Class KillUnreferencedSegmentSchema
java.lang.Object
org.apache.druid.server.coordinator.duty.MetadataCleanupDuty
org.apache.druid.server.coordinator.duty.KillUnreferencedSegmentSchema
- All Implemented Interfaces:
CoordinatorDuty
Coordinator duty to clean up segment schema which are not referenced by any used segment.
- If a schema is not referenced, UPDATE schemas SET used = false, used_status_last_updated = now
- DELETE FROM schemas WHERE used = false AND used_status_last_updated < 6 hours ago
- When creating a new segment, try to find schema for the fingerprint of the segment.
- If no record found, create a new one.
- If record found which has used = true, reuse this schema_id.
- If record found which has used = false, UPDATE SET used = true, used_status_last_updated = now
Possible race conditions:
- Between ops 1 and 3b: In other words, we might end up with a segment that points to a schema that has just been marked as unused. This is repaired by the coordinator duty.
- Between 2 and 3c: This can be handled. Either 2 will fail to update any rows (good case) or 3c will fail to update any rows (bad case). In the bad case, we need to recreate the schema, same as step 3a.
-
Constructor Summary
ConstructorsConstructorDescriptionKillUnreferencedSegmentSchema(MetadataCleanupConfig config, SegmentSchemaManager segmentSchemaManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected intcleanupEntriesCreatedBefore(org.joda.time.DateTime minCreatedTime) Cleans up metadata entries created before theminCreatedTime.Methods inherited from class org.apache.druid.server.coordinator.duty.MetadataCleanupDuty
getCurrentTime, run
-
Constructor Details
-
KillUnreferencedSegmentSchema
public KillUnreferencedSegmentSchema(MetadataCleanupConfig config, SegmentSchemaManager segmentSchemaManager)
-
-
Method Details
-
cleanupEntriesCreatedBefore
protected int cleanupEntriesCreatedBefore(org.joda.time.DateTime minCreatedTime) Description copied from class:MetadataCleanupDutyCleans up metadata entries created before theminCreatedTime.This method is not invoked if the
cleanupPeriodhas not elapsed since theMetadataCleanupDuty.lastCleanupTime.- Specified by:
cleanupEntriesCreatedBeforein classMetadataCleanupDuty- Returns:
- Number of deleted metadata entries
-