{"record":{"id":"4e405ab4e7020898","repo":"apache/cassandra","slug":"not-executing-task-on-gossipstage-it-has-shut-do","errorCode":null,"errorMessage":"Not executing task on GossipStage - it has shut down","messagePattern":"Not executing task on GossipStage - it has shut down","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/gms/Gossiper.java","lineNumber":543,"sourceCode":"    public static void runInGossipStageBlocking(Runnable runnable)\n    {\n        // run immediately if we're already in the gossip stage\n        if (isInGossipStage())\n        {\n            runnable.run();\n            return;\n        }\n        FutureTask<?> task = new FutureTask<>(runnable);\n        try\n        {\n            Stage.GOSSIP.execute(task);\n\n        }\n        catch (RejectedExecutionException e)\n        {\n            if (e.getMessage() != null && e.getMessage().contains(\"GossipStage has shut down\"))\n            {\n                logger.warn(\"Not executing task on GossipStage - it has shut down\", e);\n                return;\n            }\n            else\n                throw e;\n        }\n        try\n        {\n            task.get();\n        }\n        catch (InterruptedException e)\n        {\n            throw new UncheckedInterruptedException(e);\n        }\n        catch (ExecutionException e)\n        {\n            throw new AssertionError(e);\n        }\n    }","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/gms/Gossiper.java#L525-L561","documentation":"Gossiper submits tasks to the GossipStage executor; after gossip has been shut down during node shutdown, the executor rejects new tasks with a RejectedExecutionException whose message mentions 'GossipStage has shut down'. Gossiper detects this and logs a warning instead of propagating the exception, allowing callers like convict/doStatusCheck to unwind cleanly during shutdown.","triggerScenarios":"A gossip-stage task (convict, doStatusCheck, evictIfExpired, onResponse, unsafeBroadcastLeftStatus) is scheduled or run after Gossiper.stop/shutdown has closed the GossipStage executor; the executor throws RejectedExecutionException.","commonSituations":"Node shutdown or drain while gossip messages or failure-detection timers still fire; test teardown where the gossiper is stopped but background tasks linger; calling Gossiper APIs after StorageService.stopGossiping.","solutions":["Verify this occurs only during shutdown; if seen at runtime, ensure Gossiper.stop() is called only when the node is truly stopping.","Fix ordering in shutdown code: cancel the gossip task before shutting down GossipStage.","If it appears in tests, wait for in-flight gossip tasks to complete before stopping the gossiper.","If a caller throws this at runtime (not the warn path), check that MessagingService/gossip were not shut down prematurely."],"exampleFix":"// before\ngossiper.convict(endpoint);\ngossiper.stop();\n// after\ngossiper.stop();\n// avoid convict() after stop; guard if needed\nif (Gossiper.instance.isEnabled())\n    Gossiper.instance.convict(endpoint);","handlingStrategy":"try-catch","validationCode":"if (!Gossiper.instance.isEnabled()) { /* skip gossip task */ }","typeGuard":"boolean gossipAlive = Gossiper.instance != null && Gossiper.instance.isEnabled();","tryCatchPattern":"try { Gossiper.instance.convict(ep); } catch (RejectedExecutionException e) { logger.debug(\"gossip shut down; ignoring\", e); }","preventionTips":["Check Gossiper.isEnabled() before submitting gossip work after shutdown begins.","Order shutdown: cancel scheduled gossip task before stopping GossipStage.","In tests, quiesce executors before tearing down the gossiper."],"tags":["cassandra","gossip","shutdown","rejected-execution"],"backgroundTag":"rejected-execution-after-shutdown","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}