Commit Graph

31745 Commits

Author SHA1 Message Date
Alan Wang 8fda60880b CEP 45 - Fix tracked SSTable import/transfer bugs
- Filter interval-tree false positives: skip SSTables that intersect a
  shard range but contain no partitions within it, precomputing and
  reusing partition positions per SSTable
- Register PendingLocalTransfer once in finished() instead of per-SSTable
  in received(), fixing an assertion failure when streaming >1 SSTable
- Guard against null currentWriter in RangeAwareSSTableWriter.setOpenResult
- Schedule local cleanup before notifyFailure so cleanup always runs on
  the failure path, and remove completed transfers from the local map
- Adds dtests for the interval-tree false positive and multi-SSTable import
  cases.

Patch by Alan Wang; Reviewed by Blake Eggleston for CASSANDRA-21470
2026-07-22 11:51:48 -07:00
Blake Eggleston 982f3e3032 ninja - fix MutationJournalReplayTest.testReplayFlushed 2026-06-29 09:48:12 -07:00
Blake Eggleston f8eb131aa4 ninja - don't use non-durable keyspace params for witnesses 2026-06-23 14:54:50 -07:00
Blake Eggleston e66fb9eb0d CEP-45: Lost witness marker race
Don't truncate journal segments until witnessed offsets they contain are
flushed. Also moves MutationTrackingService startup to after the commit
log is replayed

Patch by Blake Eggleston; Reviewed by Francisco Guerrero for CASSANDRA-21443
2026-06-20 19:39:34 -07:00
Ariel Weisberg 595b158958 Paxos support for live migration to mutation tracking
During mutation tracking migration (tracked <-> untracked), the per-range
migration state must be consulted for every routing decision. Before this
change, all Paxos V1 and V2 paths used the static keyspace-level
replicationType().isTracked() check, which does not reflect per-range
migration state and produces incorrect routing decisions during migration.

Coordinator-side routing: Replace all static isTracked() checks with
MigrationRouter calls across StorageProxy (commitPaxos, sendCommit,
isTrackedKeyspaceRequiringPaxosCommitForwarding, checkAndForwardCasIfNeeded,
checkAndForwardConsensusReadIfNeeded), PaxosCommit (constructor,
isTrackedKeyspaceRequiringForwarding), PaxosCommitAndPrepare,
PaxosPrepare (start + isTracked field), PaxosPrepareRefresh, and
PaxosState truncation acknowledgment.

Handler-side validation: Add migration state validation to four Paxos
replica handlers that receive messages carrying mutations or tracked reads:
PaxosCommit.RequestHandler (direct V1/V2 commits), PaxosPrepare.RequestHandler
(V2 prepare with tracked read), PaxosCommitAndPrepare.RequestHandler
(combined commit+prepare), and PaxosPrepareRefresh.RequestHandler (refresh
commits). Each uses the conditional-fetch pattern from
AbstractMutationVerbHandler.checkReplicationMigration: compare the
coordinator routing decision against the handler MigrationRouter result,
fetch only on mismatch when the coordinator epoch is ahead (handler is
behind and needs to catch up), throw CoordinatorBehindException when the
coordinator epoch is behind.

Coordinator-side commit retry: Add commit-level COORDINATOR_BEHIND retry
in Paxos.cas() (V2) and commitPaxos() (V1). When replicas reject a commit
due to migration state mismatch, ResponseVerbHandler.maybeFetchLogs()
catches up the coordinator synchronously before delivering the failure.
The retry re-creates the commit with fresh MigrationRouter routing. This
retries only the commit phase, not the entire prepare+propose protocol.

Stale mutation ID reconciliation: Commits saved in system.paxos may have
a mutation ID from when the keyspace was tracked. When replayed after
migration to untracked (via PaxosPrepareRefresh, PaxosCommitAndPrepare,
sendCommit, or commitPaxos), the stale ID must be stripped to avoid
Keyspace.apply() rejecting the mutation. Uses Commit.withMutationId() to
reconcile in all four replay paths.

