Commit Graph

176 Commits

Author SHA1 Message Date
Benedict Elliott Smith 41cf61402c Improve Tail Latency
- TransactionStatement token aware routing
 - Mitigate convoy effect:
   - ExecuteTxnBacklog v1 can execute single key transaction backlogs and disseminate the result
     - Direct local execution possible for single key transactions
   - Use shardAppliedBefore instead of gcBefore to cleanup CFK faster
Also Improve:
 - Introduce distributed tracing
 - Combine RejectBefore and MaxConflicts
 - Self-addressed messages are delivered directly
 - Disable AccordSyncPropagator by default, as incompatible with large clusters
 - FastPathStrategy.SIMPLE should not modify fast path contents; FastPathStrategy.UP introduced to adopt this behaviour
 - Configurable queue prioritisation
 - ProtocolModifiers mostly final
 - Remove unnecessary condition check when serializing TxnUpdate
Also Fix:
 - SequentialExecutor ownership bug
 - BTree.XUpdater.reset()

patch by Benedict; reviewed by Alex Petrov and Ariel Weisberg for CASSANDRA-21361
2026-05-13 15:15:23 +01:00
Benedict Elliott Smith 8876ad4c03 Introduce:
- Clean Shutdown/Restart
 - Rebootstrap to allow nodes to rejoin consensus if they are out of sync, or did not shutdown cleanly
Improve:
 - Improve efficiency of BTreeReducingRangeMap
 - DurableBefore backed by BTreeReducingRangeMap
 - Soft reject new transactions when a replica has a backlog of work
 - system_accord_debug.command_store_ops supports starting journal replay
Fix:
 - Ensure SequentialExecutor.owner is unset only by the owner
 - Detect and avoid taking two AccordExecutor locks simultaneously
 - MaxConflicts serializer
 - tryToExecuteListening after replay, to handle invalidated dependencies
 - TxnNamedRead does not close a RowIterator, leading to native memory leaks
 - GetLatestDepsNack serialization
 - journal.readLast() did not read last
 - DefaultRemoteListeners not correctly synchronised
 - RangeTxnScanner cancellation assumes was already started
 - Start cfk compaction before replay
 - txn_graph should avoid visiting parents twice (possible if two different dependency chains connecting them in the graph)
 - Topology.cloneEquivalentWithEpoch should also share nodeLookup and ranges, especially to accelerate computeWaitForEpoch/computeScope
 - Do not invoke slowReplicaDelay or slowCoordinatorDelay during restore
 - Do not fail if slowReplicaDelay or slowCoordinatorDelay are invoked without knowing the transaction

patch by Benedict; reviewed by Alex Petrov and Ariel Weisberg for CASSANDRA-21355
2026-05-09 16:46:00 +01:00
Benedict Elliott Smith 6a665f3ee4 InMemoryRangeIndex
Also Add:
 - txn_graph and txn_graph_all virtual tables for debugging transaction dependency graphs
 - txn_cache virtual table to debug accord cache contents
Also Fix:
 - NPE in AccordDebugKeyspace.TxnOpsTable
 - AccordCoordinatorMetrics latency metrics should use Timer not Histogram
 - OnDiskIndex.readLast
Also Improve:
 - Catchup should run after progress log is started
 - Cancelling AccordTask should early-terminate range scanning
 - Improve RangeTxnScanner description
 - Add ballot to txn tables
 - Add NodeId to logging output

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21306
2026-04-13 16:01:47 +01:00
David Capwell c35c3181fa Fix flakey test org.apache.cassandra.utils.SimpleBitSetSerializersTest#any
patch by David Capwell; reviewed by Benedict Elliott Smith for CASSANDRA-21077
2026-01-07 16:00:10 -08:00
Benedict Elliott Smith e14816e244 Journal reads must select segments before sstables to avoid compaction races
Also Fix Cassandra:
 - In memory size calculation for CommandsForKey include Unmanaged
 - Accord load out-of-band cleanup should use SafeRedundantBefore
ALso Improve Cassandra:
 - Report replay information on begin replay
 - Improve AccordService shutdown
 - Log command store RedundantBefore on shutdown
 - Segment compaction should wait for readOrder barrier to replace segments, for additional safety
 - Journal segments should share readOrder with sstables
Also Improve Accord:
 - Iterate LocalListeners in order, so can query more effectively on node
 - Refine AbstractReplay.minReplay/shouldReplay

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21804
2025-12-17 19:34:44 +00:00
David Capwell 9c8ab8809d Accord: write rejections would be returned to users as server errors rather than INVALID and TxnReferenceOperation didn't handle all collections prperly
patch by David Capwell; reviewed by Benedict Elliott Smith, Caleb Rackliffe, Jyothsna Konisa for CASSANDRA-21061
2025-12-15 16:32:07 -08:00
Benedict Elliott Smith e4684a11ec Fix:
- DefaultLocalListeners.ComplexListeners iterator IndexOutOfBoundsException
 - Race condition initialising empty ActiveEpochs, when minimum pending epoch can move backwards
 - SyncPoints must be declared in an epoch containing the ranges, and PENDING_REMOVAL ranges will reject non-syncpoint transactions
 - AccordExecutorMetrics is now registered on startup
 - getRecentValues for non-cumulative histogram should not subtract prior values
Improve:
 - Report ephemeral read, epoch waits and timeout metrics
 - Remove Topologies.SelectNodeOwnership, as no need to SLICE anymore
 - Introduce SystemEventListener for epoch waiting and timeout metrics
 - No-op but log if gcBefore provided to CFK is in the past

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21076
2025-12-15 20:26:55 +00:00
Benedict Elliott Smith 13a3ae9297 Fix:
- DurabilityQueue/ShardScheduler deadlock
 - MemtableCleanerThread.Cleanup assumes Boolean parameter is non-null, which is invalid if an exception has been thrown
 - AccordDurableOnFlush may be invoked while Accord is starting up, so should use AccordService.unsafeInstance
 - AccordCache shrink without lock regression
 - Cleanup system_accord compaction leftovers before starting up
 - system_accord_debug.txn order
 - system_accord_debug.txn_blocked_by order
 - system_accord_debug.shard_epochs order
Improve:
 - Set DefaultProgressLog.setMode(Catchup) during Catchup
 - IdentityAccumulators only need to readLast, not readAll
 - Limit number of static segments we compact at once to sstable
 - If too many static segments on startup, wait for them to be compacted

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21053
2025-12-09 14:01:38 +00:00
Benedict Elliott Smith 4defbb9b1c Make TopologyException a checked exception to ensure they are handled carefully, as they may occur at surprising times
Also Fix:
 - Restore MaxDecidedRX on replay
 - When catchup_on_start_exit_on_failure == false, should startup on any kind of failure, not only timeout
 - lazy vtable LIMIT clause regression
 - DurabilityService.onEpochRetired
 - Command.validate when uniqueHlc differs
 - Avoid unsafe publication of AccordExecutor to scheduledFastTasks
 - AccordCache hitRate metric names
 - use long for return type of DurationSpec.toNanoseconds
 - Repair without all replicas should not request all Accord replicas participate
 - ExecuteAtSerializer
 - SyncPoints should be coordinated in an epoch that contains the ranges
Also Improve:
 - Split Accord startup into local+distributed, ensure we
 - Add logging to FetchDurableBefore on startup
 - Add randomised testing of AbstractLazyVirtualTable
 - Add validation of lazy virtual table key ordering
 - Don't send requests to faulty replicas
 - shrinkOrEvict large objects without holding lock
 - Accord dtest shutdown

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21042
2025-11-27 13:12:25 +00:00
Benedict Elliott Smith 494c3c7bef Add AccordExecutorMetrics
Also Introduce:
 - Sharded/LogLinearDecayingHistogram
Also Improve:
 - Do not take a reference to CFK unless relevant
