You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by vi...@apache.org on 2018/11/17 00:26:03 UTC
phoenix git commit: PHOENIX-5005 Server-side delete / upsert-select
potentially blocked after a split
Repository: phoenix
Updated Branches:
refs/heads/4.x-HBase-1.4 0d5d48111 -> 9a6abc299
PHOENIX-5005 Server-side delete / upsert-select potentially blocked after a split
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9a6abc29
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9a6abc29
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9a6abc29
Branch: refs/heads/4.x-HBase-1.4
Commit: 9a6abc2997cd8a3036498f50a74b8ab3f7ef9959
Parents: 0d5d481
Author: Vincent Poon <vi...@apache.org>
Authored: Thu Nov 8 15:38:20 2018 -0800
Committer: Vincent Poon <vi...@apache.org>
Committed: Fri Nov 16 16:25:57 2018 -0800
----------------------------------------------------------------------
.../UngroupedAggregateRegionObserver.java | 43 ++++++++++++--------
1 file changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/9a6abc29/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index 73386a2..26e338f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -262,7 +262,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
// flush happen which decrease the memstore size and then writes allowed on the region.
for (int i = 0; blockingMemstoreSize > 0 && region.getMemstoreSize() > blockingMemstoreSize && i < 30; i++) {
try {
- checkForRegionClosing();
+ checkForRegionClosingOrSplitting();
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
@@ -311,7 +311,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
* a high chance that flush might not proceed and memstore won't be freed up.
* @throws IOException
*/
- private void checkForRegionClosing() throws IOException {
+ private void checkForRegionClosingOrSplitting() throws IOException {
synchronized (lock) {
if(isRegionClosingOrSplitting) {
lock.notifyAll();
@@ -1333,13 +1333,31 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
@Override
public void preSplit(ObserverContext<RegionCoprocessorEnvironment> c, byte[] splitRow)
throws IOException {
- // Don't allow splitting if operations need read and write to same region are going on in the
- // the coprocessors to avoid dead lock scenario. See PHOENIX-3111.
+ waitForScansToFinish(c);
+ }
+
+ // Don't allow splitting/closing if operations need read and write to same region are going on in the
+ // the coprocessors to avoid dead lock scenario. See PHOENIX-3111.
+ private void waitForScansToFinish(ObserverContext<RegionCoprocessorEnvironment> c) throws IOException {
+ int maxWaitTime = c.getEnvironment().getConfiguration().getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT,
+ HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
+ long start = EnvironmentEdgeManager.currentTimeMillis();
synchronized (lock) {
isRegionClosingOrSplitting = true;
- if (scansReferenceCount > 0) {
- throw new IOException("Operations like local index building/delete/upsert select"
- + " might be going on so not allowing to split.");
+ while (scansReferenceCount > 0) {
+ try {
+ lock.wait(1000);
+ if (EnvironmentEdgeManager.currentTimeMillis() - start >= maxWaitTime) {
+ isRegionClosingOrSplitting = false; // must reset in case split is not retried
+ throw new IOException(String.format(
+ "Operations like local index building/delete/upsert select"
+ + " might be going on so not allowing to split/close. scansReferenceCount=%s region=%s",
+ scansReferenceCount,
+ c.getEnvironment().getRegionInfo().getRegionNameAsString()));
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
}
}
}
@@ -1360,16 +1378,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
@Override
public void preClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested)
throws IOException {
- synchronized (lock) {
- isRegionClosingOrSplitting = true;
- while (scansReferenceCount > 0) {
- try {
- lock.wait(1000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- }
+ waitForScansToFinish(c);
}
@Override