Forward handlers: Forwarding is harmless -- the receiving replica
re-executes the full CAS/read with its own fresh routing decisions, so no
migration validation is needed at the forward boundary itself. Removed the
"reject if keyspace not tracked" guards from CasForwardHandler and
ConsensusReadForwardHandler (forwarding is now valid in either direction).
Replaced unconditional fetchLogFromPeerOrCMS with the conditional-fetch
pattern in Paxos2CommitForwardHandler, PaxosCommitForwardHandler,
PrepareRefreshForwardHandler, and PaxosCommitAndPrepare.RequestHandler
(unconditional fetch added unnecessary latency on the no-mismatch case).

PaxosCommit failure tracking: Added super.onFailure() call to
PaxosCommit.onFailure() so FailureRecordingCallback.failureResponses is
populated, enabling failureReasonsAsMap() to return actual failure reasons.
This was required for the V2 commit retry to detect COORDINATOR_BEHIND
in MaybeFailure.failures.

PaxosCommit hint suppression: Tracked mutations must not be written as
hints because hint replay routes through Keyspace.applyInternalTracked()
based on the mutation ID presence, which fails after migration to untracked.
Guard submitHint with !isTracked() -- tracked mutations use
MutationTrackingService for retries, not the hint system.

MigrationRouter null safety: Replace getKeyspaceMetadata() (throws
NoSuchElementException on missing keyspace) with
maybeGetKeyspaceMetadata().orElse(null) at four call sites so the existing
null guards actually protect against concurrent keyspace drops.
2026-06-10 10:18:40 -07:00
Aleksey Yeshchenko e1ae7d654a Fix now-incorrect Verb reference in MutationTrackingService 2026-05-20 12:11:48 +01:00
Francisco Guerrero c6814f3c69 CEP-45: Background reconciliation - replica
patch by Francisco Guerrero; reviewed by Blake Eggleston for CASSANDRA-20378
2026-05-18 10:49:10 -07:00
Blake Eggleston 16bb95fa15 CEP-45: Implement independent mutation tracking versioning
patch by Blake Eggleston and Aleksey Yeschenko; reviewed by Aleksey
Yeschenko and Blake Eggleston for CASSANDRA-21328

Co-authored-by: Aleksey Yeschenko <aleksey@yeschenko.com>
Co-authored-by: Blake Eggleston <blake@ultrablake.com>
2026-05-14 12:34:16 +01:00
Aleksey Yeshchenko e982cf69b4 Fix MutationId class hierarchy and related maps lookup issues
patch by Aleksey Yeschenko; reviewed by Ariel Weisberg for
CASSANDRA-21366
2026-05-12 16:16:51 +01:00
Ariel Weisberg a79d34a2c0 CEP-45: BRR does tracked writes during migration to mutation tracking
During migration from untracked to tracked replication, blocking read
repair (BRR) continues to run because mutation tracking lacks sufficient
initialized state to provide monotonic reads for pending ranges. However,
BRR was previously bypassing mutation tracking entirely — read repair
mutations were sent as untracked writes via READ_REPAIR_REQ, which meant
they were invisible to the mutation journal. This is unsafe because the
migration repair that completes the transition assumes all writes after it
started are tracked, so that tracked reads can safely begin afterward.

Route BRR writes through TrackedWriteRequest.perform() when
MigrationRouter.shouldUseTrackedForWrites() indicates the token is
migrating. This gives each read repair mutation a proper MutationId and
records it in the mutation journal, ensuring the migration invariant holds.

Key changes:
- Remove the isReadRepair flag from Mutation and all special-case bypasses
  that let read repair skip mutation tracking validation and routing
- Add repairViaTrackedWrite() to BlockingReadRepair which sends each
  per-replica mutation as an independent tracked write with retry logic
  for migration races (RetryOnDifferentSystemException/CoordinatorBehindException)
