2023-01-06 16:27:42 +00:00
|
|
|
//--- repairqueue ---//
|
|
|
|
|
2023-02-08 12:23:08 +00:00
|
|
|
// repair_queue contains items that should be repaired.
|
2023-01-06 16:27:42 +00:00
|
|
|
model repair_queue (
|
|
|
|
table repair_queue
|
|
|
|
|
|
|
|
key stream_id position
|
|
|
|
|
2023-02-08 12:23:08 +00:00
|
|
|
// stream_id is uuid that refers to segments.stream_id column.
|
2023-01-06 16:27:42 +00:00
|
|
|
field stream_id blob
|
2023-02-08 12:23:08 +00:00
|
|
|
// position is a segment location that refers to segments.position column.
|
2023-01-06 16:27:42 +00:00
|
|
|
field position uint64
|
2023-02-08 12:23:08 +00:00
|
|
|
// attempted_at indicates the last time repair was tried.
|
2023-01-06 16:27:42 +00:00
|
|
|
field attempted_at timestamp (updatable, nullable)
|
2023-02-08 12:23:08 +00:00
|
|
|
// updated_at indicates when this row was last added (or re-added) to the queue.
|
2023-01-06 16:27:42 +00:00
|
|
|
field updated_at timestamp ( updatable, default current_timestamp )
|
2023-02-08 12:23:08 +00:00
|
|
|
// inserted_at indicate when this segment ended up in the repair queue the first time.
|
2023-01-06 16:27:42 +00:00
|
|
|
field inserted_at timestamp ( default current_timestamp )
|
2023-02-08 12:23:08 +00:00
|
|
|
// segment_health corresponds to the importance of this segment getting repaired.
|
|
|
|
// Lower health segments should be repaired first. See repair.SegmentHealth for more details.
|
2023-01-06 16:27:42 +00:00
|
|
|
field segment_health float64 (default 1)
|
|
|
|
|
2023-02-08 12:23:08 +00:00
|
|
|
// this index is used for efficient deletes of old entries.
|
2023-01-06 16:27:42 +00:00
|
|
|
index (
|
|
|
|
fields updated_at
|
|
|
|
)
|
|
|
|
|
2023-02-08 12:23:08 +00:00
|
|
|
// this index is used to efficiently find the segments that are most in
|
|
|
|
// danger becoming irreparable.
|
2023-01-06 16:27:42 +00:00
|
|
|
index (
|
|
|
|
name repair_queue_num_healthy_pieces_attempted_at_index
|
|
|
|
fields segment_health attempted_at
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
delete repair_queue ( where repair_queue.updated_at < ? )
|