-
Notifications
You must be signed in to change notification settings - Fork 45
enhance: Add repair zero-partition-l0 command
#462
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package repair | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/milvus-io/birdwatcher/framework" | ||
| "github.com/milvus-io/birdwatcher/models" | ||
| "github.com/milvus-io/birdwatcher/states/etcd/common" | ||
| "github.com/milvus-io/milvus/pkg/v2/proto/datapb" | ||
| ) | ||
|
|
||
| type ZeroParitiionL0Param struct { | ||
| framework.ParamBase `use:"repair zero-partition-l0" desc:"Set partitionID to non-zero value for L0 segments with partitionID 0"` | ||
|
|
||
| Collection int64 `name:"collection" default:"0" desc:"collection id to filter with"` | ||
| Segment int64 `name:"segment" default:"0" desc:"segment id to filter with"` | ||
| TargetPartitionID int64 `name:"targetPartitionID" default:"-1" desc:"the partition id to set for the segment"` | ||
| Run bool `name:"run" default:"false" desc:"actual do repair"` | ||
| } | ||
|
|
||
| func (c *ComponentRepair) ZeroPartitionL0SegmentCommand(ctx context.Context, p *ZeroParitiionL0Param) error { | ||
congqixia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| segments, err := common.ListSegments(ctx, c.client, c.basePath, func(info *models.Segment) bool { | ||
| return info.GetLevel() == datapb.SegmentLevel_L0 && | ||
| (p.Collection == 0 || info.GetCollectionID() == p.Collection) && | ||
| (p.Segment == 0 || info.GetID() == p.Segment) && | ||
| info.GetPartitionID() == 0 | ||
| }) | ||
| if err != nil { | ||
| fmt.Println("failed to list segments", err.Error()) | ||
| return nil | ||
| } | ||
congqixia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| fmt.Printf("%d segment found\n", len(segments)) | ||
| for _, info := range segments { | ||
| fmt.Printf("suspect segment %d found:\n", info.GetID()) | ||
| fmt.Printf("SegmentID: %d CollectionID: %d PartitionID: %d, State: %s, Row Count:%d\n", | ||
| info.ID, info.CollectionID, info.PartitionID, info.State.String(), info.NumOfRows) | ||
| } | ||
|
|
||
| if !p.Run { | ||
| return nil | ||
| } | ||
congqixia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| for _, info := range segments { | ||
| info.PartitionID = p.TargetPartitionID | ||
| err := common.UpdateSegment(ctx, c.client, info) | ||
| if err != nil { | ||
| fmt.Printf("update segment %d partitionID failed: %s\n", info.GetID(), err.Error()) | ||
| continue | ||
| } | ||
| fmt.Printf("update segment %d partitionID to %d succeed\n", info.GetID(), p.TargetPartitionID) | ||
| } | ||
|
Comment on lines
+45
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current repair logic is critically flawed and will likely lead to metadata corruption. The etcd key for a segment and its associated metadata (binlogs, deltalogs, statslogs) is dependent on the A correct implementation must perform a "move" operation in etcd:
Without this, the system's metadata will be in a corrupt state. |
||
|
|
||
| return nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.