Skip to content

Local version cache not updated when clearing split records #4520

Description

@alecgrieser

We maintain two caches where we store the local version associated with a record. One of them is the versionMutationCache that stores a mapping from byte[] to NonnullPair<MutationType, byte[]>:

private ConcurrentNavigableMap<byte[], NonnullPair<MutationType, byte[]>> versionMutationCache;

This is used to store the "dirty" incomplete version mutations. We apply these right before commit(). The reason this is done is that the FDB API otherwise provides no way to remove mutations, so we'd wind up writing just the version if we saved and deleted a record with a version in one transaction.

But there's a second spot, the localVersionCache:

This is from byte[] to Integer, and it allows us to read a record written with an incomplete version and fill in the version correctly. Technically, this could be done from the versionMutationCache instead, but it would require a bit more effort. (It would require reading the key from the cache, validating the MutationType is SET_VERSIONSTAMPED_VALUE, and then parsing the version out of the mutation's value.) We already update this in several places where we clear out records, including if the record is not split--see:

if (oldHasIncompleteVersion) {
return updateIndexesFuture.thenApply(vignore -> {
byte[] versionKey = getSubspace().pack(recordVersionKey(primaryKey));
context.removeLocalVersion(versionKey);
return true;
});
} else {

But it's missing from KeyValueUnsplitter::clearPreviousSplitRecord:

context.getLocalVersion(versionKey).ifPresent(localVersion -> context.removeVersionMutation(versionKey));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions