I'm developing a telecom messaging platform in C, and I'm going to need multiple processes to be working with MySQL DB.

How can I make two processes read/write to/from a Mysql DB and, if/when one of them goes down, get the other to seamlessly take over the work until the dead process gets back to work? I was thinking/googling some options and am stuck in place where I don't know which one to choose.

What I think so far is that table lock is not the best option to go for, as it will stall the other process until the table is unlocked. The other option is to use row-level locks or manual locks, but I can't find the best way to do it.

  • 1
    just a comment, check out Erlang/OTP as a language it was built to do this kind of stuff.
    – Zachary K
    Commented Mar 21, 2012 at 8:27
  • So this question is about 2 (or more) threads talking to MySQL over the same connection?
    – N.B.
    Commented Apr 20, 2012 at 10:47
  • If my answer fit you, please feel free to upvote it. Thanks in advance ^^
    – Pascal Qyy
    Commented Nov 2, 2013 at 10:50

2 Answers 2


MySQL should automatically unlock the tables (and if you're using a transactional table type it'll do something with the transaction - either roll back or commit depending on options etc) when the second process dies (since the connection will drop.) If your question is about having two processes for reliability working on a single work queue, that info may help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.