Is there an easy way to detect when the migration to v2 has completed, so it would be okay for the wrapper to delete the v1 db dir afterwards?
A user has asked me to delete the index-v14 folder, but I don’t want to blindly rmdir because the wrapper might maybe kill the v1 dir while migration is still going on.
Is there, for example, a file in the v2 dir I could check if it exists to see that migration was fully completed? Or does the config.xml contain some hint after a successful migration I could check for without much code ? Does v2 first migrate the v1 config or v1 db?
Thanks!
Note that index-v0.14.0 (if that was brought back e.g. via a config import) may of course remain present this way and might irritate users by the warning in the webinterface, but I’m not sure there is a good way to get rid of this (apart from checking whether the migrated marker is in the database).
Syncthing itself also seems to do cleanup of old migration artifacts, but not for the v1=>v2 migration yet:
For such users, the following recipe might be helpful (just in case you ever need it or someone arrives here by searching, writing it down):
After DB migration is finished, do an export to a new config file location (config.zip must not exist yet, otherwise old DB will remain in there and new DB will be added to it).
Purge data of Syncthing app (or uninstall / reinstall).
Import from the export above.
This way, the old database is cleanly gone (both the -migrated artifact and also old databases which might have come back via the import).
Thanks, that’s very understandable and appreciated.
One question: Will the future code remove only index-v0.14.0.db-migrated or also index-v0.14.0.db in case that came back e.g. from a backup, restore or something similar (like the config import on Android)?
The -migrated one will be deleted. If you put back an old index-v0.14.0.db you’ll trigger a new migration on next startup, effectively undoing whatever has been stored in the new database since. Don’t do that.
(The presence of both old and new database is effectively a signal that the migration failed partway through and must be redone.)
@Catfriend1 Since that essentially happens if users follow the recipe:
Export from v1 app.
Uninstall v1 app, and install v2 app.
Import config.
Re-export into the same config.zip location (to have a backup in case of catastrophe).
=> config.zipwill at that point contain the original v1 database (without the -migrated suffix) and the new v2 database.
At a future point in time, reinstall and import from said backup.
I believe that is dangerous, as it may trigger another migration at that point, as the original database index is put back in parallel to the v2 database.
One idea to solve this (without touching the config export code) would be to add the following step to the migration guide (at the very end):
Before performing another config backup, make sure to purge the existing config.zip.
Would it be reasonable to add this as protection against such broken backups?
Thanks, I think this protection here in SyncthingNative saved the day:
i.e. the marker in the new DB caused the old DB to be ignored and the warning to be shown.
So in fact, the re-migration was avoided, which is good to see, and since now the old DB is never present of new exports anymore as the ZIP is purged beforehand, we’ll be safe .
Thanks for doing the tests and confirmation, also of the new cleanup code!