Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: enable remove dirty importing segments #339

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix review comment
Signed-off-by: Wei Liu <[email protected]>
weiliu1031 committed Jan 15, 2025
commit 741057b76f27a3599aa19714f45817dc4f47ca34
11 changes: 8 additions & 3 deletions states/etcd/remove/dirty_importing_segment.go
Original file line number Diff line number Diff line change
@@ -13,8 +13,9 @@ import (
)

type DirtyImportingSegment struct {
framework.ParamBase `use:"remove dirty-importing-segment" desc:"remove dirty importing segments that collection meta already gone"`
framework.ParamBase `use:"remove dirty-importing-segment" desc:"remove dirty importing segments with 0 rows"`
CollectionID int64 `name:"collection" default:"0" desc:"collection id to filter with"`
Ts int64 `name:"ts" default:"0" desc:"only remove segments with ts less than this value"`
Run bool `name:"run" default:"false" desc:"flag to control actually run or dry"`
}

@@ -35,7 +36,11 @@ func (c *ComponentRemove) DirtyImportingSegmentCommand(ctx context.Context, p *D
for collectionID, segments := range groups {
for _, segment := range segments {
if segment.State == models.SegmentStateImporting {
if segment.NumOfRows == 0 {
segmentTs := segment.GetDmlPosition().GetTimestamp()
if segmentTs == 0 {
segmentTs = segment.GetStartPosition().GetTimestamp()
}
if segment.NumOfRows == 0 && segmentTs < uint64(p.Ts) {
fmt.Printf("collection %d, segment %d is dirty importing with 0 rows, remove it\n", collectionID, segment.ID)
if p.Run {
err := common.RemoveSegmentByID(ctx, c.client, c.basePath, segment.CollectionID, segment.PartitionID, segment.ID)
@@ -44,7 +49,7 @@ func (c *ComponentRemove) DirtyImportingSegmentCommand(ctx context.Context, p *D
}
}
} else {
fmt.Printf("collection %d, segment %d is dirty importing with %d rows, skip it\n", collectionID, segment.ID, segment.NumOfRows)
fmt.Printf("collection %d, segment %d is dirty importing with %d rows, ts=%d, skip it\n", collectionID, segment.ID, segment.NumOfRows, segmentTs)
}
}
}