Skip to content

Conversation

@jiefenghuang
Copy link
Contributor

close #5420
ref #1097

Signed-off-by: jiefenghuang <[email protected]>
@davies davies requested a review from SandyXSD March 19, 2025 14:11
}, 0); err != nil {
logger.Errorf("delete leaked edges: %s", err)
return
}
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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]>
@jiefenghuang jiefenghuang requested a review from SandyXSD March 21, 2025 07:07
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)
Copy link
Contributor

@SandyXSD SandyXSD Mar 21, 2025

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roTxn

@jiefenghuang jiefenghuang marked this pull request as draft March 21, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need a tool to find possible dangling nodes

3 participants