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

Auto-Sync on database save doesn't seem to be working? #49

Open
SirSilentBob opened this issue Aug 22, 2021 · 9 comments
Open

Auto-Sync on database save doesn't seem to be working? #49

SirSilentBob opened this issue Aug 22, 2021 · 9 comments

Comments

@SirSilentBob
Copy link

Good afternoon,

@walterpg and everyone else who helps, thanks for your great efforts and hard work on this plugin!

I noticed a recent change where the plugin does not auto-sync on database save. If I want the database to sync right then, I have to manually go to Tools/KPSync For Google Drive/ and click Sync With Drive for it to happen. If I make a change and save/close, the file is auto synced when I open keepass again, so the change does eventually make it to the cloud so my other computer and mobile devices will get it, but if I change something and then forget to force sync and then eg. leave for the weekend, I won't be able to get the latest credentials till I go back to that computer and open keepass and the file then gets synced. It used to be I could click the save button, sync would occur from the work computer, and then on the home computer I could just click the save button again if keepass was already open and then the database would sync and all good.

Attached a screenshot of the related config screens, I think it is configured correctly? Using latest 2.48.1 version of keepass.

image

image

Also shot of the update page, showing what else I am using for plugins. I haven't changed any of these, so not sure if any of them matter or not.

image

Thanks you, and appreciate any suggestions, and let me know if you need me to do anything for diagnostic or testing for more info/debug.

Jay

@walterpg
Copy link
Owner

Hello, thank you for your report.

"Clicking the save button" should always perform a sync because you have enabled Auto-Sync for Save commands. I have not seen other reports of users explicitly running the Save command with this configuration and it failing to engage the plugin's sync (unless you are holding the Shift key! #47). However, implicitly running a Save command via the KP auto lock scenarios is a known issue and only partially supported.

