mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-04 09:58:57 +00:00
* fix(android): open every SQLite connection in WAL, not just the JSI one #10109 re-enabled `pragma journal_mode = WAL` in WatermelonDB's shared Database.cpp. Android runs WatermelonDB through JSI -- watermelondb-jsi is in settings.gradle and WatermelonDBJSIPackage is registered in MainApplication -- so that pragma applies there, and both databases are created with `jsi: true`. But the app also opens those same files from native Kotlin, on the push notification path, and every one of those connections was opened without WAL: - DatabaseHelper.setDefaultDatabase -> WMDatabase.getInstance(path, context), whose 2-arg overload this repo's patch had stripped ENABLE_WRITE_AHEAD_LOGGING from (app.db) - getDatabaseForServer -> WMDatabase.buildDatabase(..., CREATE_IF_NECESSARY), hardcoded here, for every server database - WMDatabaseDriver's constructor, stripped by the same patch, for the bridge path WatermelonDB falls back to when JSI is unavailable Journal mode is a property of the database file, not of a connection. When Android's SQLiteConnection opens a database without ENABLE_WRITE_AHEAD_LOGGING it issues its own `PRAGMA journal_mode` on open and drags the file back out of WAL underneath the live JSI connection. Two connections disagreeing about the journal is what produced `watermelondb.sqlite: (11) database disk image is malformed` while adding a server -- the first write to app.db. The paths provably collide: the patched WMDatabase.getInstance rewrites `file:///…/files/app.db` to `/…/files/databases/app.db`, which is exactly what the JS side opens as `${Paths.document.uri}/databases/app.db`. This was consistent before #10109 because the patch disabled WAL in two independent places -- the Java flags and the C++ pragma -- so everything was non-WAL and agreed. #10109 re-enabled only the C++ half. The coherent states are all-on or all-off; this makes it all-on, so #10109 is kept. Reverting the two patch hunks rather than editing them leaves upstream's flags untouched, which is why the diff removes them instead of rewriting them. Not verified on a device here; it needs an Android build against the WAL-on repro. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Address review: trim WAL comment and regenerate watermelondb patch Regenerate @nozbe+watermelondb+0.28.1-0.patch via patch-package after restoring ENABLE_WRITE_AHEAD_LOGGING in node_modules, instead of hand-editing the patch. Trim the verbose comment in getDatabaseForServer. Co-authored-by: yasser khan <attitude3cena.yf@gmail.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|---|---|---|
| .. | ||
| @gorhom+bottom-sheet+5.2.13.patch | ||
| @nozbe+watermelondb+0.28.1-0.patch | ||
| @react-native-community+netinfo+12.0.1.patch | ||
| @rneui+base+5.0.0.patch | ||
| @types+commonmark-react-renderer+4.3.4.patch | ||
| @types+react-syntax-highlighter+15.5.13.patch | ||
| expo-image+55.0.10.patch | ||
| expo-video-thumbnails+55.0.14.patch | ||
| ratex-react-native+0.1.4.patch | ||
| react-native-keyboard-controller+1.21.10.patch | ||
| react-native-keychain+10.0.0.patch | ||
| react-native-notifications+5.2.2.patch | ||
| react-native-safe-area-context+5.7.0.patch | ||
| react-native-share+12.3.1.patch | ||
| react-native-walkthrough-tooltip+1.6.0.patch | ||
| react-native-webrtc+124.0.7.patch | ||
| react-native+0.83.9.patch | ||
| react-syntax-highlighter+16.1.1.patch | ||