MySQL: Transactions across multiple threads

Posted by Zombies on Stack Overflow See other posts from Stack Overflow or by Zombies
Published on 2010-03-22T20:49:58Z Indexed on 2010/03/22 20:51 UTC
Read the original article Hit count: 320

Preliminary:

I have an application which maintains a thread pool of about 100 threads. Each thread can last about 1-30 seconds before a new task replaces it. When a thread end, that thread almost always will result in inserting 1-3 records into a table, this table is used by all of the threads. Right now, no transactional support exists, but I am trying to add that now. So...

Goal

I want to implement a transaction for this. The rules for whether or not this transaction commits or rollback reside in the main thread. Basically there is a simple function that will return a boolean.

  1. Can I implement a transaction across multiple connections?
  2. If not, can multiple threads share the same connection? (Note: there are a LOT of inserts going on here, and that is a requirement).

© Stack Overflow or respective owner

Related posts about mysql

Related posts about transactions