Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed May 10, 2024
1 parent 368e51e commit 6ba29f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions crates/xline/src/server/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,8 @@ where
}
};
ops.append(&mut wr_ops);
let key_revisions = self.persistent.flush_ops(ops)?;
if !key_revisions.is_empty() {
self.kv_storage.insert_index(key_revisions);
}
println!("flush ops: {ops:?}");
let _key_revisions = self.persistent.flush_ops(ops)?;
self.lease_storage.mark_lease_synced(wrapper);
if !quota_enough {
if let Some(alarmer) = self.alarmer.read().clone() {
Expand Down
3 changes: 1 addition & 2 deletions crates/xline/src/server/watch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ mod test {
..Default::default()
});
let (_sync_res, ops) = store.after_sync(&req, revision).await.unwrap();
let key_revisions = db.flush_ops(ops).unwrap();
store.insert_index(key_revisions);
let _key_revisions = db.flush_ops(ops).unwrap();
}

#[tokio::test]
Expand Down
16 changes: 5 additions & 11 deletions crates/xline/src/storage/kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
db::SCHEDULED_COMPACT_REVISION,
index::{Index, IndexOperate},
lease_store::LeaseCollection,
revision::{KeyRevision, Revision},
revision::Revision,
storage_api::StorageApi,
};
use crate::{
Expand Down Expand Up @@ -794,7 +794,7 @@ where
sub_revision: i64,
) -> Result<(Vec<WriteOp>, Vec<Event>), ExecuteError> {
let mut ops = Vec::new();
let (new_rev, _prev_rev) =
let (new_rev, prev_rev) =
self.inner
.index
.register_revision(req.key.clone(), revision, sub_revision);
Expand All @@ -807,7 +807,8 @@ where
lease: req.lease,
};
if req.ignore_lease || req.ignore_value {
let prev_kv = self.inner.get_range(&req.key, &[], 0)?.pop();
let rev = prev_rev.ok_or(ExecuteError::KeyNotFound)?.mod_revision;
let prev_kv = self.inner.get_range(&req.key, &[], rev)?.pop();
let prev = prev_kv.as_ref().ok_or(ExecuteError::KeyNotFound)?;
if req.ignore_lease {
kv.lease = prev.lease;
Expand Down Expand Up @@ -913,12 +914,6 @@ where
let events = Self::new_deletion_events(revision, keys);
(ops, events)
}

/// Insert the given pairs (key, `KeyRevision`) into the index
#[inline]
pub(crate) fn insert_index(&self, key_revisions: Vec<(Vec<u8>, KeyRevision)>) {
self.inner.index.insert(key_revisions);
}
}

#[cfg(test)]
Expand Down Expand Up @@ -1040,8 +1035,7 @@ mod test {
revision: i64,
) -> Result<(), ExecuteError> {
let (_sync_res, ops) = store.after_sync(request, revision).await?;
let key_revs = store.inner.db.flush_ops(ops)?;
store.insert_index(key_revs);
let _key_revs = store.inner.db.flush_ops(ops)?;
Ok(())
}

Expand Down
3 changes: 1 addition & 2 deletions crates/xline/src/storage/kvwatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ mod test {
..Default::default()
});
let (_sync_res, ops) = store.after_sync(&req, revision).await.unwrap();
let key_revisions = db.flush_ops(ops).unwrap();
store.insert_index(key_revisions);
let _key_revisions = db.flush_ops(ops).unwrap();
}
}

0 comments on commit 6ba29f5

Please sign in to comment.