Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-3015

Concurrent select and insert deadlock on index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 10.3.1.4
    • None
    • Store
    • None

    Description

      From the derby mailinglist

      The attached test is an attempt to simulate a typical data processing
      application, it consists of:

      • an insert thread that inserts records in batch
      • a select thread that 'processes' the records inserted by the other
        thread: 'select * from table where id > ?'

      The test deadlocks. After examining them, I think that:

      • the select thread holds an S lock on the root of the PK index: (1,1)
      • the select thread waits for an S lock on one of the uncommitted inserts
      • the insert thread holds X locks on the inserted records
      • the insert thread tries to split the btree root of the PK index:
        (1,1) by acquiring an X lock, so it's a deadlock

      I've got the same problem nearly every day in my application, therefore I simplified the example file from the mailinglist. I did also try it with MySQL without a deadlock.

      Attachments

        1. Repro3015.java
          4 kB
          Kurt Huwig

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kurti Kurt Huwig
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: