{"record":{"id":"4275e0813f0b0a48","repo":"apache/hadoop","slug":"cumulativecpuusageemulatorplugin-got-interrupted","errorCode":null,"errorMessage":"CumulativeCpuUsageEmulatorPlugin got interrupted. Exiting.","messagePattern":"CumulativeCpuUsageEmulatorPlugin got interrupted\\. Exiting\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/CumulativeCpuUsageEmulatorPlugin.java","lineNumber":285,"sourceCode":"        long projectedUsage = \n          currentCpuUsage + (long)((1 - currentProgress) * rate);\n        \n        if (projectedUsage < targetCpuUsage) {\n          // determine the correction factor between the current usage and the\n          // expected usage and add some weight to the target\n          long currentWeighedTarget = \n            (long)(targetCpuUsage \n                   * getWeightForProgressInterval(currentProgress));\n          \n          while (getCurrentCPUUsage() < currentWeighedTarget) {\n            emulatorCore.compute();\n            // sleep for 100ms\n            try {\n              Thread.sleep(100);\n            } catch (InterruptedException ie) {\n              String message = \n                \"CumulativeCpuUsageEmulatorPlugin got interrupted. Exiting.\";\n              throw new RuntimeException(message);\n            }\n          }\n        }\n        \n        // set the last seen progress\n        lastSeenProgress = progress.getProgress();\n        // set the last seen usage\n        lastSeenCpuUsage = getCurrentCPUUsage();\n      }\n    }\n  }\n\n  @Override\n  public void initialize(Configuration conf, ResourceUsageMetrics metrics,\n                         ResourceCalculatorPlugin monitor,\n                         Progressive progress) {\n    this.monitor = monitor;\n    this.progress = progress;","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/CumulativeCpuUsageEmulatorPlugin.java#L267-L303","documentation":"In CumulativeCpuUsageEmulatorPlugin's midlock-adjustment loop, the plugin calls emulatorCore.compute() and Thread.sleep(100) until CPU usage reaches the progress-weighted target. If the thread is interrupted during that sleep it converts the InterruptedException into a RuntimeException with this message. Interruption here is Hadoop's normal mechanism for cancelling a task attempt, so this usually means the simulated task was killed or aborted, not that CPU emulation is broken.","triggerScenarios":"Killing/aborting the gridmix job or task attempt while a CPU-emulation map task is inside its 100ms sleep; task timeout leading the framework to interrupt the task thread; cluster shutdown interrupting running simulated tasks.","commonSituations":"'hadoop job -kill' or YARN application kill during a gridmix run with resource emulation enabled (gridmix.emulators.resource-usage.plugins including the CPU plugin); long CPU-emulation tasks exceeding task timeouts; JVM reuse scenarios where interrupts leak between tasks.","solutions":["Treat the exception as expected cancellation when you intentionally killed the job; no fix needed for the simulation itself","Raise task timeouts (mapreduce.task.timeout) so CPU-emulating tasks are not interrupted by the framework mid-emulation","If you maintain this code, restore the interrupt flag and throw a quieter checked path instead of RuntimeException"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  plugin.middleware... // run job with CPU emulation\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"got interrupted\")) {\n    // task was cancelled (kill/abort); treat as shutdown, restore interrupt flag\n    Thread.currentThread().interrupt();\n    return;\n  }\n  throw e;\n}","preventionTips":["Raise mapreduce.task.timeout above the longest CPU-emulation task so framework interrupts do not fire mid-emulation","Expect these exceptions when killing gridmix runs — filter them in log analysis rather than debugging them"],"tags":["hadoop","gridmix","cpu-emulation","interrupt","concurrency"],"backgroundTag":"thread-interrupted","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}