-
Notifications
You must be signed in to change notification settings - Fork 992
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
Return remove dir error of table dirStats to trigger retry. #4134
Conversation
Hi @JoJossd, thanks for your contribution! Currently, juicefs tries to clear the value of dir usage when To keep the SQL engine in the same behaviors as Redis and Transaction-KV, I prefer to update that dir usage record when the insert fails by "duplicated unique key" error. Please refer to https://github.com/juicedata/juicefs/blob/main/pkg/meta/sql.go#L2518 |
Thanks for the reply @Hexilee . I understand that we should keep the SQL engine in the same behavior as Redis and Transaction-KV. Just one question before further changes, in the doRmdir function, both Redis and Transaction-KV seem to delete dirStats dirQuota in one transaction, while SQL engine could delete dirQuota without successfully deleting dirStats. This is also the reason why I propose option1 to fix the issue in the first place. Please correct me if I misunderstand the logic here. doRmdir in tkv: Lines 1441 to 1442 in e39c4a6
doRmdir in redis: Lines 1577 to 1582 in e39c4a6
|
I agree with you, that deletion error should cause a transaction failure in the SQL engine. And we should also try to "insert or update" dirStats which may be left by older clients. |
If dirStats deletion is part of a transaction and the transaction aborts, the entire directory should stay intact. This means that new clients should see the entire old directory when they call mkdir. As per the documentation in the Linux man page, mkdir should return an EEXIST error instead of overwriting the old directory. Therefore, perhaps we shouldn't attempt to "insert or update" any existing file while making a new directory. |
If the entire directory still exists, we should fails |
I see your point. However, I'm not very familiar with this part of the codebase. Also, I'm currently occupied with other tasks. So I think it would be better if your team handles these changes when they have the time. This will guarantee that the change is implemented correctly and efficiently. |
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.
LGTM
The current issue is that when there's an error in deleting dirstats, the rmdir operation still proceeds (the transaction is successfully committed). However, the next time a mkdir operation with the same name is attempted, it will check dirstats. If it already exists, an error is reported, making it impossible to make a directory with the same name.
There are two options to fix this issue:
For option2, I think it requires the logic to check if the dirStats table is the only one not removed by the previous transaction, if so, overwrite the old one during mkdir, if not, report EEXIST error. This requires far more changes than option1, so option1 is preferred here.