Patrick Jane
Patrick Jane

Reputation: 336

MySQL multiple processes writing

I am trying to build a database that will be used to store the results on some tests. The problem is that these tests run in parallel and separate processes and after each one of them finishes it will commit the results to the database. Now I know that MySQL is designed to handle such situations and some engines like InnoDB can achieve row level locking.

  1. If a process will to access a locked table or entry, will this be process be blocked and poll until the table or the entry is unlocked or will the query be cached and the process can terminate normally ?
  2. When a process will try to connect to the server when it is down, what would happen or it is just up to me to handle it ?

Any help is highly appreciated.

Upvotes: 1

Views: 2108

Answers (1)

Vesper
Vesper

Reputation: 18757

The number 2 is up to you, what will you do when mysql_connect() or whatever you use to connect to database will throw an exception. The number 1 issue will be resolved at MySQL level, depending on what does your process require to do with locked table or row. Usually this results in a temporary delay for query to access the data in locked areas, but can return an out-of-time error, should the other process lock the table/row for an extended period of time. Also a mutual lock is possible, say process A locks row 1, and process B locks row 2, and A wants data from row 2 and B wants data from row 1. This is named "deadlocking", and one of the processes is chosen as a deadlock victim and its query returns a failure.

Upvotes: 2

Related Questions