[Bug]: DataCoord GC bypasses checkpoint protection when channel metadata lookup fails
Environment
- Milvus Version: Source reviewed at v3.0.1 (
658cbd16899bb715a17d4d6f727531a376678ca6). The same condition is present in v2.5.11 and v2.6.25; its first stable release was v2.2.3. - Deployment Mode: DataCoord GC; investigated in the context of an OSS, self-managed Kubernetes cluster.
- MQ: The related incident uses Pulsar 3.0.7. The faulty GC condition itself does not depend on the MQ backend.
- Metadata storage: etcd; the related incident reports etcd 3.5.18.
- SDK / OS: Not relevant to the code-level condition / not established for a reproduction environment.
Evidence status: This is a source-level finding. No fault-injection test or end-to-end reproduction has been run. It was identified while investigating #53900, but it has NOT been established as the root cause of #53900.
Reproduction
Option B: Steps — proposed fault-injection validation, not yet executed
- Set up an existing channel with a dropped segment
S. Ensure all other GC prerequisites are satisfied: drop tolerance elapsed, compaction target indexed where applicable, no loaded-segment protection, and no snapshot protection. - Set the channel checkpoint to
100and the segment's effective DML checkpoint to120. These are illustrative logical timestamps. With the channel present, this segment must remain protected from GC. - Make the catalog KV
Loadfor this channel's marker return a transient error, such as a timeout, duringChannelExists. Keep the marker logically present; do not delete the channel. - Allow subsequent object-storage and metadata deletion operations to succeed. Run the dropped-segment GC pass.
- Check whether
checkDroppedSegmentGCpermits recycling and whether segment metadata is removed. Compare against a successful marker read with the same checkpoints, which must block GC.
Trigger Conditions
- The marker read fails while the channel still exists.
- The segment DML checkpoint is ahead of the channel checkpoint.
- Other GC protections permit deletion, and subsequent deletion operations succeed. A persistent etcd outage that also prevents deletion does not by itself complete this failure sequence.
- Frequency and production occurrence are unknown.
Expected Behavior
A failure to read channel state must not be treated as confirmation that the channel no longer exists. GC should retain the segment, report the lookup error, and retry later. A channel confirmed to be deleted should retain its intended cleanup behavior.
Actual Behavior
The catalog API collapses a read failure into false:
func (kc *Catalog) ChannelExists(ctx context.Context, channel string) bool {
key := buildChannelRemovePath(channel)
v, err := kc.MetaKv.Load(ctx, key)
return err == nil && v == NonRemoveFlagTomestone
}Source: kv_catalog.go, v3.0.1.
The GC predicate enforces checkpoint protection only if that API returns true:
if gc.meta.catalog.ChannelExists(context.Background(), segInsertChannel) &&
segmentEffectiveDmlTs(segment.SegmentInfo) > cpTimestamp {
return false
}
return trueSource: checkDroppedSegmentGC.
Consequently, a lookup error bypasses this checkpoint guard. The caller then invokes recycleDroppedSegment, which can remove files and eventually drop segment metadata if its remaining checks and operations succeed.
This control-flow behavior is established by source inspection; actual deletion under injected faults remains to be tested.
Error Logs
No runtime log demonstrating this GC failure has been obtained.
The related issue #53900 reports:
missing storage version for streaming growing segment, segmentID=469122827278329750: service internal errorThat error is context only, not evidence that this GC path ran. Its public attachment does not establish a channel-marker lookup error or a GC deletion of the target segment.
Non-default Configuration
No particular non-default configuration has been established as necessary. Validation requires controlled fault injection and the checkpoint/segment state described above.
Analysis Hints (Optional)
Version history
- #22027 (
a28b3c28d29970237bb24c4b38498facd3890cc0) introduced bothChannelExistsand its use as a prerequisite for GC checkpoint protection on the2.2.0branch on February 8, 2023. - The first stable release containing that change is v2.2.3 (February 10, 2023). v2.2.2 does not contain
ChannelExists. - #22559 (
aa6212d5b0e4be3124a4edc9cf205a1771983cf8) subsequently cherry-picked it to master on March 9, 2023, entering the v2.3 release line. - This is a longstanding condition, not a newly introduced v3.0 GC regression. In particular, it already exists in the v2.5.11 version used before the upgrade in #53900.
Possible recovery impact and relationship to #53900
Premature deletion of a dropped segment's metadata can remove the information required to filter that segment's historical inserts during recovery. For example, if CreateSegment < channel checkpoint < Insert, recovery can skip the create message while still replaying the insert. If the dropped-segment metadata has also been deleted, the insert may reach writebuffer without a cache entry or a dropped-ID filter.
This is a conditional failure sequence requiring validation. We have not shown that segment 469122827278329750 was dropped, garbage-collected, or affected by a failed marker read. This issue must not be interpreted as a confirmed diagnosis or resolution of #53900.
Suggested fix and validation scope
Distinguish lookup errors from a confirmed absent/deleted channel, and skip segment GC when the lookup fails. Do not mask a recovery inconsistency by assigning a default storage version.
Add fault-injection coverage for a transient lookup failure followed by successful subsequent operations; verify that no segment files or metadata are deleted. Also cover a successful lookup with checkpoint lag, a confirmed deleted channel, and recovery filtering after the skipped GC pass.
Source: milvus-io/milvus