Skip to content

Fixed possible deadlock issue during fixSplit - #6588

Open
ddanielr wants to merge 1 commit into
apache:2.1from
ddanielr:bugfix/fix-deadlock-on-fixSplit
Open

ddanielr wants to merge 1 commit into
apache:2.1from
ddanielr:bugfix/fix-deadlock-on-fixSplit

Conversation

@ddanielr

Copy link
Copy Markdown
Contributor

This code held a lock for server.openingTablets but would attempt to modify server.unopenedTablets without holding that Object's lock.

Other sections of code that lock on these SortedSets always try to lock server.unopenedTablets first. This section of the code doesn't do that and could result in a dead lock situation.

The fix was to have this code attempt to grab the unopenedTablets lock first so it follows the same lock pattern as other code.

@ddanielr ddanielr added this to the 2.1.7 milestone Oct 15, 2026
This code held a lock for `server.openingTablets` but would attempt to
modify `server.unopenedTablets` without holding that lock.

Other sections of code that lock on these Sets always try to lock
`server.unopenedTablets` first. This section of the code doesn't do that
and could result in a dead lock situation.
@ddanielr
ddanielr force-pushed the bugfix/fix-deadlock-on-fixSplit branch from 4c56aa2 to 00c3798 Compare October 15, 2026 04:16
.contains(fixedExtent)) {
throw new IllegalStateException(
"Fixed split does not overlap " + extent + " " + fixedExtent);
synchronized (server.unopenedTablets) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the synchronization for this code block is inconsistent with the other code blocks in this method. However, I'm wondering if some of the other places in this method that synchronize on openingTablets and unopenedTablets are not needed. Both of these objects are synchronized SortedSets, which only need to be used in a synchronized block in a couple of cases according to the javadoc.

For example, there are a couple of places where the following is done, but I don't think it's necessary.

      synchronized (server.openingTablets) {
        server.openingTablets.remove(extent);
        server.openingTablets.notifyAll();
      }

I don't think that a call to 'openingTablets.removeorunopenedTablets.add` needs to be done in a synchronized block (according to the javadoc) and I'm not sure that this code block needs to be synchronized at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I added this as I was investigating a solution for the spotbugs issues that I spun off into #6587.

it would be ideal for this code to be simplified to avoid this instead.

@DomGarguilo

Copy link
Copy Markdown
Member

#6621 addresses this too. If that is merged this PR should be closed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants