mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 04:37:00 +00:00
feat: Kill roomsynctoken_shortstatehash dead
This commit is contained in:
3 files changed
+32
-2
No files matched your search
@@ -1 +1 @@
|
|||||||
Adjusted legacy sync logic to no longer use the `roomsynctoken_shortstatehash` database column. Once this change has been confirmed to be stable and reliable, a future update will remove it entirely, significantly decreasing database sizes. Contributed by @ginger.
|
Adjusted legacy sync logic to allow the `roomsynctoken_shortstatehash` database column to be dropped, massively reducing database sizes, especially for old deployments. Contributed by @ginger.
|
||||||
@@ -17,7 +17,7 @@ use std::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{Err, Result, debug, info, warn};
|
use conduwuit::{Err, Result, debug, err, info, warn};
|
||||||
use rocksdb::{
|
use rocksdb::{
|
||||||
AsColumnFamilyRef, BoundColumnFamily, DBCommon, DBWithThreadMode, MultiThreaded,
|
AsColumnFamilyRef, BoundColumnFamily, DBCommon, DBWithThreadMode, MultiThreaded,
|
||||||
WaitForCompactOptions,
|
WaitForCompactOptions,
|
||||||
@@ -127,6 +127,12 @@ impl Engine {
|
|||||||
|
|
||||||
sequence
|
sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn drop_column(&self, name: &str) -> Result {
|
||||||
|
self.db
|
||||||
|
.drop_cf(name)
|
||||||
|
.map_err(|err| err!("Failed to drop {name}: {err}"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Engine {
|
impl Drop for Engine {
|
||||||
|
|||||||
@@ -240,6 +240,19 @@ async fn migrate(services: &Services) -> Result<()> {
|
|||||||
.map_err(|e| err!("Failed to run 'split_userid_password' migration': {e}"))?;
|
.map_err(|e| err!("Failed to run 'split_userid_password' migration': {e}"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if db["global"]
|
||||||
|
.get(DROP_ROOMSYNCTOKEN_SHORTSTATEHASH)
|
||||||
|
.await
|
||||||
|
.is_not_found()
|
||||||
|
{
|
||||||
|
info!("Running migration 'drop_roomsynctoken_shortstatehash'");
|
||||||
|
obliterate_roomsynctoken_shortstatehash_with_extreme_prejudice(services)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
err!("Failed to run 'drop_roomsynctoken_shortstatehash' migration': {e}")
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
services.globals.db.database_version().await,
|
services.globals.db.database_version().await,
|
||||||
DATABASE_VERSION,
|
DATABASE_VERSION,
|
||||||
@@ -873,3 +886,14 @@ async fn split_userid_password(services: &Services) -> Result {
|
|||||||
db.db.sort()?;
|
db.db.sort()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DROP_ROOMSYNCTOKEN_SHORTSTATEHASH: &str = "drop_roomsynctoken_shortstatehash";
|
||||||
|
async fn obliterate_roomsynctoken_shortstatehash_with_extreme_prejudice(
|
||||||
|
services: &Services,
|
||||||
|
) -> Result {
|
||||||
|
services.db.db.drop_column("roomsynctoken_shortstatehash")?;
|
||||||
|
|
||||||
|
info!("Cleared roomsynctoken_shortstatehash.");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in new issue
Block a user