Also Fix:
 - Sharded/LogLinearHistogram
 - ExecuteFlags serialization bug in ReadData

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21017
2025-11-13 14:36:15 +00:00
Benedict Elliott Smith f6fd49566f Improve DurabilityQueue:
- All retries are appended to a delay queue so overlaps can be pruned
 - Quorum successes are not retried if there are superseding sync points covering the ranges
 - User-initiated requests are not purged unless the request has timed out or otherwise completed
 - Overlapping requests are queued up against the next to run
Alsp (C*):
 - Catch-up with quorums on restart
 - Manage an ordered set of keys in cache for faster range searches
Also (Accord):
 - Update copy of BTree and import IntervalBTree
 - Fix RedundantStatus WAS_OWNED_OVERRIDE_MASK
 - Add Catchup mechanism to reach parity with a quorum on restart

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-21013
2025-11-12 17:20:25 +00:00
Benedict Elliott Smith aa5c3aba1d Improve Topology Management
Merge ConfigurationService with TopologyManager to remove cyclic dependency and duplicated work.
Also:
 - Improve visibility of work blocking topology processing
 - Ensure we cannot double-count peers when deciding an epoch's distributed readiness
 - Remove the possibility of distributed stalls, by processing new topologies as soon as a
   contiguous sequence is known locally, regardless of whether anyprior local epoch is ready to
   coordinate or has recorded this fact to peers. The notification of local readiness continues
   to be processed only once all prior epochs are ready, but we can begin using and readying
   later epochs immediately.

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20998
2025-11-06 14:38:01 +00:00
Benedict Elliott Smith c9e31f297c Introduce "hardRemoved" concept for marking nodes permanently offline, to permit recovery from availability loss
Also fix:
 - Paxos should not update minHlc if AccordService is not setup
 - Remove EndpointMapper methods that require non-null, to ensure call-sites handle null case explicitly
 - AccordRepair should specify the Node Ids that must participate, but these should not affect the durability requirements for GC
 - Avoid erroneously marking UniversalOrInvalidated when only known to quorum
 - AccordSyncPropagator should not consult FailureDetector as it may throw UnknownEndpointException
 - Refuse ReplaceSameAddress if accord enabled
 - Reset Accord topologies on restart if no local command stores to ensure we can catch up (as intervening epochs may have otherwise been GC'd)
 - MaybeRecover should not abort if found durable if either: 1) prevProgressToken already witnessed durable; or 2) Home state has requested we recover anyway
 - Invariant in MaybeRecover is too strong now we permit recovering when known to be stable
 - ReadData must respond with InsufficientAndWaiting if not Stable to ensure Durability is inferred correctly by ExecuteTxn
 - Avoid StackOverflowException in NotifyWaitingOn
 - PreAccept should honour the REJECTED flag of any member of the latest topology if the vote would be relied upon for any prior epoch's quorum
 - Resume Accord bootstrap on restart
 - Fix burn test non-determinism
 - Reset Accord topologies on restart if no local command stores to ensure we can catch up (as intervening epochs may have otherwise been GC'd)
 - Exclude stale or removed ids from sync points
 - Terminate a failed DurabilityRequest if a required participant is now removed/hardRemoved
Also improve:
 - Introduce accord_debug_keyspace.{listeners_txn, listeners_local}
 - Filter and record faulty in AbstractCoordination
 - If we are the home shard, and our home progress status is done, we should not wait for the home shard to advance the waiting progress state
 - Introduce CommandStore.tryExecuteListening to try to execute all waiting transactions and their dependencies
 - ExecuteTxn on recovery should not wait, to avoid consuming progress log concurrency slots for transactions that cannot execute
 - HomeState should update its phase based on the command status to handle operator request to retry all states
 - Separate home/wait queue in DefaultProgressLog
 - Additional tracing
 - Do not call trySendMore from prerecordFailure
 - Force full recovery for sync points if we have lost quorum

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20921
2025-11-03 15:16:27 +00:00
Benedict Elliott Smith e768418696 Accord: Improve Tracing
- Introduce pattern tracing, that can intercept failed or new coordinations matching various filters
     - Support additional tracing event collection modes (SAMPLE and RING)

    patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20911
2025-10-29 10:16:32 +00:00
Alex Petrov 3d2b0efc34 Accord: Add Rebootstrap and unsafe Bootstrap
To support recovering a node that has lost some of its local transaction log, introduce rebootstrap and unsafe bootstrap modes, where Accord ensures no responses are produced for transactions the node cannot be certain it had not previously answered.

patch by Benedict and Alex Petrov for CASSANDRA-20908
2025-10-27 14:24:06 +00:00
Benedict Elliott Smith 12000406c3 Follow-up to CASSANDRA-20906: Fix Simulator 2025-09-18 14:14:53 +01:00
Benedict Elliott Smith 0b2012826a Split AsyncChain and AsyncResult; normalise AsyncResult with C* Future
patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20906
2025-09-18 12:31:13 +01:00
Benedict Elliott Smith c7de33c597 Strict Serializability Verifier may incorrectly handle blind writes when witnessed before the writing operation ACKs
patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20905
2025-09-17 21:24:37 +01:00
Benedict Elliott Smith b4f6c7c617 Topology compaction omits image records if minEpoch is ahead of last image
Also Fix:
 - RegisteredCallback should remove itself from callback map when cancelled
 - Do not throw CancellationException when processing requests that have been aborted, as may be caused by a successful meaningful reply that can be overridden
 - system_accord_debug.{executors,coordinations} fail with ClassCastException
 - CommandStore.updateMinHlc eats up CPU as called much too often
 - AccordCache not notifying flushed on shutdown
Also Improve:
 - Support skipping Deps
 - Violation information reported
 - Sort CommandStore shards by id

patch by Benedict; reviewed by Aleksey Yeschenko for CASSANDRA-20896
2025-09-09 11:11:23 +01:00
Benedict Elliott Smith b91731b5a3 All pending topology notifications must be propagated to a newly published epoch, not only the pending notification for that epoch
Also Fix:
 - JournalAndTableKeyIterator not merging in consistent order, which can lead to replaying topologies in non-ascending order
 - Invariant failure when reporting topologies if fetchTopologies on startup yields a gap
 - removeRedundantMissing could erroneously remove missing dependencies occurring after the new appliedBeforeIndex
 - Invariant failure for some propagate calls supplying 'wrong' addRoute
 - Disambiguate nextTxnId and nextTxnIdWithDefaultFlags
Also Improve:
 - LocalLog should not use NoSuchElementException for control flow (instead use ConcurrentSkipListMap)

patch by Benedict; reviewed by Aleksey Yeschenko for CASSANDRA-20886

 - JournalAndTableKeyIterator not merging in consistent order
2025-09-04 16:40:42 +01:00
Benedict Elliott Smith a813a51f7c Improve Observability:
- Track all active Coordinations
 - Refactor Replica/Coordinator metrics and report Coordinator exhausted/preempted/timeout
 - DurabilityQueue metrics and visibility
Also Fix:
 - WaitingState can get cause distributed stall when asked to wait for CanApply if not yet PreCommitted; track separate querying state and advance this to the next achievable state rather than the desired final state
 - Stalled coordinators should not prevent recovery
 - Edge case with fetch unable to make progress when pre-bootstrap and all peers have GC'd
 - Dependency initialisation for sync points across certain ownership changes
 - SyncPoint propagation may not include all of the epochs required on the receiving node for ranges they have lost but not closed, and receiving node does not validate them
 - Stable tracker accounting with LocalExecute
 - Do not prune non-durable APPLIED as must be reported in dependencies until durably applied (so as not to break recovery)
 - Ensure we cannot race with replies when initiating Coordination
 - ProgressLog does not guarantee to clear home or waiting states when erased or invalidated by compaction
 - WaitingState on non-home shard cannot guarantee progress once home shard is Erased
 - WaitingOnSync handles retired ranges incorrectly
Also Improve:
 - Standardise failure accounting, use null to represent single reply timeouts
 - BurnTest record/replay to/from file

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20878
2025-09-02 18:47:46 +01:00
Benedict Elliott Smith fdff319739 Accord fixes:
- Fix erroneous call to registerWithDelay with absolute deadline
 - ExecuteSyncPoint should discount votes from unbootstrapped replicas
 - Bootstrap no longer needs to first ensure durability (now ExecuteSyncPoint discounts votes from unbootstrapped replicas)
 - Progress stall with home shard stopping before Stable is propagated to all shards
 - Only upgrade Durability.HasPhase if we have queried all shards
 - Incorrectly inferring Durability in CheckStatus.finish
 - Incorrectly inferring/propagating stable from fast unstable reply; clarify to prevent further mistakes
 - MaxDecidedRX should track separate hlc bounds for filtering non-RX dependencies
 - minGcBefore.hlc() can move backwards across epochs, even if each shard moves forwards; must track minHlc directly
 - slowTimeout init in ExecuteTxn.LocalExecute
 - TxnId.parse for RV
Also improve:
 - Don't query recovery state if fast path durably decided
 - Support deferred partial dep deserialisation
 - Support both orientations of KeyDeps/RangeDeps
 - Support partialDeps as ByteBuffer
Also improve in Cassandra:
 - Deps serialization and Journal skipping
 - Don't inflate when reading from cache for CommandsForRanges

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20847
2025-08-19 15:20:26 +01:00
Alex Petrov 2de6078289 Improve / simplify topology reporting on startup
Patch by Alex Petrov; reviewed by Benedict Elliott Smith for CASSANDRA-20822
2025-08-14 09:39:22 +02:00
Benedict Elliott Smith 81bc18ad63 Enrich Durability with each phase, so we can both prune unapplied dependencies to mitigate replicas that are behind causing Deps growth,
and more reliably avoid initialising recovery progress log state of transactions that cannot yet make progress
Also fix:
 - Harden AccordExecutor state cleanup to failures
 - Handle SAVING state in AccordCache.tryEvict, as now possible to save for reasons besides eviction so normal to both be in evict queue and saving
 - Infer invalid in MaybeRecover and FetchData
 - MaybeRecover sometimes aborts before home shard knows outcome
 - Epoch sync with VisibilitySyncPoint
 - Retired implies synced
 - Don't interpret force repair as excluding nodes from Accord sync conditions
 - TxnData.without
Also improve:
 - Add Topology.removedNodes
 - If Durability implies we can fetch a status, update the waiting state to fetch it
 - DurableBefore debug table should have searchable txnId

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20832
2025-08-13 11:10:18 +01:00
Benedict Elliott Smith 7b12404a4e Avoid cache modification reentrancy when cancelling loads
Also fix:
 - Catch exceptions thrown by Task.cleanupExclusive to ensure we do not corrupt SequentialExecutor state
 - ConcurrentModificationException with CommandStore.waitingOnSync
 - Exclude promisedHlc that are in the future, even if not equal to Long.MAX_VALUE
 - Filter CFK on load as not expected to be up to date (for later on demand filtering validation)

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20821
2025-08-07 12:45:05 +01:00
Benedict Elliott Smith 46bda174d5 Bootstrap must first wait for a quorum to apply the sync point to ensure the DurableBefore Majority condition holds transitively,
since later quorums may include the bootstrapping node which does not participate in the durability of preceding transactions
Also Improve:
 - Apply MaxDecidedRX filtering to CommandsForKey RX dependencies
 - Optimise AbstractRanges.sliceMinimal (burn test hotspot)
 - Don't start shard schedulers on topology changes if not already started
 - Only registerTransitive if waitingOnSync
 - Reserve DurabilityRequest until ShardDurability is started
 - Don't notify progress log if stopped
 - Remove duplicated CFK unmanaged filtering
Also fix:
 - Edge case in notification across bootstrap boundary by resubmitting Unmanaged to be recomputed
 - Serialization of CommandsForKey.TxnInfo.missing() collection when non-identity flag bits are present

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20811
2025-08-04 08:41:24 +01:00
Benedict Elliott Smith f02020f06d Improve ProgressLog:
- Schedule a fallback timeout for active requests to ensure progress with lost callbacks
 - Clear active task for a txnId when new RunInvoker is registered
 - Consult DurableBefore prior to invoking recovery
 - Support user invoked reset of a command, clearing any active work and requeueing it
 - (Testing): Treat progress log for RX as recurring tasks for burn test termination
Also:
 - Add TxnOps RECOVER, FETCH, RESET_PROGRESS_LOG

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20815
2025-08-03 15:16:00 +01:00
Benedict Elliott Smith 4102ea13e5 Fix CFK restore after replay:
- Remove from CFK any unapplied transactions we know cannot apply
 - Force notification of waiting commands in CFK on replay
Also fix:
 - Don't truncateWithOutcome if pre bootstrap or stale
 - Fix RangeDeps.without(RangeDeps)
 - Fix InMemoryCommandStore replay bug with clearing DefaultLocalListeners
 - Ensure SaveStatus and executeAt are updated together to prevent corruption via expunge
Improve:
 - Inform home shard that command is decided if we cannot execute, to avoid recovery contention
 - Don't recover sync points on the fast path
 - Don't calculate recovery info for RX (since we don't use it anymore, so no need to do the work)

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20797
2025-07-28 13:32:58 +01:00
David Capwell e48d0dcd2c Journal.TopologyUpdate should not store the local topology as it can be inferred from the global on
patch by David Capwell; reviewed by Benedict Elliott Smith for CASSANDRA-20785
2025-07-24 18:51:24 -07:00
Benedict Elliott Smith 49b99c9319 Fix DurableBefore updates:
- DurableBefore.fullyContainedIn should compare txnId
Also fix:
 - Messages with nullable state should check if they are cancelled after reading the state but before using it
 - Don't snapshot during replay
 - CFK.updateRedundantBefore incorrectly updating mayExecute and sharing byId in some cases
 - Refine GC with global durability bound
 - Fix JournalGCTest

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20786
2025-07-24 20:54:35 +01:00
Benedict Elliott Smith fbe12e6291 Accord Query Tracing
Also improve:
 - Metric listeners