- Introduce WriteCallback interface (replacing Runnable) on write response
  handlers so tracked write completion can be observed without races
- Make tracked→untracked instant in AlterSchema by skipping migration
  state entirely — tracked writes are already quorum writes so untracked
  reads are strictly less demanding. Reverting an in-progress
  untracked→tracked migration cleans up the now-unnecessary state.
- Add RepairedBlockingViaTrackedWrite metric to observe BRR-via-tracked path
- Add pauseRegularPriorityForTesting() to ActiveLogReconciler to allow
  tests to suppress background reconciliation while keeping high-priority
  (tracked read) reconciliation active
- Add MutationTrackingReadRepairTest covering BRR behavior across all
  migration phases with both point reads and range scans
2026-04-28 11:15:49 -04:00
Aleksey Yeshchenko 9d336f67a3 Ninja-fix checkstyle import warnings 2026-04-21 15:16:18 +01:00
Aparna Naik a5116b93a6 CEP-45: Incremental Repair integration w/Mutation Tracking
Implement mutation tracking repair as a new repair task that replaces
Merkle tree validation and streaming for tracked keyspaces. Instead of
building hash trees and comparing data, MutationTrackingSyncCoordinator
sends MT_SYNC_REQ to all participants to collect their witnessed offsets,
then waits for background offset broadcasts to confirm all replicas have
reconciled to those target offsets.

Key changes:

- Add MutationTrackingIncrementalRepairTask that creates per-range
  MutationTrackingSyncCoordinator instances and blocks until all
  shards reach the target reconciled offsets or timeout.

- Add MT_SYNC_REQ/MT_SYNC_RSP verbs and MutationTrackingSyncRequest/
  MutationTrackingSyncResponse messages for the repair protocol to
  establish a happens-before relationship between repair start and
  offset collection.

- RepairCoordinator.create() factory method snapshots TCM state to
  decide whether to use mutation tracking repair and flips incremental
  to false (skipping anti-compaction) when MT is active without
  migration.

- Support mutation tracking migration: during untracked->tracked
  migration, run incremental repair first (for pre-migration data),
  then MT sync. KeyspaceMigrationInfo validates that repair ranges
  don't partially overlap pending migration ranges and routes
  streaming/SSTable finalization through the correct tracked vs
  untracked path.

- Temporarily route read repair mutations through the untracked write
  path during migration by adding isReadRepair flag to Mutation and
  bypassing migration routing checks in ReadRepairVerbHandler and
  CassandraKeyspaceWriteHandler. This is a stopgap; CASSANDRA-21252
  will roll back this approach and handle read repair properly.

- Add offset collection APIs to CoordinatorLog, Node2OffsetsMap, and
  Shard for computing union and intersection of witnessed offsets
  scoped to specific participant host IDs (supporting --force with
  dead node exclusion).

- Add configurable mutation_tracking_sync_timeout (default 2m) with
  JMX get/set on StorageServiceMBean.

- Fix ActiveRepairService to use tryFailure() instead of setFailure()
  to avoid double-completion exceptions during concurrent repair
  failures.

Co-Authored-By: Ariel Weisberg <aweisberg@apple.com>
2026-04-14 12:00:26 -07:00
Blake Eggleston 7ef7c675d6 rebase - fix secondary index double free bug 2026-04-13 15:05:21 -07:00
Blake Eggleston e7524acfec rebase - fix CEP-45: Support host replacement with tracked keyspaces 2026-04-13 10:43:50 -07:00
Blake Eggleston 5ab65fbc68 rebase - fix Mutation tracking journal integration, read, and write path 2026-04-13 10:12:12 -07:00
Blake Eggleston f01cbb1dd7 rebase - fix Mutation tracking journal integration, read, and write path 2026-04-13 10:09:43 -07:00
Blake Eggleston 1c10de236f CEP-45: Add feature flag for Mutation Tracking
patch by Caleb Rackliffe; reviewed by Blake Eggleston and Sam Tunnicliffe for CASSANDRA-20926

