Skip to content

Enable WAL mode - #4644

Open
uclaros wants to merge 6 commits into
masterfrom
bugfix/enable-wal-mode
Open

Enable WAL mode#4644
uclaros wants to merge 6 commits into
masterfrom
bugfix/enable-wal-mode

Conversation

@uclaros

@uclaros uclaros commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

QGIS uses WAL mode for accessing local geopackages.
By removing the OGR_SQLITE_JOURNAl=DELETE we let QGIS use that default.
Geopackages are opened in WAL mode so now readers do not block writers, fixing the issue that geodiff would find the database locked and create conflicted copies.

One thing to be aware of is that now commits may live in the .gpkg-wal file until a sqlite checkpoint operation takes place writing the .gpkg-wal contents into the .gpkg file, or the provider has closed the file. We must therefore treat the three files (.gpkg, .gpkg-wal, .gpkg-shm) as a group (hello shapefile!) when copying/renaming at the os level.
Geodiff has a GEODIFF_makeCopySqlite() function for copying gpkgs, which opens the source and creates a backup on the destination, so practically implicitly checkpointing along the way. This has been wrapped in GeodiffUtils::copyWalAware() and we need to be using this whenever we need to copy a geopackage that was opened and written to by qgis, like project layer geopackage, however we don't need to do it for copying the base file from .mergin folder or the diff geopackages.

When renaming such gpkgs we can either do GeodiffUtils::copyWalAware() and then delete the source (adding the overhead of a full copy) or use GeodiffUtils::renameWalAware() which bluntly tries to also rename -wal and -shm files (this was chosen for this proposed implementation to avoid the copy overhead, however the first solution is probably the safest choice).

Fixes #4577
Fixes #4583
Hopefully fixes #3866 (not tested)

@github-actions

Copy link
Copy Markdown

Coverage Report for CI Build 31395445511

Coverage increased (+0.08%) to 59.179%

Details

  • Coverage increased (+0.08%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 49 coverage regressions across 4 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

49 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
mm/app/main.cpp 43 36.67%
mm/core/merginuserinfo.cpp 4 77.12%
mm/app/position/providers/simulatedpositionprovider.cpp 1 91.67%
mm/core/geodiffutils.cpp 1 92.11%

Coverage Stats

Coverage Status
Relevant Lines: 15688
Covered Lines: 9284
Line Coverage: 59.18%
Coverage Strength: 103.45 hits per line

💛 - Coveralls

@github-actions

Copy link
Copy Markdown

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 71461 dmg Expires: 08/11/2026 #7146
linux Build 📬 Mergin Maps 71721 x86_64 Expires: 08/11/2026 #7172
win64 Build Build failed or not found. #6348
Android Build 📬 Mergin Maps 845751 APK [arm64-v8a] Expires: 08/11/2026 #8457
📬 Mergin Maps 845751 APK [arm64-v8a] Google Play Store #8457
Android Build 📬 Mergin Maps 845711 APK [armeabi-v7a] Expires: 08/11/2026 #8457
📬 Mergin Maps 845711 APK [armeabi-v7a] Google Play Store #8457
iOS Build 📬 Build number: 26.08.939811 #9398

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

Successfully merging this pull request may close these issues.

Mobile app creates many conflicting copies and inflates project size Enable WAL mode SQL Query Layer causing? "Saving Failed"

1 participant