{"record":{"id":"ec2cd6de6bc51a65","repo":"apache/seatunnel","slug":"interrupted-during-retry","errorCode":null,"errorMessage":"Interrupted during retry","messagePattern":"Interrupted during retry","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-amazondynamodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondynamodb/sink/DynamoDbSinkClient.java","lineNumber":183,"sourceCode":"                long delay = Math.min(baseDelayMs * (1L << retryCount), maxDelayMs);\n\n                long jitter = (long) (delay * Math.random() * 0.5);\n                delay += jitter;\n\n                log.warn(\n                        \"Retrying batch write to table '{}': attempt {}/{}, \"\n                                + \"{} unprocessed items remaining, retrying in {} ms\",\n                        tableName,\n                        retryCount,\n                        maxRetries,\n                        pendingRequests.size(),\n                        delay);\n\n                try {\n                    Thread.sleep(delay);\n                } catch (InterruptedException e) {\n                    Thread.currentThread().interrupt();\n                    throw new RuntimeException(\"Interrupted during retry\", e);\n                }\n            }\n        }\n\n        if (!pendingRequests.isEmpty()) {\n            log.error(\n                    \"Failed to write {} items to table '{}' after {} retries\",\n                    pendingRequests.size(),\n                    tableName,\n                    maxRetries);\n\n            throw new RuntimeException(\n                    String.format(\n                            \"Failed to write %d items to table %s after %d retries\",\n                            pendingRequests.size(), tableName, maxRetries));\n        }\n    }\n}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-amazondynamodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondynamodb/sink/DynamoDbSinkClient.java#L165-L201","documentation":"DynamoDbSinkClient.flushWithRetry retries failed batchWriteItem requests with sleeps between attempts. If the retry sleep is interrupted (Thread.interrupt from task cancellation or shutdown), it restores the interrupt flag and throws RuntimeException('Interrupted during retry') wrapping the InterruptedException.","triggerScenarios":"A batchWriteItem request fails with unprocessed items or throttling, the client enters its backoff Thread.sleep(delay), and the executing thread is interrupted (job cancel/failover, executor shutdown) before the delay elapses.","commonSituations":"Zeta task cancelled or checkpoint failed mid-flush; engine shutting down workers while a flush retry loop is sleeping; another component interrupting the sink thread.","solutions":["Expected during cancellation — treat as part of job shutdown; re-submit/restart the job and let checkpointing replay unflushed data.","If unexpected, audit what interrupts sink threads (custom plugins, aggressive timeouts, manual Thread.interrupt calls).","Reduce retry delays/attempt count so flushes finish quickly before cancellations occur.","Ensure idempotent writes (unique keys) so interrupted/retried flushes are safe to redo."],"exampleFix":"// before\nThread.sleep(60_000); // long backoff easily interrupted by cancel\n// after\nThread.sleep(Math.min(delay, 5_000)); // short backoff, fewer interrupt windows","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { client.flushWithRetry(); } catch (RuntimeException e) { if (e.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); /* graceful abort: checkpoint will replay */ } else { throw e; } }","preventionTips":["Keep backoff delays short so flushes complete before cancellations.","Ensure writes are idempotent (unique keys) so interrupted flushes can be redone safely.","Treat interrupt-based RuntimeExceptions as expected during job cancel/shutdown."],"tags":["java","dynamodb","interrupt","retry"],"backgroundTag":"request-timeout","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}