Fix migration of last mod cid (#3065)

This commit is contained in:
Firstyear 2024-09-30 19:56:48 +10:00 committed by GitHub
parent e4f5c2313d
commit 23636acbf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View file

@ -2352,6 +2352,21 @@ where
vs.trim(trim_cid);
}
// During migration to the new modified/created cid system, we need to account
// for entries that don't have this yet. Normally we would apply this in seal()
// to the current CID. At this point we enter in the expected value from the
// entry. Note, we don't set last mod to cid yet, we leave that to seal() so that
// if this entry is excluded later in the change, we haven't tainted anything, or
// so that if the change only applies to non-replicated attrs we haven't mucked
// up the value.
let last_mod_cid = self.valid.ecstate.get_max_cid();
let cv = vs_cid![last_mod_cid.clone()];
let _ = self.attrs.insert(Attribute::LastModifiedCid, cv);
let create_at_cid = self.valid.ecstate.at();
let cv = vs_cid![create_at_cid.clone()];
let _ = self.attrs.insert(Attribute::CreatedAtCid, cv);
Entry {
valid: EntryInvalid {
cid,

View file

@ -220,21 +220,6 @@ impl<'a> QueryServerWriteTransaction<'a> {
.and_then(|()| self.reload())
}
#[instrument(level = "debug", skip_all)]
pub fn internal_migrate_or_create_str(&mut self, e_str: &str) -> Result<(), OperationError> {
let res = Entry::from_proto_entry_str(e_str, self)
/*
.and_then(|e: Entry<EntryInvalid, EntryNew>| {
let schema = self.get_schema();
e.validate(schema).map_err(OperationError::SchemaViolation)
})
*/
.and_then(|e: Entry<EntryInit, EntryNew>| self.internal_migrate_or_create(e));
trace!(?res);
debug_assert!(res.is_ok());
res
}
#[instrument(level = "debug", skip_all)]
/// - If the thing exists:
/// - Ensure the set of attributes match and are present