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

Foreign key constraint failed when using --dry-run #851

Closed
2 tasks done
AymenQ opened this issue Mar 31, 2020 · 8 comments · Fixed by #856
Closed
2 tasks done

Foreign key constraint failed when using --dry-run #851

AymenQ opened this issue Mar 31, 2020 · 8 comments · Fixed by #856
Labels
Bug Something isn't working Fixed

Comments

@AymenQ
Copy link

AymenQ commented Mar 31, 2020

Bug Report Details

When running the below command, I receive a FOREIGN KEY constraint failed error, no matter whether or not I run the command with --resync. I am currently only using --dry-run to make sure I'm not overwriting local changes with the remote.

Application and Operating System Details:

  • Fedora 31 (5.4.12-200.fc31.x86_64)
  • GUI system
  • OneDrive type: business
  • Application version: v2.4.0-5-g50fb2d8
  • Curl version: 7.66.0

Complete Verbose Log Output
A clear and full log of the problem when running the application in the following manner (ie, not in monitor mode):

onedrive --dry-run --synchronize --single-directory 'redacted1/redacted2/redacted3' --resync  --upload-only --verbose

Application Log Output:

Using Config Dir: /home/redacted/.config/onedrive
DRY-RUN Configured. Output below shows what 'would' have occurred.
Deleting the saved status ...
Initializing the OneDrive API ...
Opening the item database ...
All operations will be performed in: /home/redacted/onedrive
Application version: v2.4.0-5-g50fb2d8
Account Type: business
Default Drive ID: redacted
Default Root ID: redacted
Remaining Free Space: 5357571643960
Fetching details for OneDrive Root
OneDrive Root does not exist in the database. We need to add it.
Added OneDrive Root to the local database
Initializing the Synchronization Engine ...
Syncing changes from this selected path: redacted1/redacted2/redacted3
Syncing changes from selected local path only - NOT syncing data changes from OneDrive ...
Uploading differences of year3/semester1/redacted1
Uploading new items of year3/semester1/redacted2
OneDrive Client requested to create remote path: redacted1/redacted2/redacted3
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1/redacted2/redacted3
The parent for this path is not in the local database - need to add parent to local database
OneDrive Client requested to create remote path: redacted1/redacted2
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1/redacted2
The parent for this path is not in the local database - need to add parent to local database
OneDrive Client requested to create remote path: redacted1
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1
The parent for this path is in the local database - adding requested path (redacted1) to database
OneDrive Client requested to create remote path: redacted1/redacted2/redacted3/redacted4
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1/redacted2/redacted3/redacted4
The parent for this path is not in the local database - need to add parent to local database
OneDrive Client requested to create remote path: redacted1/redacted2/redacted3
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1/redacted2/redacted3
The parent for this path is not in the local database - need to add parent to local database
OneDrive Client requested to create remote path: redacted1/redacted2
The requested directory to create was found on OneDrive - skipping creating the directory: redacted1/redacted2
The parent for this path is in the local database - adding requested path (redacted1/redacted2) to database
Requested file to upload exists on OneDrive - local database is out of sync for this file: redacted1/redatced2/redacted3/redacted4/redacted5.txt
Updating the local database with details for this file: redacted1/redatced2/redacted3/redacted4/redacted5.txt

A database statement execution error occurred: FOREIGN KEY constraint failed

Please retry your command with --resync to fix any local database corruption issues

Bug Report Checklist

  • Detailed description
  • Verbose Log Output
@abraunegg
Copy link
Owner

@AymenQ
Can you please provide a verbose debug log via email. Will need to see unredacted output to correlate what is going on here.

Also, as this is occurring when using --dry-run it could be related to that - and not be an actual issue. Will attempt to try and replicate this as well.

@abraunegg abraunegg changed the title Foreign key constraint failed Foreign key constraint failed when using --dry-run Mar 31, 2020
@abraunegg abraunegg added Bug Something isn't working In Progress Currently being worked on and removed More Information Needed Waiting on Response labels Mar 31, 2020
@abraunegg
Copy link
Owner

@AymenQ
Able to replicate this of sorts, but not with --dry-run - but without & causing a crash:

