db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-2991) Index split deadlock
Date Thu, 26 Feb 2009 13:53:03 GMT

     [ https://issues.apache.org/jira/browse/DERBY-2991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Knut Anders Hatlen updated DERBY-2991:
--------------------------------------

    Derby Info: [Patch Available]

I know there are at least a couple of issues with the 2a patch, but
I'm setting the patch available flag anyway because I believe those
issues won't cause big changes to the patch, so the patch is in such a
state that it should be ready for review.

The issues I'm aware of that need to be resolved, are these:

- BTreePostCommit.purgeCommittedDeletes() needs to call
  Page.setRepositionNeeded() to tell index scans that they need to
  reposition by key. Since purgeCommittedDeletes() is only called in a
  separate transaction that has an exclusive table lock, I believe
  that this issue could only affect holdable index scans that
  reposition after a commit.

- Some callers of BTreeScan.reposition(pos,false) have
  comments/asserts stating that it is impossible that the current row
  has been purged because they hold the scan lock. I think that it is
  now possible that rows are purged from the page if we released the
  latch, so we might need to change how they handle that situation. In
  most cases (except read-uncommitted scans) the scans hold a lock on
  the current row so that it is true that the row cannot have been
  purged.

Feedback on the patch as it is would be appreciated. I'll probably be
offline for a couple of days, so I may not respond immediately to
questions/comments.

> Index split deadlock
> --------------------
>
>                 Key: DERBY-2991
>                 URL: https://issues.apache.org/jira/browse/DERBY-2991
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.2.2.0, 10.3.1.4
>         Environment: Windows XP, Java 6
>            Reporter: Bogdan Calmac
>            Assignee: Knut Anders Hatlen
>         Attachments: d2991-2a.diff, d2991-2a.stat, d2991-preview-1a.diff, d2991-preview-1a.stat,
d2991-preview-1b.diff, d2991-preview-1b.stat, d2991-preview-1c.diff, d2991-preview-1c.stat,
d2991-preview-1d.diff, d2991-preview-1d.stat, d2991-preview-1e.diff, derby.log, InsertSelectDeadlock.java,
perftest.diff, Repro2991.java, stacktraces_during_deadlock.txt, test-1.diff, test-2.diff,
test-3.diff
>
>
> After doing dome research on the mailing list, it appears that the index split deadlock
is a known behaviour, so I will start by describing the theoretical problem first and then
follow with the details of my test case.
> If you have concurrent select and insert transactions on the same table, the observed
locking behaviour is as follows:
>  - the select transaction acquires an S lock on the root block of the index and then
waits for an S lock on some uncommitted row of the insert transaction
>  - the insert transaction acquires X locks on the inserted records and if it needs to
do an index split creates a sub-transaction that tries to acquire an X lock on the root block
of the index
> In summary: INDEX LOCK followed by ROW LOCK + ROW LOCK followed by INDEX LOCK = deadlock
> In the case of my project this is an important issue (lack of concurrency after being
forced to use table level locking) and I would like to contribute to the project and fix this
issue (if possible). I was wondering if someone that knows the code can give me a few pointers
on the implications of this issue:
>  - Is this a limitation of the top-down algorithm used?
>  - Would fixing it require to use a bottom up algorithm for better concurrency (which
is certainly non trivial)?
>  - Trying to break the circular locking above, I would first question why does the select
transaction need to acquire (and hold) a lock on the root block of the index. Would it be
possible to ensure the consistency of the select without locking the index?
> -----
> The attached test (InsertSelectDeadlock.java) tries to simulate a typical data collection
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 derby log provides detail about the deadlock trace and stacktraces_during_deadlock.txt
shows that the inser thread is doing an index split.
> The test was run on 10.2.2.0 and 10.3.1.4 with identical behaviour.
> Thanks,
> Bogdan Calmac.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message