bdeggleston commented on code in PR #106:
URL: https://github.com/apache/cassandra-accord/pull/106#discussion_r1700543443
##########
accord-core/src/main/java/accord/local/SafeCommandStore.java:
##########
@@ -214,58 +214,64 @@ private void updateMaxConflicts(Command prev, Command
updated)
commandStore().updateMaxConflicts(prev, updated);
}
- private void updateCommandsForKey(Command prev, Command updated)
+ private void updateCommandsForKey(Command prev, Command next)
{
- if (!CommandsForKey.needsUpdate(prev, updated))
+ if (!CommandsForKey.needsUpdate(prev, next))
return;
- TxnId txnId = updated.txnId();
- Keys keys;
- if (txnId.domain().isKey() && txnId.kind().isGloballyVisible())
+ TxnId txnId = next.txnId();
+ if (CommandsForKey.manages(txnId)) updateManagedCommandsForKey(this,
prev, next);
+ if (!CommandsForKey.managesExecution(txnId) &&
next.hasBeen(Status.Stable) && !next.hasBeen(Status.Truncated) &&
!prev.hasBeen(Status.Stable))
+ updateUnmanagedExecutionCommandsForKey(this, next);
+ }
+
+ private static void updateManagedCommandsForKey(SafeCommandStore
safeStore, Command prev, Command next)
+ {
+ TxnId txnId = next.txnId();
+ Keys keys = (Keys)next.keysOrRanges();
+ if (keys == null || next.hasBeen(Status.Truncated)) keys =
(Keys)prev.keysOrRanges();
+ if (keys == null)
+ return;
+
+ // TODO (required): additionalKeysOrRanges may not be being handled
entirely correctly here, though it may not matter.
+ // Once committed without a given key, we should be effectively
erasing the command from that CFK
+ PreLoadContext context = PreLoadContext.contextFor(txnId, keys,
COMMANDS);
+ // TODO (expected): execute immediately for any keys we already have
loaded, and save only those we haven't for later
+ if (safeStore.canExecuteWith(context))
{
- keys = (Keys)updated.keysOrRanges();
- if (keys == null || updated.hasBeen(Status.Truncated)) keys =
(Keys)prev.keysOrRanges();
- if (keys == null)
- return;
-
- PreLoadContext context = PreLoadContext.contextFor(txnId, keys,
COMMANDS);
- // TODO (expected): execute immediately for any keys we already
have loaded, and save only those we haven't for later
- if (canExecuteWith(context))
- {
- for (Key key : keys)
- {
- get(key).update(this, prev, updated);
- }
- }
- else
+ for (Key key : keys)
{
- commandStore().execute(context, safeStore ->
safeStore.updateCommandsForKey(prev, updated))
- .begin(commandStore().agent);
+ safeStore.get(key).update(safeStore, next);
}
}
else
{
- if (!updated.hasBeen(Status.Stable) || prev.hasBeen(Status.Stable)
|| updated.hasBeen(Status.Truncated))
- return;
-
- keys = updated.asCommitted().waitingOn.keys;
- // TODO (required): consider how execution works for transactions
that await future deps and where the command store inherits additional keys in
execution epoch
- Ranges ranges = ranges().allAt(updated.executeAt());
- PreLoadContext context = PreLoadContext.contextFor(txnId, keys,
COMMANDS);
- // TODO (expected): execute immediately for any keys we already
have loaded, and save only those we haven't for later
- if (canExecuteWith(context))
- {
- Routables.foldl(keys, ranges, (self, t, key, o, i) -> {
- self.get(key).registerUnmanaged(self, self.get(t));
- return null;
- }, this, txnId, null, i->false);
- }
- else
- {
- commandStore().execute(context, safeStore ->
safeStore.updateCommandsForKey(prev, updated))
- .begin(commandStore().agent);
- }
+ safeStore = safeStore;
Review Comment:
ah nice, that's a good idea
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]