{"record":{"id":"c92e666a89bf312f","repo":"apache/druid","slug":"announcehistoricalsegments-failed-with-null-metada","errorCode":null,"errorMessage":"announceHistoricalSegments failed with null metadata, should not happen.","messagePattern":"announceHistoricalSegments failed with null metadata, should not happen\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java","lineNumber":440,"sourceCode":"\n  @Override\n  public Set<DataSegment> commitSegments(\n      final Set<DataSegment> segments,\n      @Nullable final SegmentSchemaMapping segmentSchemaMapping\n  )\n  {\n    final SegmentPublishResult result =\n        commitSegmentsAndMetadata(\n            segments,\n            null,\n            null,\n            null,\n            segmentSchemaMapping\n        );\n\n    // Metadata transaction cannot fail because we are not trying to do one.\n    if (!result.isSuccess()) {\n      throw new ISE(\"announceHistoricalSegments failed with null metadata, should not happen.\");\n    }\n\n    return result.getSegments();\n  }\n\n  @Override\n  public SegmentPublishResult commitSegmentsAndMetadata(\n      final Set<DataSegment> segments,\n      @Nullable final String supervisorId,\n      @Nullable final DataSourceMetadata startMetadata,\n      @Nullable final DataSourceMetadata endMetadata,\n      @Nullable final SegmentSchemaMapping segmentSchemaMapping\n  )\n  {\n    verifySegmentsToCommit(segments);\n    IndexerMetadataStorageCoordinator.validateDataSourceMetadata(supervisorId, startMetadata, endMetadata);\n    final String dataSource = segments.iterator().next().getDataSource();\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java#L422-L458","documentation":"IndexerSQLMetadataStorageCoordinator.commitSegments calls announceHistoricalSegments with null metadata, performing no metadata transaction. The code asserts the result must always succeed in this mode; if it doesn't, an internal invariant is broken and ISE is thrown with this message.","triggerScenarios":"commitSegments when the underlying announceHistoricalSegments transaction fails despite metadata being null — e.g. database connectivity failure, SQL error inserting segments, or a race losing a segment-insert conflict during the segment announcement.","commonSituations":"Metadata DB outage or lock contention during segment publish; duplicate segment announcement races between tasks; schema mismatches after Druid upgrades.","solutions":["Check metadata-store connectivity and the coordinator logs for the underlying SQL failure","Retry the segment commit — the operation is designed to be retried on transient DB failures","Resolve duplicate/racing segment announcements; verify no two tasks are publishing overlapping segments"],"exampleFix":"// before\ncoordinator.commitSegments(segments, null, segmentSchemaMapping); // no retry\n// after\nRetryUtils.retry(() -> coordinator.commitSegments(segments, null, segmentSchemaMapping), RetryUtils.IS_RETRYABLE, 3);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return coordinator.commitSegments(segments, null, segmentSchemaMapping); } catch (IllegalStateException e) { if (e.getMessage().contains(\"announceHistoricalSegments failed\")) { // transient metadata-store issue; retry with backoff throw new RetryableException(e); } throw e; }","preventionTips":["Ensure the metadata store is healthy and reachable before publishing","Avoid overlapping segment announcements between concurrent tasks","Monitor coordinator logs for the underlying SQL exception"],"tags":["java","metadata","segments","invariant"],"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"}