Do you use any of the KP auto lock/exit features, or changed the associated configuration recently? The most recent plugin releases have changed how KP auto lock is handled (#36). Have you enabled the "Resume on return from Auto-Lock or Exit" feature to avoid the plugin's warning about the deferred sync that may occur after returning from auto lock/exit?

KP auto lock/exit has surely saved a few missed Save commands over the years, which is great. But unfortunately it cannot also be relied upon to immediately engage the plugin's sync. There's more discussion about this in #45.

@SirSilentBob
Copy link
Author

Thanks for your reply, sir.

I am not using any type of auto lock or auto saves:

image

image

Anything else that you'd suggest I check or try?

Thanks,

Jay

@walterpg
Copy link
Owner

walterpg commented Aug 28, 2021

So, just to recap, Auto Sync on Save is configured as shown in your screenshot above.

  • You perform a KeePass function that changes the database.
  • You perform an explicit KeePass Save command (FileSave, Ctrl+S keys, or click the "diskette" tool bar icon).
  • You confirm that the database file is successfully saved to the local disk.
  • KPSync does not perform a Sync (that is, no KPSync nor KP "Synchronizing..." messages appear in the KeePass status bar, and when you download, by another process, the database from Drive that should have been sync'ed, the changes that you made are not there).

Let me know if I missed anything.

Also you witnessed this behavior,

  • Perform only the first two steps above.
  • Perform an explicit Sync with Drive command (ToolsKPSync for Google DriveSync with Drive).
  • You confirm that the database file is successfully saved to the local disk.
  • KPSync performs the synchronization (KPSync and KP "Synchronizing..." messages appear in the KeePass status bar, and when you download, by another process, the database from Drive that should have been sync'ed, the changes that you made are there).

If all of that is correct, then there can only be some unknown mechanism, most likely a plugin, that is interfering with KP Save command events. KeePass must inform interested plugins about Save command processing. It's fairly fundamental stuff that "just works", but if there are multiple interested parties, one of them could be fouling the signals KP is sending.

You could try disabling other plugins that work in conjunction with KP Save. If you aren't sure if a plugin uses Save or not, go ahead and disable it anyway. Then try again and see if anything changes.

If nothing changes by disabling the plugins and you want to dig in further, you could try out the logging facility. The current release of KPSync features rudimentary, mostly undocumented diagnostic logging. Three paragraphs or so into the Release Notes topic are instructions for configuring the feature to produce KPSync log files on your PC. When you get that working, make note of the time you run the KeePass Save command as outlined above, and correlate with the times shown in log entries, if any. This might (or not) reveal something interesting.

@SirSilentBob
Copy link
Author

Good evening Walter,

Your recap and witnessed behavior description above is spot on.

I removed plugins one by one and observed the same behavior.
I clicked the button to clear the plugin cache after each plugin removal cycle, and also once I got to the point of ONLY having the KPSyncforDrive plugin present, also cleared the plugin cache and tried again, same result with ONLY the KPSyncforDrive plugin present.

Next, I enabled debugging as described in your release notes, and left two minutes time between actions to make it very clear what was occurring and when. The below is a synopsis:

1144pm : logged in to keepass. KPSyncforDrive did a sync operation once I was logged in.

Did no further action, until:

1146pm: New Test entry created in db and save button clicked. KPSyncforDrive did NOT do a sync operation.

Did no further action, until:

1148pm: Manually went into Tools/KPSync For Google Drive/ and clicked Sync With Drive. KPSyncforDrive did a sync operation.

Went back and examined the log file:

Found this entry, which the timestamp would correlate with when I clicked the Save icon after creating a new DB test entry:

2021-08-31 23:46:07.862 -04:00 [INF] Marking database 'Our Accounts' (D:\KeePass\Our Accounts.kdbx) for deferred Auto Sync (reason 1).

It seems that "deferred Auto Sync (reason 1)" is possibly the cause? Is there some other setting or condition that I need to check, or something to edit/delete from the database to prevent this "deferred Auto Sync (reason 1)"

Thanks!

Jay

@walterpg
Copy link
Owner

walterpg commented Sep 3, 2021

Nice work. Now, open that database in KP, and look at the plugin data (ToolsDatabase ToolsDatabase Maintenance..., then click the Plugin Data tab). There should be at least one KeePassSyncForDrive.* entry similar to this:

dbmaint

If there are other entries, let us know the name/value of each, then delete all but the one shown above (select the row, click Delete). With extraneous entries deleted, Auto Sync should work again (at least once!). If that works, then for now that is your workaround if you lose Auto Sync this way again.

I can replicate the behavior you report this way:

  • Open a KP database with Auto Sync on Save on a removable drive (or network share, etc.).
  • Modify the database, DO NOT run KP Save.
  • Remove/disconnect the removable drive.
  • Run the KP Save command. With the media missing, KP shows a popup; click Cancel on this.
  • Insert/connect the removable drive.
  • Run KP Save again. Observe that the file is saved, Auto Sync is not engaged, and an extraneous plugin data entry is left in the database.

Does this sound like a plausible sequence for your scenario?

At any rate, there should be a fix for the removable drive problem in the next release.

@SirSilentBob
Copy link
Author

Hello Walter,

I do not use keepass databases from a flash drive or removable media, or over a network drive/share. I only open it from on a local hard drive or phone storage on all the devices I use it on. However, I understand there's other conditions that can cause a disk error. The possibility of a disk error is probably safe to assume exponentially INCREASES with the amount of additional computers / mobile devices that are used with the database file on the google drive. The devices that I use for this database are as follows:

3 home computers (2 desktops, 1 laptop)
1 work computer
3 mobile devices (personal android phone, wife's android phone, my work iphone)

7 total diverse devices using the keepass database, so still a lot of real estate for something to happen!

I checked the entries that were under the Plugin Data tab under Database Maintenance as you instructed. Here are the entries below. I had to type them out, because one of them was so long and the window could not be enlarged to be able to get a screenshot of everything:

KeePassOTP.MigrationStatus / Entry2CustomeData, KeepassOTP2OtpAuth, SanitizeSeed, OTPAuthFormatCorrection, CleanOTPDB, ProcessReferences, EntryStrings2CustomData
KeePassOTP.PreloadOTP / false
KeePassOTP.UseDBForOTPSeeds / false
KeePassOTPDB.MigrationStatus / Entry2CustomeData
KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting
KeePassSyncForDrive.Extensions.GetDatabaseUuid / (UUID censored)
PCA.MigrationStatus / Entry2CustomData
PEDCalc.MigrationStatus / Entry2CustomData

I deleted the extra entries, clicked the close button on Database Maintenance and then clicked the save icon. Sync worked successfully as expected, but just a single time!

I checked the Plugin Data tab after that one successful sync, and noticed the entries had returned...

So I figured, they were being put back into the database by the sync process, including the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry, and I decided to try something and see if it was possibly a workaround.

I went into the KPSync For Google Drive settings, Options and Defaults tab, and un-checked "Sync when Saving a KeePass Database". I then returned to the Plugin Data tab under Database Maintenance, and deleted the following entry:

KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting

I then clicked the save icon to save the database locally. I then went to my google drive folder in my browser that has the keepass database file, and then right clicked Manage Versions and then Upload New Version. I then uploaded the locally saved keepass database that I had manually removed the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry from. I then re-opened the keepass database in keepass. The normal "sync before opening a keepass database" operation occurred successfully. I then returned to the Plugin Data tab under Database Maintenance, and noticed that the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry had NOT been put back into the database!

I then went back into the KPSync For Google Drive settings, Options and Defaults tab, and checked "Sync when Saving a KeePass Database". I then clicked the save icon, and sync occurs normally, and I can repeatedly click the save icon and sync occurs as it should!

To test this further, I remotely put this latest keepass database file onto a computer remotely, and then opened keepass. The sync operations all perform properly and normally as expected, also on this additional computer!

It appears that the extra steps I took of manually putting a "current" version of the keepass database without the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry onto the google drive, as well as locally on the computers ensures that entry is NOT put back into the database, and therefore sync operations continue normally when keepass is opened, when the save icon is clicked, etc. and I would recommend this as a temporary work around this issue.

Thank you for your help, and I learned something new today thanks to you, Walter! I learned about the "Plugin Data" tab under Database Maintenance" and therefore I now know to include checking that area if I need to help debug plugin problems.

Have a good weekend, @walterpg!

Jay

@lucaislearning
Copy link

Hey, just want to let you know that i had the same issue. I was able to fix it with SirSilentBobs Workaround. Disabeling Autosync, deleting the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry and uploading this database (with the Plugin) instat of Syncing did solve the problem.

@SirSilentBob
Copy link
Author

Hey, just want to let you know that i had the same issue. I was able to fix it with SirSilentBobs Workaround. Disabeling Autosync, deleting the "KeePassSyncForDrive.Extensions.DeferredAutoSync / Exiting" entry and uploading this database (with the Plugin) instat of Syncing did solve the problem.

@lucaislearning , I am glad my info helped assist you as well. Take care.

@MaroonCoffee
Copy link

SirSilentBobs workaround worked perfectly for me as well. Thanks! I've had this issue for a quite a while now, but now the autosync works just fine.

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

No branches or pull requests

4 participants