Skip to content

tservers hosting metadata could not complete shutdown #3512

Closed

Description

@ctubbsii

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)

Originally posted by @ivakegg in #3368 (comment)

Activity

  1. added
    bugThis issue has been verified to be a bug.
    on Jun 21, 2023
  2. self-assigned this
    on Jun 22, 2023
  3. keith-turner commented on Jun 26, 2023

    @keith-turner
    Contributor

    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 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.

  4. keith-turner commented on Jun 28, 2023

    @keith-turner
    Contributor

    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(var writer = client.createBatchWriter("foo")) {
                for(int i = 0; i < 1000000; i++) {
                    Mutation m = new Mutation(String.format("%08d", i));
                    m.put("","","");
                    writer.addMutation(m);
                }
            }
    
            client.tableOperations().flush("foo",null,null,true);
    
            Runnable task = new Runnable() {
                @Override
                public void run() {
                    while(true) {
                        try (var scanner = new IsolatedScanner(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 tserver
                            System.out.println(new Date()+" "+scanner.stream().limit(500000).count());
                        } catch (Exception e) {
                            e.printStackTrace();
                            break;
                        }
                    }
                }
            };
    
            ExecutorService service = Executors.newFixedThreadPool(10);
            for(int i =0; i< 10; i++){
              service.execute(task);
            };
    
            // do periodic splits to force tablet to close.. TODO eventually splitting tablet we are not scanning above
            for(int i = 0; i < 1000000; i+=1000) {
                String split = String.format("%08d", i);
                client.tableOperations().addSplits("foo", new TreeSet<>(List.of(new Text(split))));
                System.out.println(new Date()+" added split "+split);
                Thread.sleep(500);
            }
  5. jmark99 commented on Jun 29, 2023

    @jmark99
    Contributor

    @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.
    
    
  6. keith-turner commented on Jun 29, 2023

    @keith-turner
    Contributor

    One way to fix this is to have single method like the following in SessionManager that is used for all session cleanup.

    void cleanup(Collection<Session> sessions){
     for(var session : 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.
       }
    }
  7. dlmarion commented on Jun 29, 2023

    @dlmarion
    Contributor

    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.

  8. dlmarion commented on Jun 29, 2023

    @dlmarion
    Contributor

    Should Scanner.close call isolatedDataSource.interrupt() before trying to obtain the scannerSemaphore ?

  9. keith-turner commented on Jun 29, 2023

    @keith-turner
    Contributor

    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.

  10. dlmarion commented on Jun 30, 2023

    @dlmarion
    Contributor

    @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)
    
  11. keith-turner commented on Jul 6, 2023

    @keith-turner
    Contributor

    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.

  12. ctubbsii commented on Jul 11, 2023

    @ctubbsii
    MemberAuthor

    With #3571, it looks like this can be closed. Is there something keeping this issue open?

  13. dlmarion commented on Jul 27, 2023

    @dlmarion
    Contributor

    I talked with @ivakegg , he said we are good to close this and they will open a new issue if needed.

  14. added this to the 2.1.2 milestone on Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugThis issue has been verified to be a bug.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions