Firstly - good luck! I hope whatever it is, that it resolves itself sooner rather than later, and that it's not too serious.

For suggestions, it's going to depend on what type of problem it is.

For a short term (or not overly personal) problem, like extended family issues or similar, take day off and either:

* Sort out the issue (if you can)

* Relax - just taking a day for yourself and doing what you feel like doing (even if it's lying in front of the TV all day) can do wonders for your mental state

Like another poster pointed out, the issue can be more productively dealt with or processed with a dedicated day, rather than trying to do it inbetween work commitments.

For longer term issues (serious illness in immediate family, relationship problems, etc), there is no surefire way to deal with it, but there are ways to make it impact your work less (note: it WILL impact your work - the goal is to make that impact as minimal as possible). Keep in mind that your health and mental health impacts your ability to work and provide for yourself (and family). Protect this at all costs, and remember that family responsibilities should come first (any reasonable employer will understand this to some degree).

Some things that worked for me:

* Inform a superior that you trust about the issue. Tell them that you will do your best to minimise impact on work, but it's important that someone knows you're not just 'slacking off', but dealing with problems. Ideally, this is someone that will have your back.

* Talk to someone, be it a friend, professional, family member, etc. Talking to someone helps you process the issue quicker, and takes some of the worry off your shoulders.

* If you have elements of your job that involves close interaction with other people, do those. Interacting with another human (with the knowledge that you can't let them down while working with them) is a quick way to focus, and also has room for lighthearted interaction, or deep technical discussion with someone to take your mind off things.

* Focus (in the short term) on things that you're good at, and can do almost 'mechanically'. If you're good at coding, but hate documentation, do the coding. If your superior knows what's going on, they'll understand.

* Find things that are mechanical to do - if you need to test things, and there are test plans and procedures in place that you can follow systematically without too much thinking involved, do those.

* Meetings. Everyone jokes about them, but they are good in this case (unless you have to prepare/present them).

* Lower your expectations for daily output, so that you are not disappointed at the end of a day. Do, however, try and absolutely stick to these lowered expectations. Start small with tasks, and once you're in the groove, keep running with it. Try your best to not overthink things - break them down into small, manageable chunks.

* Try and avoid unnecessary interruptions when you're in the zone, because at this moment, it will take you much longer to get back in the zone.

* Try and avoid things that will remind you of the issue while at work - deal with them after or before work. Do not check personal e-mails, etc. Obviously this is not applicable in all scenarios, but helps for things that you can't do much about short term.

* If it all gets too much, take a day off, and relax. A 'mental health day' can buy you another month work of mostly productive work days.

I hope this helps!