patch by Benedict; reviewed by David Capwell for CASSANDRA-20773
2025-07-24 20:20:17 +01:00
Alex Petrov 53eb2fdac8 Improve GC testing; fix durability startup order
Patch by Alex Petrov; reviewed by Benedict Elliott Smith for CASSANDRA-20767
2025-07-23 14:59:12 +02:00
Benedict Elliott Smith 54e39a90b0 Limit replay to those records not durably persisted to both command store and data store
Also fix:
 - Limit truncation to TruncatedApplyWithOutcome until data is persisted durably to local store
 - IntervalUpdater not invoking super.close()
 - Do not invoke preRunExclusive without holding lock
 - IntervalUpdater not correctly initialise BranchBuilder.inUse
 - AccordExecutor should notify if more work on unlock of caches
 - Relax paranoid CFK validation during restart
Also improve:
 - Flush logs before System.exit
 - Start/stop progress log explicitly
 - Limit progress log concurrency
 - Clear heavy fields in some messages once processed

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20780
2025-07-23 12:19:06 +01:00
Benedict Elliott Smith 0e9f0fab78 Improve:
- PreLoadContext descriptions
 - Introduce LoadKeysFor so we can avoid loading range transactions except where necessary

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20758
2025-07-17 07:21:04 +01:00
Benedict Elliott Smith 37b6ade9c9 Accord: Fix minDecidedId calculation
Also fix:
 - slowCoordinatorDelay calculation for locally truncated command throws ISE
 - Bad cast of Truncated during replay
 - Don't throw IllegalStateException in Invariants.expect if accord.testing == false
 - Replay of empty segment throws NPE