Co-authored-by: Blake Eggleston <blake@ultrablake.com>
Co-authored-by: Caleb Rackliffe <calebrackliffe@gmail.com>
2026-04-09 16:46:57 -07:00
Ariel Weisberg b11122f23b SERIAL read/write support for Witnesses and Mutation Tracking
Patch by Ariel Weisberg; Reviewed by Aleksey Yeschenko for CASSANDRA-20953
2026-04-09 16:46:57 -07:00
Abe Ratnofsky 06e7dee9f8 CEP-45: Full Repair Support for Tracked Keyspaces
Tracked keyspaces cannot accept new data without first registering it in
the log. Any unreconciled data that isn't present in the log will break
read monotonicity, since mutation tracking uses a single data read and
can only read reconcile mutation IDs that are present in the log.

Full repair sync tasks also deliver data to replicas, and require
integration with the log just like imports do. The general design of this
integration is to give repair SyncTasks the same two-phase commit as
import transfers, where we stream SSTables to a pending directory, then
once sufficient streams complete successfully, we "activate" those
streams and move them out of the pending directory and into the live set.

patch by Caleb Rackliffe; reviewed by Abe Ratnofsky for CASSANDRA-21066

Co-authored-by: Caleb Rackliffe <calebrackliffe@gmail.com>
Co-authored-by: Abe Ratnofsky <abe@aber.io>
2026-04-09 16:46:37 -07:00
Aparna Naik 861b4e82a9 Add support for counters to mutation tracking
patch by Aparna Naik; reviewed by Aleksey Yeschenko for CASSANDRA-20959
2026-04-09 16:46:37 -07:00
Blake Eggleston d5b5fd7f77 CEP-45: Replication type migration
Patch by Blake Eggleston; Reviewed by Ariel Weisberg for CASSANDRA-20388
2026-04-09 16:46:37 -07:00
Aparna Naik 5b3784031f CEP-45: Add virtual tables for Mutation Tracking
patch by Aparna Naik; reviewed by Abe Ratnofsky and Blake Eggleston for CASSANDRA-20987
2026-04-09 16:45:32 -07:00
Aparna Naik 5854400649 CEP-45: Add metrics for Mutation Tracking
patch by Aparna Naik; reviewed by Abe Ratnofsky and Blake Eggleston for CASSANDRA-20986
2026-04-09 16:45:32 -07:00
Abe Ratnofsky 407e19021b CEP-45: Bulk transfer
patch by Abe Ratnofsky; reviewed by Caleb Rackliffe and Blake Eggleston for CASSANDRA-20383
2026-04-09 16:45:32 -07:00
Blake Eggleston 129cbf3f75 CEP-45: Fix IN queries for mutation tracking
Patch by Blake Eggleston; Reviewed by Abe Ratnofsky for CASSANDRA-20375
2026-04-09 16:45:32 -07:00
Blake Eggleston 4d7815e2e8 CEP-45: Add support for unlogged batches
Patch by Blake Eggleston; Reviewed by Abe Ratnofsky for CASSANDRA-20957
2026-04-09 16:45:32 -07:00
Blake Eggleston e51c0d2346 Fix param type - from query forwarding I think 2026-04-09 16:45:32 -07:00
Blake Eggleston 19be8aeac2 CEP-45: Add mutation tracking support for secondary index reads
This patch enables mutation tracking for queries using secondary indexes (both
legacy 2i and SAI). Key changes include the addition of the MultiStepSearcher
interface, which allows existing index implementations to iterate over matches
and filter augmented data, proper Memtable snapshotting, and the integration of
these in PartialTrackedIndexRead.

patch by Blake Eggleston; reviewed by Aleksey Yeschenko and Caleb Rackliffe for CASSANDRA-20374

