{"record":{"id":"3c944d96929a5312","repo":"apache/druid","slug":"failed-to-add-a-row-with-timestamp-s-3c944d","errorCode":null,"errorMessage":"Failed to add a row with timestamp[%s]","messagePattern":"Failed to add a row with timestamp\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/SinglePhaseSubTask.java","lineNumber":444,"sourceCode":"\n        if (addResult.isOk()) {\n          final boolean isPushRequired = addResult.isPushRequired(\n              partitionsSpec.getMaxRowsPerSegment(),\n              partitionsSpec.getMaxTotalRowsOr(DynamicPartitionsSpec.DEFAULT_MAX_TOTAL_ROWS)\n          );\n          if (isPushRequired) {\n            // There can be some segments waiting for being published even though any rows won't be added to them.\n            // If those segments are not published here, the available space in appenderator will be kept to be small\n            // which makes the size of segments smaller.\n            final SegmentsAndCommitMetadata pushed = driver.pushAllAndClear(pushTimeout);\n            pushedSegments.addAll(pushed.getSegments());\n            segmentSchemaMapping.merge(pushed.getSegmentSchemaMapping());\n            LOG.info(\"Pushed [%s] segments and [%s] schemas\", pushed.getSegments().size(), segmentSchemaMapping.getSchemaCount());\n            LOG.infoSegments(pushed.getSegments(), \"Pushed segments\");\n            LOG.info(\"SegmentSchema is [%s]\", segmentSchemaMapping);\n          }\n        } else {\n          throw new ISE(\"Failed to add a row with timestamp[%s]\", inputRow.getTimestamp());\n        }\n      }\n\n      final SegmentsAndCommitMetadata pushed = driver.pushAllAndClear(pushTimeout);\n      pushedSegments.addAll(pushed.getSegments());\n      segmentSchemaMapping.merge(pushed.getSegmentSchemaMapping());\n      LOG.info(\"Pushed [%s] segments and [%s] schemas\", pushed.getSegments().size(), segmentSchemaMapping.getSchemaCount());\n      LOG.infoSegments(pushed.getSegments(), \"Pushed segments\");\n      LOG.info(\"SegmentSchema is [%s]\", segmentSchemaMapping);\n      appenderator.close();\n\n      return new DataSegmentsWithSchemas(pushedSegments, segmentSchemaMapping.isNonEmpty() ? segmentSchemaMapping : null);\n    }\n    catch (TimeoutException | ExecutionException e) {\n      exceptionOccurred = true;\n      throw new RuntimeException(e);\n    }\n    catch (Exception e) {","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/SinglePhaseSubTask.java#L426-L462","documentation":"Thrown by SinglePhaseSubTask.generateAndPushSegments when the IndexIngestionDriver fails to add an input row to the current segment — i.e., the row could not be added to the incremental index while building segments. This indicates a row-level ingestion failure such as the row not fitting into the current segment's schema/partitioning, rather than bad input alone, and Druid surfaces the failing row's timestamp for diagnosis.","triggerScenarios":"driver.add(inputRow) returns false (row not added) — e.g., the row's dimensions/timestamp fall outside the shard spec's expected range for the current segment, or the incremental index rejects the row because of schema mismatch with the assigned partition.","commonSituations":"Range partitioning where a row's partition-dimension value doesn't match the subtask's assigned range; clock issues putting rows outside the task's interval; dimension schema changes mid-run; rows filtered by partitions but not pre-filtered by the input source reader.","solutions":["Check the reported timestamp and the subtask's assigned intervals/partitions; fix the input filter or partitionsSpec so rows match the subtask's ranges","Re-run determinePartitions to regenerate partition boundaries if input data shifted between the determine and ingest phases","Verify that clocks and time filtering in the input source do not emit rows outside the task granularity interval","If caused by a driver/index bug, capture the failing row and report with full task logs; consider upgrading Druid"],"exampleFix":"// before: rows outside assigned range reach the driver\nInputRow row = rowIterator.next();\n// after: pre-filter to the subtask's interval/partition range\nif (interval.contains(row.getTimestamp()) && range.contains(row.getDimension(partitionDim).get(0))) {\n  driver.add(row);\n}","handlingStrategy":"validation","validationCode":"// pre-filter rows to the subtask's assigned interval and partition range before driver.add\nif (!interval.contains(inputRow.getTimestamp())) { continue; }\nObject pdv = inputRow.getRaw(partitionDimension);\nif (!assignedRange.contains(pdv)) { continue; }","typeGuard":"boolean isRowInScope(InputRow row, Interval interval, Range<Object> range, String dim) {\n  return interval.contains(row.getTimestamp())\n      && row.getDimension(dim) != null\n      && row.getDimension(dim).size() == 1\n      && range.contains(row.getDimension(dim).get(0));\n}","tryCatchPattern":"catch (ISE e) {\n  if (e.getMessage().startsWith(\"Failed to add a row with timestamp\")) {\n    log.error(\"row out of segment scope at %s; check partitionsSpec/interval filters\", e.getMessage());\n    throw new TaskRetryableException(e); // or fail fast with diagnostics\n  } throw e;\n}","preventionTips":["Run the input-source sampler to verify rows match the configured intervals","Keep partitionsSpec boundaries and input data in sync: re-run determinePartitions if data changed","NTP-sync cluster clocks so timestamps stay inside task intervals","Flatten multi-valued partition dimensions before ingestion"],"tags":["ingestion","batch-ingestion","input-rows"],"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-14T05:17:10.506Z"}