move cork to remove_to_device_events fn
add cork around write-heavy database routine called in loop; cleanup Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
23cf2b2236
commit
b77a1eb079
3 changed files with 14 additions and 8 deletions
|
@ -89,7 +89,7 @@ impl Console {
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, name = "console")]
|
||||
#[tracing::instrument(skip_all, name = "console", level = "trace")]
|
||||
async fn worker(self: Arc<Self>) {
|
||||
debug!("session starting");
|
||||
while self.server.running() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduit::{implement, Result};
|
||||
use database::{Deserialized, Map};
|
||||
use database::{Database, Deserialized, Map};
|
||||
use ruma::{RoomId, UserId};
|
||||
|
||||
use crate::{globals, rooms, rooms::short::ShortStateHash, Dep};
|
||||
|
@ -12,6 +12,7 @@ pub struct Service {
|
|||
}
|
||||
|
||||
struct Data {
|
||||
db: Arc<Database>,
|
||||
userroomid_notificationcount: Arc<Map>,
|
||||
userroomid_highlightcount: Arc<Map>,
|
||||
roomuserid_lastnotificationread: Arc<Map>,
|
||||
|
@ -27,11 +28,12 @@ impl crate::Service for Service {
|
|||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
db: Data {
|
||||
userroomid_notificationcount: args.db["userroomid_notificationcount"].clone(),
|
||||
userroomid_highlightcount: args.db["userroomid_highlightcount"].clone(),
|
||||
roomuserid_lastnotificationread: args.db["userroomid_highlightcount"].clone(), //< NOTE: known bug from conduit
|
||||
roomsynctoken_shortstatehash: args.db["roomsynctoken_shortstatehash"].clone(),
|
||||
},
|
||||
db: args.db.clone(),
|
||||
userroomid_notificationcount: args.db["userroomid_notificationcount"].clone(),
|
||||
userroomid_highlightcount: args.db["userroomid_highlightcount"].clone(),
|
||||
roomuserid_lastnotificationread: args.db["userroomid_highlightcount"].clone(),
|
||||
roomsynctoken_shortstatehash: args.db["roomsynctoken_shortstatehash"].clone(),
|
||||
},
|
||||
|
||||
services: Services {
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
|
@ -98,6 +100,7 @@ pub async fn associate_token_shortstatehash(&self, room_id: &RoomId, token: u64,
|
|||
.await
|
||||
.expect("room exists");
|
||||
|
||||
let _cork = self.db.db.cork();
|
||||
let key: &[u64] = &[shortroomid, token];
|
||||
self.db
|
||||
.roomsynctoken_shortstatehash
|
||||
|
|
|
@ -5,7 +5,7 @@ use conduit::{
|
|||
utils::{stream::TryIgnore, string::Unquoted, ReadyExt},
|
||||
Err, Error, Result, Server,
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
use database::{Database, Deserialized, Ignore, Interfix, Json, Map};
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt};
|
||||
use ruma::{
|
||||
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
|
||||
|
@ -26,6 +26,7 @@ pub struct Service {
|
|||
|
||||
struct Services {
|
||||
server: Arc<Server>,
|
||||
db: Arc<Database>,
|
||||
account_data: Dep<account_data::Service>,
|
||||
admin: Dep<admin::Service>,
|
||||
globals: Dep<globals::Service>,
|
||||
|
@ -60,6 +61,7 @@ impl crate::Service for Service {
|
|||
Ok(Arc::new(Self {
|
||||
services: Services {
|
||||
server: args.server.clone(),
|
||||
db: args.db.clone(),
|
||||
account_data: args.depend::<account_data::Service>("account_data"),
|
||||
admin: args.depend::<admin::Service>("admin"),
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
|
@ -721,6 +723,7 @@ impl Service {
|
|||
let mut last = prefix.clone();
|
||||
last.extend_from_slice(&until.to_be_bytes());
|
||||
|
||||
let _cork = self.services.db.cork_and_flush();
|
||||
self.db
|
||||
.todeviceid_events
|
||||
.rev_raw_keys_from(&last) // this includes last
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue