fix deadlock

This commit is contained in:
Aiden McClelland
2021-07-08 11:03:48 -06:00
parent 824a103e5c
commit a70d06644e
4 changed files with 9 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ mod test;
pub use handle::{DbHandle, PatchDbHandle};
pub use json_ptr;
pub use json_patch;
pub use locker::{LockType, Locker};
pub use model::{
BoxModel, HasModel, Map, MapModel, Model, ModelData, ModelDataMut, OptionModel, VecModel,

View File

@@ -29,10 +29,13 @@ pub struct Transaction<Parent: DbHandle> {
impl Transaction<&mut PatchDbHandle> {
pub async fn commit(mut self, expire_id: Option<String>) -> Result<Arc<Revision>, Error> {
let store_lock = self.parent.store();
let store = store_lock.read().await;
let store = store_lock.write().await;
self.rebase()?;
let rev = self.parent.db.apply(self.updates, expire_id, None).await?;
drop(store);
let rev = self
.parent
.db
.apply(self.updates, expire_id, Some(store))
.await?;
Ok(rev)
}
pub async fn abort(mut self) -> Result<DiffPatch, Error> {