Merge "Enable write-ahead logging for keystore db." am: fb1604952a am: 91fe6ad84b am: 4f27ac568a
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1699378
Change-Id: Ie6bade3ae98f0d15bab788e9d3e41668d6d71da3
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index ce0cb1d..0cc3aa9 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -984,6 +984,12 @@
return Err(e);
}
}
+ let result: String = conn
+ .pragma_update_and_check(None, "journal_mode", &"WAL", |row| row.get(0))
+ .expect("Attempting to set journal mode failed.");
+ if result != "wal" {
+ error!("Failed to put DB in WAL mode. This will make keystore slow.");
+ }
break;
}
diff --git a/keystore2/vpnprofilestore/lib.rs b/keystore2/vpnprofilestore/lib.rs
index 548bec5..3d986a2 100644
--- a/keystore2/vpnprofilestore/lib.rs
+++ b/keystore2/vpnprofilestore/lib.rs
@@ -24,6 +24,7 @@
};
use anyhow::{Context, Result};
use keystore2::{async_task::AsyncTask, legacy_blob::LegacyBlobLoader, utils::watchdog as wd};
+use log::error;
use rusqlite::{
params, Connection, OptionalExtension, Transaction, TransactionBehavior, NO_PARAMS,
};
@@ -43,6 +44,15 @@
};
db.init_tables().context("Trying to initialize vpnstore db.")?;
+
+ let result: String = db
+ .conn
+ .pragma_update_and_check(None, "journal_mode", &"WAL", |row| row.get(0))
+ .expect("Attempting to set journal mode failed.");
+ if result != "wal" {
+ error!("Failed to put DB in WAL mode. This will make keystore slow.");
+ }
+
Ok(db)
}