Also improve:
 - Support tracing of recovery and home progress

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20771
2025-07-16 19:37:26 +01:00
Ariel Weisberg e6cf2132ab Add testing of consensus live migration to simulator
Patch by Ariel Weisberg; Reviewed by Benedict Elliott Smith for CASSANDRA-20587
2025-07-16 11:31:54 -04:00
Benedict Elliott Smith e8bd2319f4 Accord Fixes:
- Don't try to update metrics when no TxnId (e.g. GetMaxConflict)
 - maybeExecuteImmediately did not guarantee mutual exclusivity
 - Cancellation of a running 'plain' task could corrupt AccordExecutor state
 - GetLatestDeps message serializer
 - txn_blocked_by StackOverflowError
 - Not updating CommandsForKey in all cases on restart
Also Improve:
 - TableId.from/toString
 - Route toString methods
 - Tracing coverage of FetchRoute
 - Replay command store parallelism

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20763
2025-07-14 23:22:45 +01:00
Benedict Elliott Smith fd2e11f0d2 Accord Fixes:
- WatermarkCollector should not report same closed/retired epoch N times
 - AccordSyncPropagator can merge pending requests and back-off retries
 - AccordCommandLoader should notify listeners
 - AccordSegmentCompactor should estimate number of keys to ensure bloom filters work
 - txn_blocked_by table should report what it can, not throw IllegalStateException
 - Permit uncompressed system tables

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20754
2025-07-11 15:19:36 +01:00
David Capwell 8289bb4cde Accord: Topology serializer has a lot of repeated data, can dedup to shrink the cost
patch by David Capwell; reviewed by Benedict Elliott Smith for CASSANDRA-20715
2025-07-10 20:06:02 -07:00
Benedict Elliott Smith cba4208568 Standardise Replay logic to ensure SafeCommandStore.update is called
Also Fix:
 - Initialise home state when calling waiting() if not already initialised
 - Don't reportClosed/reportRetired for epochs that are already closed/retired
Also Improve:
 - Implement waitForQuiescence in AccordExecutor
 - Permit replay parallelism

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20750
2025-07-08 21:23:47 +01:00
Benedict Elliott Smith a866f92fcf Improve:
- Journal debugging vtable support
 - Background task tracing support
Fix:
 - HLC_BOUND only valid for strictly lower HLC
 - HAS_UNIQUE_HLC can only be safely computed if READY_TO_EXECUTE
 - Break recursion in CommandStore.ensureReadyToCoordinate
 - Fix find intersecting shard scheduler
 - Separate adhoc ShardScheduler from normal to avoid overwriting
 - Should still use execution listeners to detect invalid reads for certain transactions even with dataStoreDetectsFutureReads

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20746
2025-07-04 09:08:50 +01:00
Benedict Elliott Smith c9e52399e6 Fix:
- Lock inversion when restarting durability for erased sync point
 - Initialise durability cycle start time
Improve:
 - Improve durability reporting
 - Timeout durability requests
 - DurabilityQueue concurrency should limit only until quorum is achieved
 - Some exceptions that may be thrown when starting coordination may not be propagated

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20328
2025-07-02 14:09:45 +01:00
Benedict Elliott Smith 0a7797ca85 Fix:
- Cannot shrink CommandsForKey if loading pruned
 - NoSpamLogger to suppress AccordSyncPropagator repeats
 - Minor performance improvement to BTree.Subtraction
 - EphemeralReads should retry in a later epoch if replication factor changes
 - Fix no local epoch for NotAccept
 - Invalidate a command with no route but for which we know we own some key that has applied locally
 - Don't pre-merge existing DurableBefore, to reduce duplicate/redundant persistence
 - Misc purging bugs and improve testing of purging

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20739
2025-06-29 12:59:09 +01:00
Benedict Elliott Smith 115c553984 Follow-up to CASSANDRA-20726:
- Fix shouldCleanup handling of erase/expunge
 - Fix CommandChange handling of minUniqueHlc being cleared
 - Don't clear minUniqueHlc when fast applying; instead simply validate !isWaiting

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20726
2025-06-26 20:31:19 +01:00
Benedict Elliott Smith fadc64c17d (Accord) Fix:
- Attempt to fix CommandsForKey StackOverflowError (presumed to be reachable via SaveStatus->InternalStatus map returning null)
 - Bound recursion with SafeCommandStore.tryRecurse()
 - IndexOutOfBoundsException in CINTIA checkpoint list encoding bounds logic
 - Maintain MaxDecidedRX to save majority of work when deciding RX that are newer than those we have previously agreed
 - Introduce IntervalBTree and use in CommandsForRanges to limit time spent in critical section when there are millions of RX

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20727
2025-06-25 15:07:27 +01:00
Benedict Elliott Smith 6d303e6843 Improve:
- Introduce SequentialAgentExecutor
 - ExecuteEphemeralRead.LocalExecute (matching ExecuteTxn.LocalExecute)
 - remove AgentExecutor (agent() only used as implementation detail)
 - Skip CommandStore/CommandsForKey on read or apply, when safe to do so
 - Implement maybeExecuteImmediately
 - Faster maxTimestamp
Fix:
 - Marking vestigial without knowing all covering keys
 - Incorrect size in WaitingOn.none
 - Cleanup RX that are not known but are no longer needed, due to being defunct
 - Home should not abort because of local truncation; may still be incomplete on another shard
 - Invalidate infinite loop due to interpreting Vestigial as a possible decision (as though it were another Truncated state)
 - Known.isTruncated reporting incorrect answer in some cases, leading to infinite RecoverWithRoute loops as not slicing to correct subset and some shards are truncated and reject the deps collection
 - BurnTest slowCoordinatorDelay should grow with retryCount
 - NotAccept should check both ballot and saveStatus; PreCommitted or later can be propagated by Apply that has an earlier ballot
 - Handle awaiting locally retired epoch
 - Fix propagate low epoch of sync points
 - Fix GetEphemeralReadDeps.reduce NPE
 - Don't use tombstones to ERASE journal entries, as want to produce an Erased SaveStatus until EXPUNGE

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20726
2025-06-25 15:01:54 +01:00
Alex Petrov 1350082a13 Avoid re-serializing all-equivalent topologies
patch by Alex Petrov; reviewed by Benedict for CASSANDRA-20721
2025-06-19 12:40:38 +01:00
Benedict Elliott Smith 7ef2ccd4a1 Erase should consistently erase all content
Also Fix:
 - slowCoordinatorDelay should bound its start point, and log more detail if its expectations are breached
 - Erased SaveStatus can be reported for all queried owned participants on a replica (the saved participants have been erased)

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20722
2025-06-19 12:40:38 +01:00
Benedict Elliott Smith 464a4f9d79 Accord Fixes:
- AccordJournal should not attempt to construct expunged commands
 - ready/notReady logic can break if we receive a partial Route that does not cover the local store
 - Invariant.require -> TopologyRetiredException
 - validate min/max in TopologyManager.preciseEpochs
Improve:
 - ExecuteSyncPoint should send Apply

patch by Benedict; reviewed by Alex Petrov for CASSANDRA-20713
2025-06-16 11:42:12 +01:00
Benedict Elliott Smith 1b78bbdc35 Fix:
- Do not query local topology when deciding what keys to fetch to avoid TopologyRetiredException
 - Ensure we propagate information back to the requesting CommandStore by using the store id to ensure it is included
 - BurnTest topology fetching was broken by earlier patch
 - Topology callbacks were not being invoked as we were not calling .begin()
 - Topology mismatch failure during notAccept phase was not being reported due to CoordinatePreAccept already having isDone==true

patch by Benedict; reviewed by David Capwell for CASSANDRA-20711
2025-06-12 11:41:59 +01:00