in reply to Re: DBIx::Class and Parallel SQLite Transactions
in thread DBIx::Class and Parallel SQLite Transactions

I would agree with your statement if there were only insert or update calls being made during transaction; however, there are additional cycles spent and database calls made to determine whether updates or inserts are needed. Also added to this is that the transaction contains one initial operation to set an active flag inactive for all affected rows, followed by the update/insert action. So there are opportunities to for parallel execution, at least in theory

After mulling it over, I am currently deciding to stick with a single writer; however, I am going to refactor the update procedure to utilize a temporary table. My initial plan looks something like:

  1. Create database transaction semaphore
  2. Create update thread
  3. Create temporary table with the same structure as the destination table
  4. Copy rows of interest from the destination table to the temporary table
  5. Perform all operations on the temporary table where there will be no concurrency issues
  6. Grab database transaction semaphore
  7. Update destination table from temporary table
  8. Release database transaction semaphore
  9. Flush data in temporary table
  10. Start over for next set of data

I believe that this approach, while more complex than my current approach, will squeeze most of if not all of the non update/insert specific processing cycles out of the actual transaction where concurrency is an issue while insuring that multiple writers will not be attempting write transaction at the same time

I recognize that this essentially duplicates the locking performed by SQLite; however, I cannot figure out how to do to keep DBIC from either throwing an exception or to handle the exception properly because DBIC's exception returns a null error message in $@.

Additionally, I am having problems identifying how to create the temporary table using DBIC. I have tried to build on some work documented in some early threads in here the monastery but realized little success with it yet. I'll start a new thread on that topic later today and will update this thread with its link

Thanks to all of the Monks who have replied with input!

  • Comment on Re^2: DBIx::Class and Parallel SQLite Transactions