I tried to re-open a QGIS map document that referenced several layers stored in geopackages. These layers failed to load, with the "Handle unavailable layers" dialog. I think they were open in -wal mode when QGIS crashed. QGIS won't open these geopackages at this point, I tried opening them in R using the sf package, but this fails with the message that the geopackage is wal mounted.
I tried copying the geopackage and reopening, based on information that suggested that I'd potentially lose uncommitted changes, but after copying the file it still failed to load. The .wal file appears empty (0kb and looked empty if I opened in a text editor). I can see both the .wal and .shm files in my file explorer.
Edit- I copied the entire directory with my project onto another drive, but without the .wal and .shm files. When I did so, I was able to open the QGZ file and load the problematic layers. I then tried to delete the recent files from the working directory and replace them with the working copy from the backup drive, but they still didn't load the layers stored in the geopackage.
Is there a way to rescue these files, or do I just need to give up and roll back to my last backup?
Further, are there best practices to use to prevent this in the future?