Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,19 @@ public void run() {
KeyExtent fixedExtent =
ManagerMetadataUtil.fixSplit(server.getContext(), tabletMetadata, server.getLock());

synchronized (server.openingTablets) {
server.openingTablets.remove(extent);
server.openingTablets.notifyAll();
// it expected that the new extent will overlap the old one... if it does not, it
// should not be added to unopenedTablets
if (!KeyExtent.findOverlapping(extent, new TreeSet<>(Arrays.asList(fixedExtent)))
.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.

synchronized (server.openingTablets) {
server.openingTablets.remove(extent);
server.openingTablets.notifyAll();
// it expected that the new extent will overlap the old one... if it does not, it
// should not be added to unopenedTablets
if (!KeyExtent.findOverlapping(extent, new TreeSet<>(Arrays.asList(fixedExtent)))
.contains(fixedExtent)) {
throw new IllegalStateException(
"Fixed split does not overlap " + extent + " " + fixedExtent);
}
server.unopenedTablets.add(fixedExtent);
}
server.unopenedTablets.add(fixedExtent);
}
// split was rolled back... try again
new AssignmentHandler(server, fixedExtent).run();
Expand Down
Loading