{"record":{"id":"0655f5599b02e8b6","repo":"apache/druid","slug":"failed-to-update-segments-with-schema-information","errorCode":null,"errorMessage":"Failed to update segments with schema information: %s","messagePattern":"Failed to update segments with schema information: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/segment/metadata/SegmentSchemaManager.java","lineNumber":332,"sourceCode":"                          .bind(\"num_rows\", segmentSchema.getSegmentSchemaMetadata().getNumRows())\n                          .bind(\"last_updated\", updateTime.toString());\n      }\n\n      final int[] affectedRows = segmentUpdateBatch.execute();\n      final List<SegmentId> failedUpdates = new ArrayList<>();\n      for (int i = 0; i < partition.size(); ++i) {\n        if (affectedRows[i] != 1) {\n          failedUpdates.add(partition.get(i).getSegmentId());\n        }\n      }\n\n      if (failedUpdates.isEmpty()) {\n        log.infoSegmentIds(\n            partition.stream().map(SegmentSchemaMetadataPlus::getSegmentId),\n            \"Updated segments with schema information in the DB\"\n        );\n      } else {\n        throw new ISE(\n            \"Failed to update segments with schema information: %s\",\n            failedUpdates\n        );\n      }\n    }\n  }\n\n  /**\n   * Query the metadata DB to filter the fingerprints that already exist.\n   * @return Map from fingerprint to its \"used\" status\n   */\n  private Map<String, Boolean> getExistingFingerprints(\n      final Handle handle,\n      final Set<String> fingerprintsToInsert\n  )\n  {\n    if (fingerprintsToInsert.isEmpty()) {\n      return Collections.emptyMap();","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/segment/metadata/SegmentSchemaManager.java#L314-L350","documentation":"After publishing schemas, SegmentSchemaManager.updateSegmentWithSchemaInformation updates the segments table rows with schema fingerprints; rows that fail to update are collected in failedUpdates. If any update fails, this ISE is thrown so callers do not proceed with segments whose schema linkage is incomplete.","triggerScenarios":"Calling persistSchemaAndUpdateSegmentsTable when the UPDATE of one or more segment rows in the metadata store fails — DB outage, deadlock/lock timeout, row no longer existing, or connection failure mid-batch.","commonSituations":"Metadata DB under heavy load during bulk publish; transaction deadlocks with concurrent task updates; segment rows deleted by retention/cleanup racing this update; transient network failures.","solutions":["Inspect the metadata-store exception logged before this ISE to find the root SQL failure","Retry the operation after transient DB issues — row updates are idempotent per segment","Verify the segment rows still exist in the segments table (they may have been cleaned concurrently)","Check for lock/deadlock contention and DB timeout settings during bulk publish windows"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm segment rows exist before updating\nsegments.forEach(s -> verifyRowExists(segmentsTable, s.getId()));","typeGuard":null,"tryCatchPattern":"try {\n  manager.persistSchemaAndUpdateSegmentsTable(segments);\n} catch (ISE e) {\n  retryWithBackoff(() -> manager.persistSchemaAndUpdateSegmentsTable(segments));\n}","preventionTips":["Reduce bulk-update contention by staggering large publishes","Ensure DB deadlock/lock timeout settings accommodate batch updates","Avoid concurrent retention cleanup during schema publish windows"],"tags":["database","metadata-store","ingestion"],"backgroundTag":"database-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}