Refactor working-set support, add pending tasks

This refactors the working-set support so that taskdb knows how to
rebuild the working set (in a single transaction) but replica knows what
tasks should be in that set.

This also adds support for automatically adding tasks to the working set
when they are marked pending.  Note that tasks are not *removed* from
the working set automatically, but only on a gc operation.
This commit is contained in:
Dustin J. Mitchell
2020-11-22 18:18:53 -05:00
parent 39a0dfe798
commit 03e4fc7cee
5 changed files with 120 additions and 44 deletions

View File

@@ -307,7 +307,7 @@ impl<'t> TaskStorageTxn for Txn<'t> {
Ok(res)
}
fn add_to_working_set(&mut self, uuid: Uuid) -> Fallible<u64> {
fn add_to_working_set(&mut self, uuid: &Uuid) -> Fallible<u64> {
let working_set_bucket = self.working_set_bucket();
let numbers_bucket = self.numbers_bucket();
let kvtxn = self.kvtxn();
@@ -321,7 +321,7 @@ impl<'t> TaskStorageTxn for Txn<'t> {
kvtxn.set(
working_set_bucket,
next_index.into(),
Msgpack::to_value_buf(uuid)?,
Msgpack::to_value_buf(uuid.clone())?,
)?;
kvtxn.set(
numbers_bucket,
@@ -666,8 +666,8 @@ mod test {
{
let mut txn = storage.txn()?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(uuid2.clone())?;
txn.add_to_working_set(&uuid1)?;
txn.add_to_working_set(&uuid2)?;
txn.commit()?;
}
@@ -689,15 +689,15 @@ mod test {
{
let mut txn = storage.txn()?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(uuid2.clone())?;
txn.add_to_working_set(&uuid1)?;
txn.add_to_working_set(&uuid2)?;
txn.commit()?;
}
{
let mut txn = storage.txn()?;
txn.remove_from_working_set(1)?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(&uuid1)?;
txn.commit()?;
}
@@ -718,7 +718,7 @@ mod test {
{
let mut txn = storage.txn()?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(&uuid1)?;
txn.commit()?;
}
@@ -742,16 +742,16 @@ mod test {
{
let mut txn = storage.txn()?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(uuid2.clone())?;
txn.add_to_working_set(&uuid1)?;
txn.add_to_working_set(&uuid2)?;
txn.commit()?;
}
{
let mut txn = storage.txn()?;
txn.clear_working_set()?;
txn.add_to_working_set(uuid2.clone())?;
txn.add_to_working_set(uuid1.clone())?;
txn.add_to_working_set(&uuid2)?;
txn.add_to_working_set(&uuid1)?;
txn.commit()?;
}