Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-22404 Open/Close region request may be executed twice when mast…#234
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11 ...procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6 hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 ...-server/src/main/java/org/apache/hadoop/hbase/master/assignment/CloseRegionProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 ...e-server/src/main/java/org/apache/hadoop/hbase/master/assignment/OpenRegionProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16 ...er/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionRemoteProcedureBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4 ...er/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionTransitionProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6 hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/UnassignProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10 ...erver/src/main/java/org/apache/hadoop/hbase/master/procedure/SplitWALRemoteProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15 .../main/java/org/apache/hadoop/hbase/master/procedure/SwitchRpcThrottleRemoteProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8 ...server/src/main/java/org/apache/hadoop/hbase/master/replication/RefreshPeerProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10 ...a/org/apache/hadoop/hbase/master/replication/SyncReplicationReplayWALRemoteProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60 hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,6 +51,7 @@ | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.concurrent.ConcurrentMap; | ||
| import java.util.concurrent.ConcurrentSkipListMap; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
| import java.util.function.Function; | ||
| @@ -191,6 +192,8 @@ | ||
| import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting; | ||
| import org.apache.hbase.thirdparty.com.google.common.base.Preconditions; | ||
| import org.apache.hbase.thirdparty.com.google.common.base.Throwables; | ||
| import org.apache.hbase.thirdparty.com.google.common.cache.Cache; | ||
| import org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder; | ||
| import org.apache.hbase.thirdparty.com.google.common.collect.Maps; | ||
| import org.apache.hbase.thirdparty.com.google.protobuf.BlockingRpcChannel; | ||
| import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; | ||
| @@ -255,6 +258,18 @@ public class HRegionServer extends HasThread implements | ||
| protected final ConcurrentMap<byte[], Boolean> regionsInTransitionInRS = | ||
| new ConcurrentSkipListMap<>(Bytes.BYTES_COMPARATOR); | ||
| /** | ||
| * Used to cache the open/close region procedures which already submitted. | ||
| * See {@link #submitRegionProcedure(long)}. | ||
| */ | ||
| private final ConcurrentMap<Long, Long> submittedRegionProcedures = new ConcurrentHashMap<>(); | ||
| /** | ||
| * Used to cache the open/close region procedures which already executed. | ||
Apache9 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| * See {@link #submitRegionProcedure(long)}. | ||
| */ | ||
| private final Cache<Long, Long> executedRegionProcedures = | ||
| CacheBuilder.newBuilder().expireAfterAccess(600, TimeUnit.SECONDS).build(); | ||
| // Cache flushing | ||
| protected MemStoreFlusher cacheFlusher; | ||
| @@ -3882,6 +3897,51 @@ void reportProcedureDone(ReportProcedureDoneRequest request) throws IOException | ||
| } | ||
| } | ||
| /** | ||
| * Will ignore the open/close region procedures which already submitted or executed. | ||
| * | ||
| * When master had unfinished open/close region procedure and restarted, new active master may | ||
| * send duplicate open/close region request to regionserver. The open/close request is submitted | ||
| * to a thread pool and execute. So first need a cache for submitted open/close region procedures. | ||
| * | ||
| * After the open/close region request executed and report region transition succeed, cache it in | ||
| * executed region procedures cache. See {@link #finishRegionProcedure(long)}. After report region | ||
| * transition succeed, master will not send the open/close region request to regionserver again. | ||
| * And we thought that the ongoing duplicate open/close region request should not be delayed more | ||
| * than 600 seconds. So the executed region procedures cache will expire after 600 seconds. | ||
| * | ||
| * See HBASE-22404 for more details. | ||
| * | ||
| * @param procId the id of the open/close region procedure | ||
| * @return true if the procedure can be submitted. | ||
| */ | ||
| boolean submitRegionProcedure(long procId) { | ||
| if (procId == -1) { | ||
| return true; | ||
| } | ||
| // Ignore the region procedures which already submitted. | ||
| Long previous = submittedRegionProcedures.putIfAbsent(procId, procId); | ||
| if (previous != null) { | ||
| LOG.warn("Received procedure pid={}, which already submitted, just ignore it", procId); | ||
| return false; | ||
| } | ||
| // Ignore the region procedures which already executed. | ||
| if (executedRegionProcedures.getIfPresent(procId) != null) { | ||
| LOG.warn("Received procedure pid={}, which already executed, just ignore it", procId); | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| /** | ||
| * See {@link #submitRegionProcedure(long)}. | ||
| * @param procId the id of the open/close region procedure | ||
| */ | ||
| public void finishRegionProcedure(long procId) { | ||
| executedRegionProcedures.put(procId, procId); | ||
Apache9 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| submittedRegionProcedures.remove(procId); | ||
| } | ||
| public boolean isShutDown() { | ||
| return shutDown; | ||
| } | ||
21 changes: 14 additions & 7 deletions
21 hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
I think for these procedures we should also test whether the procedure has already been finished. Anyway, should be another issue.