Skip to content

Commit 767a68a

Browse files
authored
fixes exception for canceled scan task (apache#5093)
An exception was happening when a scan task was canceled before it ever ran. This was caused by transitionFromRunning() executing when transitoinToRunning() had never executed. When this happened a precondition check that the scanThread was non-null would fail. These changes only execute transitionFromRunning() when transitionToRunning() has executed.
1 parent fa3de84 commit 767a68a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

server/tserver/src/main/java/org/apache/accumulo/tserver/scan/LookupTask.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ public void run() {
6464
MultiScanSession session = (MultiScanSession) server.getSession(scanID);
6565
String oldThreadName = Thread.currentThread().getName();
6666

67+
if (!transitionToRunning()) {
68+
return;
69+
}
70+
// Do not add any code here. Need to ensure that transitionFromRunning() runs in the finally
71+
// block when transitionToRunning() returns true.
6772
try {
6873
if (isCancelled() || session == null) {
6974
return;
7075
}
7176

72-
if (!transitionToRunning()) {
73-
return;
74-
}
75-
7677
TableConfiguration acuTableConf = server.getTableConfiguration(session.threadPoolExtent);
7778
long maxResultsSize = acuTableConf.getAsBytes(Property.TABLE_SCAN_MAXMEM);
7879

server/tserver/src/main/java/org/apache/accumulo/tserver/scan/NextBatchTask.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ public void run() {
5454
final SingleScanSession scanSession = (SingleScanSession) server.getSession(scanID);
5555
String oldThreadName = Thread.currentThread().getName();
5656

57+
if (!transitionToRunning()) {
58+
return;
59+
}
60+
// Do not add any code here. Need to ensure that transitionFromRunning() runs in the finally
61+
// block when transitionToRunning() returns true.
5762
try {
5863
if (isCancelled() || scanSession == null) {
5964
return;
6065
}
6166

62-
if (!transitionToRunning()) {
63-
return;
64-
}
65-
6667
Thread.currentThread()
6768
.setName("User: " + scanSession.getUser() + " Start: " + scanSession.startTime
6869
+ " Client: " + scanSession.client + " Tablet: " + scanSession.extent);

0 commit comments

Comments
 (0)