{"record":{"id":"f77ca82826035451","repo":"apache/druid","slug":"can-t-reschedule-fetch-records-runnable-recordsre","errorCode":null,"errorMessage":"can't reschedule fetch records runnable, recordsResult is null??","messagePattern":"can't reschedule fetch records runnable, recordsResult is null\\?\\?","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java","lineNumber":352,"sourceCode":"          // may happen if interrupted while BlockingQueue.offer() is waiting\n          log.warn(\n              e,\n              \"Interrupted while waiting to add record to buffer, retrying in [%,dms]\",\n              EXCEPTION_RETRY_DELAY_MS\n          );\n          scheduleBackgroundFetch(EXCEPTION_RETRY_DELAY_MS);\n        }\n        catch (ExpiredIteratorException e) {\n          log.warn(\n              e,\n              \"ShardIterator expired while trying to fetch records, retrying in [%,dms]\",\n              fetchDelayMillis\n          );\n          if (recordsResult != null) {\n            shardIterator = recordsResult.nextShardIterator(); // will be null if the shard has been closed\n            scheduleBackgroundFetch(fetchDelayMillis);\n          } else {\n            throw new ISE(\"can't reschedule fetch records runnable, recordsResult is null??\");\n          }\n        }\n        catch (ResourceNotFoundException | InvalidArgumentException e) {\n          // aws errors\n          log.error(e, \"encounted AWS error while attempting to fetch records, will not retry\");\n          throw e;\n        }\n        catch (SdkException e) {\n          if (AWSClientUtil.isClientExceptionRecoverable(e)) {\n            log.warn(e, \"encounted unknown recoverable AWS exception, retrying in [%,dms]\", EXCEPTION_RETRY_DELAY_MS);\n            scheduleBackgroundFetch(EXCEPTION_RETRY_DELAY_MS);\n          } else {\n            log.warn(e, \"encounted unknown unrecoverable AWS exception, will not retry\");\n            throw new RuntimeException(e);\n          }\n        }\n        catch (Throwable e) {\n          // non transient errors","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java#L334-L370","documentation":"The background fetch runnable in KinesisRecordSupplier reschedules itself after each getRecords call. If recordsResult comes back null the runnable cannot obtain the next shard iterator and cannot reschedule, so it throws this ISE. This indicates an internal invariant break — the Kinesis client returned null where a GetRecordsResult was expected.","triggerScenarios":"fetchRecords, run from scheduleBackgroundFetch, receives a null recordsResult from the underlying getRecords future/call and reaches the else branch that reschedules the next fetch.","commonSituations":"Race between supplier close() and an in-flight fetch; AWS SDK returning unexpected null after a shard merge/closure; bugs in custom AWS SDK or proxy layers intercepting the response.","solutions":["Check for supplier lifecycle races — ensure close() is not called while background fetch is scheduled","Inspect shard state in AWS console (merged/closed shards) around the failure time","Capture the full logs just before this ISE; an earlier swallowed AWS error often explains the null","Report to Druid if reproducible — this path is expected to be unreachable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (supplier.isClosed()) { throw new IllegalStateException(\"supplier closed; not scheduling fetch\"); }","typeGuard":"static boolean isInvariantFailure(Throwable t) {\n  return t instanceof ISE && t.getMessage() != null && t.getMessage().contains(\"recordsResult is null\");\n}","tryCatchPattern":"try {\n  runFetchLoop();\n} catch (ISE e) {\n  if (e.getMessage().contains(\"recordsResult is null\")) {\n    LOG.error(e, \"Kinesis background fetch invariant broken; restarting task is required\");\n  }\n  throw e;\n}","preventionTips":["Avoid closing the supplier while background fetch is still scheduled","Check AWS SDK version compatibility with the Druid kinesis extension","Review shard merge/close events around failure time — keep shards' parent tracking consistent","Treat this as a bug: capture full logs and file an issue if reproducible"],"tags":["kinesis","invariant-violation","background-fetch"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}