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>) {
|
async fn worker(self: Arc<Self>) {
|
||||||
debug!("session starting");
|
debug!("session starting");
|
||||||
while self.server.running() {
|
while self.server.running() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use conduit::{implement, Result};
|
use conduit::{implement, Result};
|
||||||
use database::{Deserialized, Map};
|
use database::{Database, Deserialized, Map};
|
||||||
use ruma::{RoomId, UserId};
|
use ruma::{RoomId, UserId};
|
||||||
|
|
||||||
use crate::{globals, rooms, rooms::short::ShortStateHash, Dep};
|
use crate::{globals, rooms, rooms::short::ShortStateHash, Dep};
|
||||||
|
@ -12,6 +12,7 @@ pub struct Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
|
db: Arc<Database>,
|
||||||
userroomid_notificationcount: Arc<Map>,
|
userroomid_notificationcount: Arc<Map>,
|
||||||
userroomid_highlightcount: Arc<Map>,
|
userroomid_highlightcount: Arc<Map>,
|
||||||
roomuserid_lastnotificationread: Arc<Map>,
|
roomuserid_lastnotificationread: Arc<Map>,
|
||||||
|
@ -27,11 +28,12 @@ impl crate::Service for Service {
|
||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
db: Data {
|
db: Data {
|
||||||
userroomid_notificationcount: args.db["userroomid_notificationcount"].clone(),
|
db: args.db.clone(),
|
||||||
userroomid_highlightcount: args.db["userroomid_highlightcount"].clone(),
|
userroomid_notificationcount: args.db["userroomid_notificationcount"].clone(),
|
||||||
roomuserid_lastnotificationread: args.db["userroomid_highlightcount"].clone(), //< NOTE: known bug from conduit
|
userroomid_highlightcount: args.db["userroomid_highlightcount"].clone(),
|
||||||
roomsynctoken_shortstatehash: args.db["roomsynctoken_shortstatehash"].clone(),
|
roomuserid_lastnotificationread: args.db["userroomid_highlightcount"].clone(),
|
||||||
},
|
roomsynctoken_shortstatehash: args.db["roomsynctoken_shortstatehash"].clone(),
|
||||||
|
},
|
||||||
|
|
||||||
services: Services {
|
services: Services {
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
|
@ -98,6 +100,7 @@ pub async fn associate_token_shortstatehash(&self, room_id: &RoomId, token: u64,
|
||||||
.await
|
.await
|
||||||
.expect("room exists");
|
.expect("room exists");
|
||||||
|
|
||||||
|
let _cork = self.db.db.cork();
|
||||||
let key: &[u64] = &[shortroomid, token];
|
let key: &[u64] = &[shortroomid, token];
|
||||||
self.db
|
self.db
|
||||||
.roomsynctoken_shortstatehash
|
.roomsynctoken_shortstatehash
|
||||||
|
|
|
@ -5,7 +5,7 @@ use conduit::{
|
||||||
utils::{stream::TryIgnore, string::Unquoted, ReadyExt},
|
utils::{stream::TryIgnore, string::Unquoted, ReadyExt},
|
||||||
Err, Error, Result, Server,
|
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 futures::{FutureExt, Stream, StreamExt, TryFutureExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
|
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
|
||||||
|
@ -26,6 +26,7 @@ pub struct Service {
|
||||||
|
|
||||||
struct Services {
|
struct Services {
|
||||||
server: Arc<Server>,
|
server: Arc<Server>,
|
||||||
|
db: Arc<Database>,
|
||||||
account_data: Dep<account_data::Service>,
|
account_data: Dep<account_data::Service>,
|
||||||
admin: Dep<admin::Service>,
|
admin: Dep<admin::Service>,
|
||||||
globals: Dep<globals::Service>,
|
globals: Dep<globals::Service>,
|
||||||
|
@ -60,6 +61,7 @@ impl crate::Service for Service {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
services: Services {
|
services: Services {
|
||||||
server: args.server.clone(),
|
server: args.server.clone(),
|
||||||
|
db: args.db.clone(),
|
||||||
account_data: args.depend::<account_data::Service>("account_data"),
|
account_data: args.depend::<account_data::Service>("account_data"),
|
||||||
admin: args.depend::<admin::Service>("admin"),
|
admin: args.depend::<admin::Service>("admin"),
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
|
@ -721,6 +723,7 @@ impl Service {
|
||||||
let mut last = prefix.clone();
|
let mut last = prefix.clone();
|
||||||
last.extend_from_slice(&until.to_be_bytes());
|
last.extend_from_slice(&until.to_be_bytes());
|
||||||
|
|
||||||
|
let _cork = self.services.db.cork_and_flush();
|
||||||
self.db
|
self.db
|
||||||
.todeviceid_events
|
.todeviceid_events
|
||||||
.rev_raw_keys_from(&last) // this includes last
|
.rev_raw_keys_from(&last) // this includes last
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue