keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
21.47k stars 1.48k forks source link

Saving database fails with "Database file has unmerged changes" #9062

Open 4SiB opened 1 year ago

4SiB commented 1 year ago

When I try save data to DBfile then I see that error. Database is on shared fileserver who I manage and this share works for many ppl without problems.

Steps to Reproduce

  1. Put a database into \\fileserver\dir1\dir2\folder with space\filename.kdbx
  2. Set in options {DBFILENAME}{TIME:yyyyMMdd_hh}.kdbx
  3. Works from/with 2 computers with shared DB and each laptop have own local DB.

Expected Behavior

Press SAVE icon and see success.

Actual Behavior

Error: Writing to database failed: Datafile file has unmerged changes. image

Exit app with popup: Discard changes to close and exit.

Context

Two v2.7.4 on 2 laptops access to datafile. Only my PC have that type of problems. Other laptop works proper with database, only differ that it use autosave .

image

KeePassXC - Version 2.7.4 Revision: 63b2394

Qt 5.15.6 Debugging mode is disabled.

Operating system: Windows 10 Version 2009 CPU architecture: x86_64 Kernel: winnt 10.0.19045

Operating System: Windows

TobyC5 commented 1 year ago

Hi, I encounter the same behaviour with Dropbox, no matter if I use the "alternative saving method" or not. Is there a way to force a merge somehow?

droidmonkey commented 1 year ago

Yes you can do Database -> Merge database...

TobyC5 commented 1 year ago

Yes you can do Database -> Merge database...

So, with this I can merge the database with itself? Thanks, I will try it the next time. I thought this is only to be used when merging two different databases.

droidmonkey commented 1 year ago

Yah it compares entries by unique ID and only writes the latest data based on modified time. Everything else will remain untouched.

TobyC5 commented 1 year ago

Yah it compares entries by unique ID and only writes the latest data based on modified time. Everything else will remain untouched.

Unfortunately, the error persists. After doing this it says the merge operation was successful, but upon saving the same error shows up stating that there are unmerged changes. When trying to save once more it suggests to disable safe saves, but it does not help.

droidmonkey commented 1 year ago

You need to disable or restart your cloud file service, it is interfering with KeePassXC to write to the file. You are seeing this because the file on disk is changed from when it was last loaded/saved and KeePassXC cannot re-read the file.

TobyC5 commented 1 year ago

Is this only happening with Dropbox? Would it be better to use another cloud file service like OneDrive or Google Drive?

mochsner commented 1 year ago

Hi, running into a similar issue using Syncthing.

Version Info

KeePassXC - Version 2.7.4
Revision: 63b2394

Qt 5.12.8
Debugging mode is disabled.

Operating system: Ubuntu 20.04.6 LTS
CPU architecture: x86_64
Kernel: linux 5.4.0-146-generic

Enabled extensions:
- Auto-Type
- Browser Integration
- SSH Agent
- KeeShare
- YubiKey
- Secret Service Integration

Cryptographic libraries:
- Botan 2.12.1
cihe13375 commented 1 year ago

Also encountered this error today. Merging database or exiting the sync service doesn't help, and there are no processes locking the database file. I finally circumvented the issue by (1) save the database to somewhere else; (2) restart keepassxc and reload the old file; (3) merge it with the file saved in 1).

mochsner commented 1 year ago

Yeah, ran into same issue again today @cihe13375 -- think I used this resolution last time as well and it worked. I don't think there's been any caveats to it, and if keepass always takes the last modified entry within a database (which I believe it does), this is essentially a resolution..?

hr3x8 commented 4 months ago

I have a similar situation. I don't know whether to log a new issue or not.

I have 2 computers on same network. Computer A - Linux Mint 21.3, KeePassXC 2.7.9 (latest PPA), Nextcloud 3.13.2 (latest flatpak) Computer B - Linux Mint 22, KeePassXC 2.7.9 (latest PPA), Nextcloud 3.13.2 (latest flatpak)

I have a database shared via Nextcloud. KeePassXC not started. I checked that database is identical on both machines via sha256sum.

I then open the database on both computers. I make a change on computer A and save. I verify that sha256sum changed. Then I verify that sha256sum has changed on the second computer. Computer B now has a popup:

image

I did not make any changes on Computer B and both started with the same database and same sha256sum. I just waited to see if change I made on Computer A would load. Both computers have the following options:

image

I've also tried it with all automatically save options enabled, which makes it worse as it causes conflicts in synchronization much quicker on both sides. It appears that even after loading (computer B) there is some kind of change that is recorded internally but does not trigger a save, but it does trigger a merge conflict if database is modified externally.

If I open the same database on both machines and only make a change on one and sync, I should not have a merge conflict.

Continuing, for fun, I accept merge conflict on computer B, save and sync. Sync goes to Computer A and now Computer A, which should have identical data has a merge conflict popup. i.e. with both KeePassXC clients are now in a merge loop where I do "merge, save, sync" back and forth between Computer A and Computer B without any data added or removed.

droidmonkey commented 4 months ago

That notice does not indicate a merge conflict. It indicates your open database has unsaved changes. Those could be non-data changes like the expand/collapse setting on a group. This may also happen if you are using keeshare.

hr3x8 commented 4 months ago

I do have keyshare, but do not do any changes on the database. Simply opening identical databases on two computers and making a change in one and saving will trigger this loop where "unsaved changes" will pop up back and forth between multiple computers regardless whether I choose to close or merge. This behaviour stated with recent updates and now it prevents me from having keepass open on multiple devices. "Automatically save" and "Automatically reload" are now useless options when using Nextcloud because they create loop havoc. As soon as database is loaded there is a "change" just because I have a keyshare?

droidmonkey commented 4 months ago

What version of keepassxc are you running? Some things regarding this were fixed in 2.7.8 and 2.7.9

hr3x8 commented 4 months ago

On both computers 2.7.9, Linux Mint from PPA ppa:phoerious/keepassxc. One computers is Mint 21.3 (ubuntu 22.04) and another 22 (ubuntu 24.04).

image

I don't want to hijack this thread and my issue may be different. It did start with the same orange popup underneath the open database tabs. I have 2 databases, but only one has keeshare.

I did have issues in the past but with Nextcloud I could simply "keep server copy" on conflict and resume with both "auto save" and "auto load external" enabled. I got this issue yesterday and seems to be in a loop, so I started disabling options for "auto save" and "auto load external" and checking manually with checksums. I will try reproduce this with a new database and with scp (manual copy) instead of nextcloud. Fix for now is me saving and turning off KeePassXC on a computer I use instead of leaving it running in background always. This prevents a "change" to exist if I update on another computer.