Co-authored-by: Blake Eggleston <blake@ultrablake.com>
Co-authored-by: Caleb Rackliffe <calebrackliffe@gmail.com>
Co-authored-by: Aleksey Yeschenko <aleksey@apache.org>
2026-04-09 16:45:32 -07:00
Caleb Rackliffe 5a94a5a0fd Enable range reads for MultiNodeTableWalkWithMutationTrackingTest and document failure modes for known problematic seeds
patch by Caleb Rackliffe; reviewed by Blake Eggleston for CASSANDRA-20898
2026-04-09 16:45:32 -07:00
Aleksey Yeschenko d34e758e4b Truncate mutation journal as logs get reconciled
patch by Aleksey Yeschenko; reviewed by Alex Petrov for CASSANDRA-20710
2026-04-09 16:45:32 -07:00
Caleb Rackliffe def980e475 Disable mutation tracking by default in CassandraGenerators
patch by Caleb Rackliffe; reviewed by Blake Eggleston for CASSANDRA-20944
2026-04-09 16:45:32 -07:00
Blake Eggleston 4215cfd2aa CEP-45: Support host replacement with tracked keyspaces
Patch by Blake Eggleston; Reviewed by Abe Ratnofsky for CASSANDRA-20891
2026-04-09 16:45:32 -07:00
Alex Petrov a7b431d683 CEP-45: Integrate Mutation Journal with Memtable flush tracking
* Tracking of Memtable -> SSTable flushes in Mutation Journal segments
  * Replay of Mutation Journal segments that were not fully flushed to SSTables
  * Distinguish between CommitLog and MutationJournal offsets
  * Effectively adds support for node bounces

Patch by Alex Petrov; reviewed by Aleksey Yeschenko for CASSANDRA-20919
2026-04-09 16:45:32 -07:00
Ariel Weisberg 1e036cf620 Initial witness non-serial single partition read/write path
Patch by Ariel Weisberg; Reviewed by Abe Ratnosfky for CASSANDRA-20930
2026-04-09 16:45:32 -07:00
Aleksey Yeschenko 9d856f2c08 Implement Shard and CoordinatorLog metadata durability
patch by Aleksey Yeschenko; reviewed by Abe Ratnofsky for CASSANDRA-20882
2026-04-09 16:42:44 -07:00
Blake Eggleston 9dbafa812d Single-partition read fixes:
- filter augmenting mutations and add comment explaining why we don't exclude reconciled mutations when augmenting
- propagate exceptions during acknowledgeReconcile
- fix UnreconciledMutations handling of single key bounds
- fix single offset remove bug

patch by Blake Eggleston; reviewed by Caleb Rackliffe for CASSANDRA-20830
2026-04-09 16:42:44 -07:00
Caleb Rackliffe 416c1292e4 Enable single-partition AST fuzz tests w/ mutation tracking
patch by Caleb Rackliffe; reviewed by ? for CASSANDRA-20830
2026-04-09 16:42:44 -07:00
Aleksey Yeschenko 9676c0eaeb Implement unified log reconciliation
patch by Aleksey Yeschenko; reviewed by Blake Eggleston for
CASSANDRA-20729

Co-authored-by: Aleksey Yeschenko <aleksey@apache.org>
Co-authored-by: Blake Eggleston <blake@ultrablake.com>
2026-04-09 16:35:32 -07:00
Caleb Rackliffe c1bb86ab60 Initial round of post-rebase (mostly Accord-related) fixes 2026-04-09 16:34:18 -07:00
Caleb Rackliffe 6c26813c2a Separate TestParams by use-case (Accord vs. Mutation Journal) 2026-04-09 16:34:18 -07:00
Blake Eggleston 14a743f8f7 CEP-45: Fix ALLOW FILTERING queries for mutation tracking
Patch by Blake Eggleston; Reviewed by Aleksey Yeschenko for CASSANDRA-20555
2026-04-09 16:34:18 -07:00
Abe Ratnofsky 65caf3f58b Fully reconciled SSTable promotion
patch by Abe Ratnofsky; reviewed by Ariel Weisberg, Blake Eggleston for CASSANDRA-20381
2026-04-09 16:34:18 -07:00
Abe Ratnofsky 51e63f0ff3 Add mutation tracking summary to SSTables
Patch by Abe Ratnofsky; reviewed by Ariel Weisberg, Blake Eggleston for CASSANDRA-20336
2026-04-09 16:34:18 -07:00
Aleksey Yeschenko fa017c6334 Implement coordinator log offset broadcasting
patch by Aleksey Yeschenko; reviewed by Blake Eggleston for CASSANDRA-20576
2026-04-09 16:34:18 -07:00
Abe Ratnofsky c18ca7afc5 CEP-45: Query forwarding
Patch by Abe Ratnofsky; Reviewed by Blake Eggleston for CASSANDRA-20309
2026-04-09 16:34:18 -07:00
Blake Eggleston c71f976955 Mutation tracking journal integration, read, and write path
Patch by Blake Eggleston & Aleksey Yeshchenko
Reviewed by Blake Eggleston, Aleksey Yeshchenko, & Abe Ratnofsky
 for CASSANDRA-20304, CASSANDRA-20305, & CASSANDRA-20308, CASSANDRA-20373

Co-authored-by: Blake Eggleston <blake@ultrablake.com>
Co-authored-by: Aleksey Yeschenko <aleksey@apache.org>
2026-04-09 16:34:18 -07:00
Aleksey Yeschenko b824304867 Introduce MutationJournal for coordinator logs
patch by Aleksey Yeschenko; reviewed by Blake Eggleston for
CASSANDRA-20353
2026-04-08 09:30:40 -07:00
Paulo Motta 73063437b6 Merge branch 'cassandra-5.0' into trunk 2026-04-08 11:17:44 -04:00
Paulo Motta 9500eb129b Backport Automated Repair Inside Cassandra (CEP-37)
Includes bug fixes and features:
- Improved observability in AutoRepair (CASSANDRA-20581)
- Stop repair scheduler if two major versions detected (CASSANDRA-20048)
- Safeguard Full repair against disk protection (CASSANDRA-20045)
- Stop AutoRepair monitoring thread upon shutdown (CASSANDRA-20623)
- Fix race condition in auto-repair scheduler (CASSANDRA-20265)
- Minimum repair task duration setting (CASSANDRA-20160)
- Preview_repaired auto-repair type (CASSANDRA-20046)
- Gate auto-repair behind cassandra.autorepair.enable JVM property
- Add cassandra.autorepair.check_min_version to gate minimum version enforcement
- Prevent auto-repair from running if any node is below 5.0.7
- Make system_distributed auto-repair schema conditional on feature being enabled
- Add user-friendly errors for disabled auto-repair and schema incompatibility

patch by Paulo Motta; reviewed by Andy Tolbert, Jaydeepkumar Chovatia for CASSANDRA-21138

Co-Authored-By: Andy Tolbert <andy_tolbert@apple.com>
Co-Authored-By: Chris Lohfink <clohfink@netflix.com>
Co-Authored-By: Francisco Guerrero <frankgh@apache.org>
Co-Authored-By: Himanshu Jindal <himanshj@amazon.com>
Co-Authored-By: Jaydeepkumar Chovatia <jchovati@uber.com>
Co-Authored-By: Kristijonas Zalys <kzalys@uber.com>
Co-Authored-By: jaydeepkumar1984 <chovatia.jaydeep@gmail.com>
2026-04-08 10:53:41 -04:00
mck d2bdb2ffa8
Merge branch 'cassandra-5.0' into trunk
* cassandra-5.0:
  Autogenerate the doc antora.yml
2026-04-08 15:24:07 +02:00