-
Notifications
You must be signed in to change notification settings - Fork 619
HDDS-10138. NPE for SstFilteringService in OMDBCheckpointServlet.Lock #6015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f82cee9
0eeedc7
41d18a1
707098b
6834b58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |||||||||||||||||||||||||||||||
| import org.apache.hadoop.security.UserGroupInformation; | ||||||||||||||||||||||||||||||||
| import org.apache.ozone.rocksdiff.RocksDBCheckpointDiffer; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import org.apache.ratis.thirdparty.com.google.common.base.Preconditions; | ||||||||||||||||||||||||||||||||
| import org.jetbrains.annotations.NotNull; | ||||||||||||||||||||||||||||||||
| import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||
| import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||
|
|
@@ -55,6 +56,7 @@ | |||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||||||||||
| import java.util.Objects; | ||||||||||||||||||||||||||||||||
| import java.util.Optional; | ||||||||||||||||||||||||||||||||
| import java.util.Set; | ||||||||||||||||||||||||||||||||
| import java.util.concurrent.atomic.AtomicLong; | ||||||||||||||||||||||||||||||||
| import java.util.stream.Collectors; | ||||||||||||||||||||||||||||||||
|
|
@@ -644,29 +646,42 @@ public BootstrapStateHandler.Lock getBootstrapStateLock() { | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| static class Lock extends BootstrapStateHandler.Lock { | ||||||||||||||||||||||||||||||||
| private final BootstrapStateHandler keyDeletingService; | ||||||||||||||||||||||||||||||||
| private final BootstrapStateHandler sstFilteringService; | ||||||||||||||||||||||||||||||||
| private final BootstrapStateHandler rocksDbCheckpointDiffer; | ||||||||||||||||||||||||||||||||
| private final BootstrapStateHandler snapshotDeletingService; | ||||||||||||||||||||||||||||||||
| private final Optional<BootstrapStateHandler> keyDeletingService; | ||||||||||||||||||||||||||||||||
| private final Optional<BootstrapStateHandler> sstFilteringService; | ||||||||||||||||||||||||||||||||
| private final Optional<BootstrapStateHandler> rocksDbCheckpointDiffer; | ||||||||||||||||||||||||||||||||
| private final Optional<BootstrapStateHandler> snapshotDeletingService; | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion. Updated. |
||||||||||||||||||||||||||||||||
| private final OzoneManager om; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Lock(OzoneManager om) { | ||||||||||||||||||||||||||||||||
| Preconditions.checkNotNull(om); | ||||||||||||||||||||||||||||||||
| Preconditions.checkNotNull(om.getKeyManager()); | ||||||||||||||||||||||||||||||||
| Preconditions.checkNotNull(om.getMetadataManager()); | ||||||||||||||||||||||||||||||||
| Preconditions.checkNotNull(om.getMetadataManager().getStore()); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| this.om = om; | ||||||||||||||||||||||||||||||||
| keyDeletingService = om.getKeyManager().getDeletingService(); | ||||||||||||||||||||||||||||||||
| sstFilteringService = om.getKeyManager().getSnapshotSstFilteringService(); | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer = om.getMetadataManager().getStore() | ||||||||||||||||||||||||||||||||
| .getRocksDBCheckpointDiffer(); | ||||||||||||||||||||||||||||||||
| snapshotDeletingService = om.getKeyManager().getSnapshotDeletingService(); | ||||||||||||||||||||||||||||||||
| keyDeletingService = Optional.ofNullable(om.getKeyManager().getDeletingService()); | ||||||||||||||||||||||||||||||||
| sstFilteringService = Optional.ofNullable(om.getKeyManager().getSnapshotSstFilteringService()); | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer = Optional.ofNullable(om.getMetadataManager().getStore() | ||||||||||||||||||||||||||||||||
| .getRocksDBCheckpointDiffer()); | ||||||||||||||||||||||||||||||||
| snapshotDeletingService = Optional.ofNullable(om.getKeyManager().getSnapshotDeletingService()); | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. PTAL. |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||
| public BootstrapStateHandler.Lock lock() | ||||||||||||||||||||||||||||||||
| throws InterruptedException { | ||||||||||||||||||||||||||||||||
| // First lock all the handlers. | ||||||||||||||||||||||||||||||||
| keyDeletingService.getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| sstFilteringService.getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer.getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| snapshotDeletingService.getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| if (keyDeletingService.isPresent()) { | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can changed to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||||||||||||||||||||||||||||||||
| keyDeletingService.get().getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (sstFilteringService.isPresent()) { | ||||||||||||||||||||||||||||||||
| sstFilteringService.get().getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (rocksDbCheckpointDiffer.isPresent()) { | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer.get().getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (snapshotDeletingService.isPresent()) { | ||||||||||||||||||||||||||||||||
| snapshotDeletingService.get().getBootstrapStateLock().lock(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. PTAL. |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Then wait for the double buffer to be flushed. | ||||||||||||||||||||||||||||||||
| om.awaitDoubleBufferFlush(); | ||||||||||||||||||||||||||||||||
|
|
@@ -675,10 +690,11 @@ public BootstrapStateHandler.Lock lock() | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||
| public void unlock() { | ||||||||||||||||||||||||||||||||
| snapshotDeletingService.getBootstrapStateLock().unlock(); | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer.getBootstrapStateLock().unlock(); | ||||||||||||||||||||||||||||||||
| sstFilteringService.getBootstrapStateLock().unlock(); | ||||||||||||||||||||||||||||||||
| keyDeletingService.getBootstrapStateLock().unlock(); | ||||||||||||||||||||||||||||||||
| snapshotDeletingService.ifPresent(deletingService -> deletingService.getBootstrapStateLock().unlock()); | ||||||||||||||||||||||||||||||||
| rocksDbCheckpointDiffer.ifPresent( | ||||||||||||||||||||||||||||||||
| rocksDBCheckpointDiffer -> rocksDBCheckpointDiffer.getBootstrapStateLock().unlock()); | ||||||||||||||||||||||||||||||||
| sstFilteringService.ifPresent(filteringService -> filteringService.getBootstrapStateLock().unlock()); | ||||||||||||||||||||||||||||||||
| keyDeletingService.ifPresent(deletingService -> deletingService.getBootstrapStateLock().unlock()); | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: this will release locks in the same order as they were acquired, instead of in reverse order. I think both are fine as long as the order is fixed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated PTAL.
I think it should be fine. However, seems like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was thinking whether it's necessary to add |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If suggestion to use list is accepted, this becomes unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. PTAL.