{"record":{"id":"0ff1560ea2be13d8","repo":"apache/druid","slug":"actual-row-count-mismatch-expected-d-found-d","errorCode":null,"errorMessage":"Actual Row count mismatch. Expected [%d] found [%d]","messagePattern":"Actual Row count mismatch\\. Expected \\[(.+?)\\] found \\[(.+?)\\]","errorType":"validation","errorClass":"SegmentValidationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/IndexIO.java","lineNumber":249,"sourceCode":"    if (fileSize > Integer.MAX_VALUE) {\n      throw new IOE(\"File[%s] too large[%d]\", indexFile, fileSize);\n    }\n  }\n\n  interface IndexIOHandler\n  {\n    MMappedIndex mapDir(File inDir) throws IOException;\n  }\n\n  private static void validateRowValues(\n      RowPointer rp1,\n      IndexableAdapter adapter1,\n      RowPointer rp2,\n      IndexableAdapter adapter2\n  )\n  {\n    if (rp1.getTimestamp() != rp2.getTimestamp()) {\n      throw new SegmentValidationException(\n          \"Timestamp mismatch. Expected %d found %d\",\n          rp1.getTimestamp(),\n          rp2.getTimestamp()\n      );\n    }\n    final List<Object> dims1 = rp1.getDimensionValuesForDebug();\n    final List<Object> dims2 = rp2.getDimensionValuesForDebug();\n    if (dims1.size() != dims2.size()) {\n      throw new SegmentValidationException(\"Dim lengths not equal %s vs %s\", dims1, dims2);\n    }\n    final List<String> dim1Names = adapter1.getDimensionNames(false);\n    final List<String> dim2Names = adapter2.getDimensionNames(false);\n    int dimCount = dims1.size();\n    for (int i = 0; i < dimCount; ++i) {\n      final String dim1Name = dim1Names.get(i);\n      final String dim2Name = dim2Names.get(i);\n\n      ColumnCapabilities capabilities1 = adapter1.getCapabilities(dim1Name);","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/IndexIO.java#L231-L267","documentation":"IndexIO.validateRowValues compares rows at the same pointer position when validating two segments against each other. If the row counts differ (or the pointer walks past one segment before the other), it reports an actual/expected row-count mismatch. This indicates the two segments do not contain identical row data and cannot be considered equivalent.","triggerScenarios":"Calling IndexIO.validateTwoSegments (or the validation utility wrapping it) on two segment files where the number of rows in one differs from the other, producing mismatched RowPointer iterations.","commonSituations":"Post-merge or post-conversion verification of segments that were re-ingested with different filters or time zones; comparing a migrated segment against its source; validation tooling run against partially-written segments.","solutions":["Re-generate both segments from the same source data with identical ingestion specs","Check for missing rows in one segment (dropped data, differing time zones, filters) and re-persist it","Verify both segments use the same interval and rollup settings before validating"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try (IndexableAdapter a1 = IndexIO.loadAdapter(seg1); IndexableAdapter a2 = IndexIO.loadAdapter(seg2)) {\n  if (a1.getNumRows() != a2.getNumRows()) {\n    throw new IllegalStateException(\"Row counts differ: \" + a1.getNumRows() + \" vs \" + a2.getNumRows());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  IndexIO.validateTwoSegments(adapter1, adapter2);\n} catch (SegmentValidationException e) {\n  log.error(\"Segments not equivalent: %s\", e.getMessage());\n  // treat as invalid comparison, re-generate source segment\n}","preventionTips":["Only validate segments generated from identical inputs and specs","Verify row counts match before deep row-by-row validation"],"tags":["druid","segment","validation","data-mismatch"],"backgroundTag":"schema-validation-failed","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"}