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

Handle a 'race' condition to process inotify events #948

Merged
merged 2 commits into from Jun 11, 2020

Conversation

abraunegg
Copy link
Owner

  • Handle a 'race' condition to process inotify events generated whilst performing DB or filesystem walk

* Handle a 'race' condition to process inotify events generated whilst performing DB or filesystem walk
@abraunegg
Copy link
Owner Author

abraunegg commented Jun 6, 2020

@norbusan
This issue is 'hard' to reproduce, however the following works:

  • Configure monitor_interval to some very low value I have been using 20, but anything low is fine
  • Upload to OneDrive ~2-3 folders, with ~100 files in each folder. This gives some 'DB' & 'filesystem scanning time'
  • To trigger, only (and only when) The file has not changed ... is appearing, move file / folder from A -> B

Without PR:
FS Operation: mv ../random_files/mh7TkJf64UByKz5UnNAA2AisbGoblJlq/file2.data .

...
Processing random_files
The directory has not changed
Processing mh7TkJf64UByKz5UnNAA2AisbGoblJlq
The directory has not changed
Processing file0.data
The file has not changed
Processing file2.data
The file has been deleted locally
Deleting item from OneDrive: random_files/mh7TkJf64UByKz5UnNAA2AisbGoblJlq/file2.data
Processing file3.data
The file has not changed
Processing file4.data
The file has not changed
Processing file5.data
...
The file has not changed
Processing file99.data
The file has not changed
Uploading new items of .
Uploading new file ./target/file2.data ... done.
Remaining free space on OneDrive: 5312113440
Applying changes of Path ID: 66D53BE8A5056ECA!101
Processing 6 OneDrive items to ensure consistent local state
...

File, though moved, is 'deleted' and 're-uploaded'

With PR:
FS Operation: mv ../random_files/mh7TkJf64UByKz5UnNAA2AisbGoblJlq/file3.data .

...
Processing file0.data
The file has not changed
Processing file3.data
The file appears to have been deleted locally .. but we are running in --monitor mode. This may have been 'moved' rather than 'deleted'
Processing file4.data
The file has not changed
...
[M] Item moved: random_files/mh7TkJf64UByKz5UnNAA2AisbGoblJlq/file3.data -> target/file3.data
Moving random_files/mh7TkJf64UByKz5UnNAA2AisbGoblJlq/file3.data to target/file3.data
Uploading new items of .
Applying changes of Path ID: 66D53BE8A5056ECA!101

File, moved locally, is 'moved' on OneDrive - not deleted & re-uploaded as 'new'

The same situation exists for folders, which is also fixed in this PR, can be tested with the same methodology.

@abraunegg
Copy link
Owner Author

@norbusan
Deleted files / folders are also handled correctly:

Processing target
The directory has not changed
Processing file1.data
The file appears to have been deleted locally .. but we are running in --monitor mode. This may have been 'moved' rather than 'deleted'
Processing file2.data
The file appears to have been deleted locally .. but we are running in --monitor mode. This may have been 'moved' rather than 'deleted'
Processing file3.data
The file appears to have been deleted locally .. but we are running in --monitor mode. This may have been 'moved' rather than 'deleted'
Processing random_files
The directory has not changed
Processing mh7TkJf64UByKz5UnNAA2AisbGoblJlq
The directory has not changed
...
The file has not changed
Processing file99.data
The file has not changed
[M] Item deleted: target/file1.data
Deleting item from OneDrive: target/file1.data
[M] Item deleted: target/file2.data
Deleting item from OneDrive: target/file2.data
[M] Item deleted: target/file3.data
Deleting item from OneDrive: target/file3.data
Uploading new items of .
Applying changes of Path ID: 66D53BE8A5056ECA!101

@abraunegg abraunegg requested a review from norbusan June 6, 2020 00:17
@abraunegg abraunegg linked an issue Jun 6, 2020 that may be closed by this pull request
@abraunegg abraunegg added this to the v2.4.3 milestone Jun 6, 2020
* In --monitor, --dry-run cant be used, no need for this to be tested for or run
@abraunegg
Copy link
Owner Author

@norbusan
Any changes in reviewing this change?

Copy link
Collaborator

@norbusan norbusan left a comment

Choose a reason for hiding this comment

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

Seems to work fine. Thanks

@abraunegg abraunegg merged commit e321c37 into master Jun 11, 2020
@abraunegg abraunegg deleted the fix-monitor-race-condition branch June 20, 2020 22:32
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uploading when moving file within onedrive in monitor
2 participants