You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tservers hosting metadata could not complete shutdown #3512
User reports that [the issue reported in #3368] has been observed again. They don't know if it is the same reason.
These are tservers that are exclusively handling accumulo.metadata tablets. They were stuck spamming the following messages:
SessionManager INFO : Closing idle session from user=!SYSTEM, client=<manager node>
Tablet DEBUG: Waiting to completeClose for ..., 0 writes 1 scans
This was seen with ACCUMULO 2.1.1-RC2 (which was released as 2.1.1)
While examining the code looking for causes I found one possible candidate cause for this. It may not be the cause of this problem, but it needs to be fixed. Scan sessions register a cleanup call if the session is not accessed in a certain amount of time. This cleanup code calls session.cleanUp which returns a boolean, however that return value is not checked. When it returns false the session was not cleaned up and clean up needs to be attempted again later. Below is the line where the return value was not checked.
I may have been able to reproduce this. I was running the following in jshell because I suspected an issue with isolated scans. I currently have a tablet stuck in close waiting on a scan. I am investigating the stuck tablet.
client.tableOperations().create("foo");
try(varwriter = client.createBatchWriter("foo")) {
for(inti = 0; i < 1000000; i++) {
Mutationm = newMutation(String.format("%08d", i));
m.put("","","");
writer.addMutation(m);
}
}
client.tableOperations().flush("foo",null,null,true);
Runnabletask = newRunnable() {
@Overridepublicvoidrun() {
while(true) {
try (varscanner = newIsolatedScanner(client.createScanner("foo"))) {
// TODO maybe do not close scanner? The following limit was placed on the stream to // avoid reading all the data possibly leaving a scan session active on the tserverSystem.out.println(newDate()+" "+scanner.stream().limit(500000).count());
} catch (Exceptione) {
e.printStackTrace();
break;
}
}
}
};
ExecutorServiceservice = Executors.newFixedThreadPool(10);
for(inti =0; i< 10; i++){
service.execute(task);
};
// do periodic splits to force tablet to close.. TODO eventually splitting tablet we are not scanning abovefor(inti = 0; i < 1000000; i+=1000) {
Stringsplit = String.format("%08d", i);
client.tableOperations().addSplits("foo", newTreeSet<>(List.of(newText(split))));
System.out.println(newDate()+" added split "+split);
Thread.sleep(500);
}
@keith-turner asked to see if others could replicate his error by running the code in the previous comment. I was able to do so. Afterward, he asked for checks to be put in the code when the session cleanup method was called. I added checks in three locations within the SessionManager and re-ran the test. Doing so indicated that the session.close() method returned false when called within removeSession around line 212.
The modified code was as follows:
if (doCleanup) {
boolean cleanup = session.cleanup();
if (!cleanup) {
log.info(">>>> session.cleanup() false around line 212");
}
}
The following line appears in tserver.log:
2023-06-29T09:35:30,313 [session.SessionManager] INFO : >>>> session.cleanup() false around line 212
I allowed the jshell session to run about 11 minutes before force quitting. The output was similar to the lines below:
Thu Jun 29 09:35:29 EDT 2023 added split 00014000
Thu Jun 29 09:35:14 EDT 2023 500000
Thu Jun 29 09:35:14 EDT 2023 500000
2023-06-29T09:37:31,344 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 5 failures.
2023-06-29T09:37:38,735 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 50 failures.
2023-06-29T09:37:45,736 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 100 failures.
2023-06-29T09:37:52,872 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 150 failures.
...
2023-06-29T09:45:58,101 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 3650 failures.
2023-06-29T09:46:05,042 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 3700 failures.
2023-06-29T09:46:12,024 [admin.TableOperations] WARN : Having difficulty locating hosting tabletserver for split 00015000 on table foo. Seen 3750 failures.
One way to fix this is to have single method like the following in SessionManager that is used for all session cleanup.
voidcleanup(Collection<Session> sessions){
for(varsession : sessions){
if(!session.cleanup()){
// Queue session for deferred clean up at later time. This could be done by scheduling a // task to run later or adding it a collection that is periodically inspected by a scheduled // task. The sweep() method in session manager method handles deferred cleanup for // itself, this could be generalized for the entire class. The sweep() method is already// called periodically.
}
}
Looking at the implementations of Session.cleanup(), only SingleScanSession and SummarySession can return false. SummarySession just returns the return value of Future.cancel(true), which I think in most cases will end cancelling the future. The SingleScanSession case is more complicated as it calls Scanner.close which will return false if it doesn't obtain a lock within 10ms.
Should Scanner.close call isolatedDataSource.interrupt() before trying to obtain the scannerSemaphore ?
I think the interruptFlag that Scanner.close() does set to true is also passed to the scanner data source when its created, so that should be the same.
@keith-turner@jmark99 - I turned your jshell test into an IT in dlmarion@cfb428d. I was able to reproduce the tablet server shutting down, but I think the cause may be different. What I'm seeing in the logs is that the Manager requests that the root and test table tablet be unloaded from the tablet server. The TabletGroupWatcher for the metadata table however never requests that the metadata table tablet be unloaded. The TabletGroupWatcher for the metadata table appears to be waiting at MetadataTableScanner.hasNext(), possibly due to the root tablet being unloaded?
Anyway, I'm not sure that what I'm seeing is related to this specific issue, but I wanted to provide the information just in case.
Edit: I guess the one interesting thing here is that the IsolatedScanners in the test do not prevent the test table from being unloaded.
Update: Did some further digging and I think there is an issue with the TabletGroupWatcher, specifically in the assigned / hosted accounting. In my test when I stop the one and only TabletServer, it sends unload messages to suspend all tables (root, metadata, test). The root and test tablets close with no issue, but the metadata tablet is stuck closing because the root tablet is closed. I took a couple of jstacks and all of them looked like:
"Minor compacting !0;~<" #306 daemon prio=5 os_prio=0 cpu=11.56ms elapsed=138.38s tid=0x00007fa2f009b000 nid=0x1ac34 in Object.wait() [0x00007fa2178f6000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.18/Native Method)
- waiting on <no object reference available>
at java.lang.Object.wait(java.base@11.0.18/Object.java:328)
at org.apache.accumulo.core.clientImpl.TabletServerBatchWriter.waitRTE(TabletServerBatchWriter.java:499)
at org.apache.accumulo.core.clientImpl.TabletServerBatchWriter.close(TabletServerBatchWriter.java:365)
- waiting to re-lock in wait() <0x00000000f8e443c0> (a org.apache.accumulo.core.clientImpl.TabletServerBatchWriter)
at org.apache.accumulo.core.clientImpl.BatchWriterImpl.close(BatchWriterImpl.java:58)
at org.apache.accumulo.server.metadata.TabletsMutatorImpl.close(TabletsMutatorImpl.java:81)
at org.apache.accumulo.server.metadata.TabletMutatorImpl.mutate(TabletMutatorImpl.java:41)
at org.apache.accumulo.server.util.ManagerMetadataUtil.updateTabletDataFile(ManagerMetadataUtil.java:249)
at org.apache.accumulo.tserver.tablet.Tablet.updateTabletDataFile(Tablet.java:2053)
- locked <0x00000000f26b17f8> (a java.lang.Object)
at org.apache.accumulo.tserver.tablet.DatafileManager.bringMinorCompactionOnline(DatafileManager.java:362)
at org.apache.accumulo.tserver.tablet.Tablet.minorCompact(Tablet.java:496)
at org.apache.accumulo.tserver.tablet.MinorCompactionTask.run(MinorCompactionTask.java:111)
at org.apache.accumulo.tserver.tablet.Tablet.initiateClose(Tablet.java:955)
at org.apache.accumulo.tserver.tablet.Tablet.close(Tablet.java:895)
at org.apache.accumulo.tserver.UnloadTabletHandler.run(UnloadTabletHandler.java:93)
at org.apache.accumulo.core.trace.TraceWrappedRunnable.run(TraceWrappedRunnable.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.18/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.18/ThreadPoolExecutor.java:628)
at org.apache.accumulo.core.trace.TraceWrappedRunnable.run(TraceWrappedRunnable.java:52)
at java.lang.Thread.run(java.base@11.0.18/Thread.java:829)
I was able to reproduce the tablet server shutting down, but I think the cause may be different. What I'm seeing in the logs is that the Manager requests that the root and test table tablet be unloaded from the tablet server.
That sounds like an additional bug possibly, I opened #3569 as a fix for the problem of sessions not being cleaned up. We should not close this issue for #3569 w/o figuring out the TGW problem or opening an issue for it.
Activity
keith-turner commentedon Jun 26, 2023
While examining the code looking for causes I found one possible candidate cause for this. It may not be the cause of this problem, but it needs to be fixed. Scan sessions register a cleanup call if the session is not accessed in a certain amount of time. This cleanup code calls session.cleanUp which returns a boolean, however that return value is not checked. When it returns false the session was not cleaned up and clean up needs to be attempted again later. Below is the line where the return value was not checked.
accumulo/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java
Line 285 in 260fde4
I will work on a fix for this. When cleanUp returns false the session manager needs to attempt clean up again later, currently it does not.
keith-turner commentedon Jun 28, 2023
I may have been able to reproduce this. I was running the following in jshell because I suspected an issue with isolated scans. I currently have a tablet stuck in close waiting on a scan. I am investigating the stuck tablet.
jmark99 commentedon Jun 29, 2023
@keith-turner asked to see if others could replicate his error by running the code in the previous comment. I was able to do so. Afterward, he asked for checks to be put in the code when the session cleanup method was called. I added checks in three locations within the
SessionManagerand re-ran the test. Doing so indicated that thesession.close()method returned false when called withinremoveSessionaround line 212.The modified code was as follows:
The following line appears in tserver.log:
2023-06-29T09:35:30,313 [session.SessionManager] INFO : >>>> session.cleanup() false around line 212I allowed the jshell session to run about 11 minutes before force quitting. The output was similar to the lines below:
keith-turner commentedon Jun 29, 2023
One way to fix this is to have single method like the following in SessionManager that is used for all session cleanup.
dlmarion commentedon Jun 29, 2023
Looking at the implementations of
Session.cleanup(), onlySingleScanSessionandSummarySessioncan returnfalse.SummarySessionjust returns the return value ofFuture.cancel(true), which I think in most cases will end cancelling the future. TheSingleScanSessioncase is more complicated as it callsScanner.closewhich will returnfalseif it doesn't obtain a lock within 10ms.dlmarion commentedon Jun 29, 2023
Should
Scanner.closecallisolatedDataSource.interrupt()before trying to obtain thescannerSemaphore?keith-turner commentedon Jun 29, 2023
I think the interruptFlag that Scanner.close() does set to true is also passed to the scanner data source when its created, so that should be the same.
Created an IT to try and reproduce apache#3512
dlmarion commentedon Jun 30, 2023
@keith-turner @jmark99 - I turned your jshell test into an IT in dlmarion@cfb428d. I was able to reproduce the tablet server shutting down, but I think the cause may be different. What I'm seeing in the logs is that the Manager requests that the root and test table tablet be unloaded from the tablet server. The TabletGroupWatcher for the metadata table however never requests that the metadata table tablet be unloaded. The TabletGroupWatcher for the metadata table appears to be waiting at MetadataTableScanner.hasNext(), possibly due to the root tablet being unloaded?
Anyway, I'm not sure that what I'm seeing is related to this specific issue, but I wanted to provide the information just in case.
Edit: I guess the one interesting thing here is that the IsolatedScanners in the test do not prevent the test table from being unloaded.
Update: Did some further digging and I think there is an issue with the TabletGroupWatcher, specifically in the assigned / hosted accounting. In my test when I stop the one and only TabletServer, it sends unload messages to suspend all tables (root, metadata, test). The root and test tablets close with no issue, but the metadata tablet is stuck closing because the root tablet is closed. I took a couple of jstacks and all of them looked like:
ensures sessions are always cleaned up
keith-turner commentedon Jul 6, 2023
That sounds like an additional bug possibly, I opened #3569 as a fix for the problem of sessions not being cleaned up. We should not close this issue for #3569 w/o figuring out the TGW problem or opening an issue for it.
ensures sessions are always cleaned up (#3569)
adds logging when tablet close is waiting on a scan
ctubbsii commentedon Jul 11, 2023
With #3571, it looks like this can be closed. Is there something keeping this issue open?
dlmarion commentedon Jul 27, 2023
I talked with @ivakegg , he said we are good to close this and they will open a new issue if needed.