{"record":{"id":"4bec4b100f7e7fc4","repo":"apache/cassandra","slug":"unexpected-interruption","errorCode":null,"errorMessage":"Unexpected interruption","messagePattern":"Unexpected interruption","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"tools/stress/src/org/apache/cassandra/stress/StressAction.java","lineNumber":254,"sourceCode":"        final Consumer[] consumers = new Consumer[threadCount];\n        for (int i = 0; i < threadCount; i++)\n        {\n            consumers[i] = new Consumer(operations, isWarmup,\n                                        done, start, releaseConsumers, workManager, metrics, rateLimiter);\n        }\n\n        // starting worker threadCount\n        for (int i = 0; i < threadCount; i++)\n            consumers[i].start();\n\n        // wait for the lot of them to get their pants on\n        try\n        {\n            start.await();\n        }\n        catch (InterruptedException e)\n        {\n            throw new RuntimeException(\"Unexpected interruption\", e);\n        }\n        // start counting from NOW!\n        if(rateLimiter != null)\n        {\n            rateLimiter.start();\n        }\n        // release the hounds!!!\n        releaseConsumers.countDown();\n\n        metrics.start();\n\n        if (durationUnits != null)\n        {\n            Uninterruptibles.sleepUninterruptibly(duration, durationUnits);\n            workManager.stop();\n        }\n        else if (opCount <= 0)\n        {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/StressAction.java#L236-L272","documentation":"In StressAction's inner run loop, each worker thread waits on a 'start' CountDownLatch so all threads begin simultaneously. If the worker thread is interrupted while waiting on start.await(), the code rethrows as RuntimeException('Unexpected interruption', e). Stress threads are not expected to be interrupted during startup; this means the JVM/harness interrupted the thread abnormally (e.g. shutdown hook, external kill semantics, or a bug in the coordinating code).","triggerScenarios":"Thread interrupt delivered while a stress worker is blocked in start.await() before the coordinated start — e.g. JVM shutdown initiated, StressAction cancel/interrupt path racing with worker start, or a misconfigured pool shutting down workers.","commonSituations":"Ctrl-C or timeout killing the stress process just as threads start; a supervising harness calling interrupt on the stress thread pool; bug fixes/patches that interrupt workers during setup.","solutions":["Check who interrupts the worker (shutdown hooks, cancel paths) and ensure stress is not torn down during startup.","Re-run the stress command and avoid killing the process during the first seconds of the run.","If interruption is intentional (cancel), treat this RuntimeException as expected cancellation in the harness.","Wrap the StressAction invocation with try/catch (RuntimeException) checking getCause() instanceof InterruptedException for graceful shutdown."],"exampleFix":"// before\nstressAction.run(); // process may die with 'Unexpected interruption'\n// after\ntry {\n    stressAction.run();\n} catch (RuntimeException e) {\n    if (!(e.getCause() instanceof InterruptedException)) throw e;\n    // expected during shutdown\n}","handlingStrategy":"try-catch","validationCode":"// ensure no component interrupts the stress thread during coordinated start:\n// avoid calling stressThread.interrupt() before start.countDown() fires","typeGuard":null,"tryCatchPattern":"try {\n    start.await();\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt(); // restore interrupt status\n    throw new RuntimeException(\"Unexpected interruption\", e);\n}","preventionTips":["Do not interrupt stress worker threads except during deliberate shutdown.","Register shutdown hooks that let the coordinated start complete or cancel cleanly.","Run stress in environments (CI agents, supervisors) that do not SIGINT processes mid-startup."],"tags":["stress-tool","thread-interrupt","concurrency"],"backgroundTag":"unexpected-interrupt","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}