Using Config Dir: /home/alex/.config/onedrive-business/
Deleting the saved status ...
Initializing the OneDrive API ...
Opening the item database ...
All operations will be performed in: /home/alex/OneDriveBusiness
Application version: v2.4.0-6-gbed6e6b
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1099509676479
Fetching details for OneDrive Root
OneDrive Root does not exist in the database. We need to add it.
Added OneDrive Root to the local database
Initializing the Synchronization Engine ...
Syncing changes from this selected path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Syncing changes from selected local path only - NOT syncing data changes from OneDrive ...
Uploading differences of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Uploading new items of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
OneDrive Client requested to create remote path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
The requested directory to create was not found on OneDrive - creating remote directory: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Retry sync count: 1: The parent item id is not in the database
Syncing changes from this selected path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Syncing changes from selected local path only - NOT syncing data changes from OneDrive ...
Uploading differences of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Uploading new items of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
OneDrive Client requested to create remote path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
The requested directory to create was not found on OneDrive - creating remote directory: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Retry sync count: 2: The parent item id is not in the database
Syncing changes from this selected path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Syncing changes from selected local path only - NOT syncing data changes from OneDrive ...
Uploading differences of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Uploading new items of random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
OneDrive Client requested to create remote path: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
The requested directory to create was not found on OneDrive - creating remote directory: random_files/JkksyJzJR3NWuaXdeJLiJI0RRLL1lpqH
Giving up on sync after three attempts: The parent item id is not in the database
object.Exception@src/sync.d(2682): The parent item id is not in the database
----------------
/home/alex/dlang/dmd-2.085.0/linux/bin64/../../src/phobos/std/exception.d:515 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x576dea]
??:? pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x66b385]
src/sync.d:2682 void sync.SyncEngine.uploadCreateDir(const(immutable(char)[])) [0x635d16]
src/sync.d:2542 void sync.SyncEngine.uploadNewItems(immutable(char)[]) [0x6353fd]
src/sync.d:1939 void sync.SyncEngine.scanForDifferences(immutable(char)[]) [0x6331ed]
src/main.d:911 void main.performSync(sync.SyncEngine, immutable(char)[], bool, bool, bool, long, bool, bool) [0x61a7b2]
src/main.d:671 _Dmain [0x619a12]

working on the fix at present, which should also fix the issue when using --dry-run

@abraunegg
Copy link
Owner

@AymenQ
Also able to replicate this with --dry-run as well - to trigger the files or path need to also exist already on OneDrive in a --resync scenario.

@abraunegg
Copy link
Owner

@AymenQ
Please can you test the following PR for solving your issue:

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
git fetch origin pull/856/head:pr856
git checkout pr856
./configure; make clean; make;

example output with using PR:

./onedrive --confdir '~/.config/onedrive-business/' --synchronize --single-directory 'random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o' --resync  --upload-only --verbose --dry-run
Using Config Dir: /home/alex/.config/onedrive-business/
DRY-RUN Configured. Output below shows what 'would' have occurred.
Deleting the saved status ...
Initializing the OneDrive API ...
Opening the item database ...
All operations will be performed in: /home/alex/OneDriveBusiness
Application version: v2.4.0-6-gbed6e6b
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1099456529129
Fetching details for OneDrive Root
OneDrive Root does not exist in the database. We need to add it.
Added OneDrive Root to the local database
Initializing the Synchronization Engine ...
Syncing changes from this selected path: random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o
Syncing changes from selected local path only - NOT syncing data changes from OneDrive ...
Uploading differences of random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o
Uploading new items of random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o
OneDrive Client requested to create remote path: random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o
The requested directory to create was not found on OneDrive - creating remote directory: random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o
Successfully created the remote directory random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o on OneDrive
Uploading new file random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o/file0.data ... done.
Remaining free space on OneDrive: 1099454885609
Uploading new file random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o/file1.data ... done.
Remaining free space on OneDrive: 1099453871593
Uploading new file random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o/file2.data ... done.
Remaining free space on OneDrive: 1099452854953
Uploading new file random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o/file3.data ... done.
Remaining free space on OneDrive: 1099451661929
Uploading new file random_files/5ZMZTdmBQMYUkhW7MXgxV0jj0JlBoT9o/file4.data ... done.
Remaining free space on OneDrive: 1099451380905

@abraunegg abraunegg added PR Provided - Needs Testing and removed In Progress Currently being worked on labels Apr 1, 2020
@AymenQ
Copy link
Author

AymenQ commented Apr 1, 2020

@abraunegg
Thank you very much for working on this, apologies for not getting back to you earlier. I've tested the PR and I can confirm it now works as expected; the bug seems to be fixed. Thanks for the quick turnaround!

@abraunegg
Copy link
Owner

Merged #856 to Master

@abraunegg
Copy link
Owner

@AymenQ
Thanks for the confirmation of the fix

@lock
Copy link

lock bot commented May 5, 2020

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

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants