-
Notifications
You must be signed in to change notification settings - Fork 1.1k
cmd/gc: scan leaked inodes and edges #5795
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?
Conversation
Signed-off-by: jiefenghuang <[email protected]>
Signed-off-by: jiefenghuang <[email protected]>
| }, 0); err != nil { | ||
| logger.Errorf("delete leaked edges: %s", err) | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that a file becomes dangling when it has node and edge, but parent node not exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary purpose is to provide a scanning tool along with a detail for repair; as for deletion, the entire subtree can be removed through multiple iterations.
| cutoff := time.Now().Add(-before) | ||
|
|
||
| nodes := make(map[Ino]*Attr) | ||
| if err := m.client.scan(nil, func(key, value []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scan may take pretty long, leaving the nodes and edges inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kv scan occur within the same snapshot; however, Redis cannot guarantee this consistency. Therefore, it’s advisable to perform a double-check at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will indeed be time-consuming
will add a configuration that disabled by default.
Signed-off-by: jiefenghuang <[email protected]>
| for inode, attr := range nodes { | ||
| if _, ok := foundInodes[inode]; !ok && time.Unix(attr.Ctime, 0).Before(cutoff) { | ||
| if _, ok := node2Edges[inode]; !ok && time.Unix(attr.Ctime, 0).Before(cutoff) { | ||
| logger.Infof("found leaded inode: %d %+v", inode, attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need double check according to the attr.Parent or parent key as well. See baseMeta.GetPaths
|
|
||
| var edges []edge | ||
| var nodes []node | ||
| if err := m.txn(func(s *xorm.Session) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roTxn
close #5420
ref #1097