Skip to content

Commit 890ba2a

Browse files
committed
Merge branch 'cassandra-6.0' into trunk
2 parents b6f175b + 41cf614 commit 890ba2a

172 files changed

Lines changed: 4219 additions & 1305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.build/checkstyle.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,9 @@
5858
</module>
5959

6060
<module name="SuppressWithNearbyCommentFilter">
61-
<property name="commentFormat" value="checkstyle: permit this invocation"/>
62-
<property name="idFormat" value="blockPathToFile"/>
63-
<property name="influenceFormat" value="0"/>
64-
</module>
65-
66-
<module name="SuppressWithNearbyCommentFilter">
67-
<property name="commentFormat" value="checkstyle: permit this invocation"/>
68-
<property name="idFormat" value="blockToCases"/>
69-
<property name="influenceFormat" value="0"/>
61+
<property name="commentFormat" value="checkstyle: permit this invocation"/>
62+
<property name="idFormat" value="blockInstantNow|blockPathToFile|blockToCases"/>
63+
<property name="influenceFormat" value="0"/>
7064
</module>
7165

7266
<module name="RegexpSinglelineJava">

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Merged from 5.0:
1111

1212

1313
6.0-alpha2
14+
* Accord: Tail Latency Improvements (CASSANDRA-21361)
15+
* Artificial Latency Injection (CASSANDRA-17024)
16+
* Accord: Clean Shutdown/Restart, Rebootstrap, et al (CASSANDRA-21355)
1417
* Reduce memory allocations in SelectStatement.getQuery (CASSANDRA-21351)
1518
* Avoid allocation by getFunctions in SelectStatement.authorize (CASSANDRA-21347)
1619
* Avoid unit conversion in DatabaseDescriptor.getMaxValueSize() for every deserializing Cell (CASSANDRA-21295)

modules/accord

Submodule accord updated 151 files

src/java/org/apache/cassandra/concurrent/ExecutorLocals.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
public class ExecutorLocals implements WithResources, Closeable
3535
{
36-
private static final ExecutorLocals none = new ExecutorLocals(null, null);
36+
private static final ExecutorLocals none = new ExecutorLocals(null, null, false);
3737
private static final FastThreadLocal<ExecutorLocals> locals = new FastThreadLocal<ExecutorLocals>()
3838
{
3939
@Override
@@ -45,20 +45,23 @@ protected ExecutorLocals initialValue()
4545

4646
public static class Impl
4747
{
48-
protected static void set(TraceState traceState, ClientWarn.State clientWarnState)
48+
@SuppressWarnings("resource")
49+
protected static void set(TraceState traceState, ClientWarn.State clientWarnState, boolean eligibleForArtificialLatency)
4950
{
50-
if (traceState == null && clientWarnState == null) locals.set(none);
51-
else locals.set(new ExecutorLocals(traceState, clientWarnState));
51+
if (traceState == null && clientWarnState == null && !eligibleForArtificialLatency) locals.set(none);
52+
else locals.set(new ExecutorLocals(traceState, clientWarnState, eligibleForArtificialLatency));
5253
}
5354
}
5455

5556
public final TraceState traceState;
5657
public final ClientWarn.State clientWarnState;
58+
public final boolean eligibleForArtificialLatency;
5759

58-
protected ExecutorLocals(TraceState traceState, ClientWarn.State clientWarnState)
60+
protected ExecutorLocals(TraceState traceState, ClientWarn.State clientWarnState, boolean eligibleForArtificialLatency)
5961
{
6062
this.traceState = traceState;
6163
this.clientWarnState = clientWarnState;
64+
this.eligibleForArtificialLatency = eligibleForArtificialLatency;
6265
}
6366

6467
/**
@@ -82,7 +85,7 @@ public static WithResources propagate()
8285
public static ExecutorLocals create(TraceState traceState)
8386
{
8487
ExecutorLocals current = locals.get();
85-
return current.traceState == traceState ? current : new ExecutorLocals(traceState, current.clientWarnState);
88+
return current.traceState == traceState ? current : new ExecutorLocals(traceState, current.clientWarnState, current.eligibleForArtificialLatency);
8689
}
8790

8891
public static void clear()

src/java/org/apache/cassandra/config/AccordSpec.java renamed to src/java/org/apache/cassandra/config/AccordConfig.java

Lines changed: 98 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,28 @@
2222

2323
import com.fasterxml.jackson.annotation.JsonIgnore;
2424

25+
import accord.api.ProtocolModifiers.CleanCfkBefore;
26+
import accord.api.ProtocolModifiers.CoordinatorBacklogExecution;
27+
import accord.api.ProtocolModifiers.FastExecution;
28+
import accord.api.ProtocolModifiers.ReplicaExecution;
29+
import accord.api.ProtocolModifiers.SendStableMessages;
30+
import accord.primitives.TxnId;
2531
import accord.utils.Invariants;
2632

2733
import org.apache.cassandra.journal.Params;
2834
import org.apache.cassandra.service.accord.serializers.Version;
2935
import org.apache.cassandra.service.consensus.TransactionalMode;
3036

31-
import static org.apache.cassandra.config.AccordSpec.CatchupMode.NORMAL;
32-
import static org.apache.cassandra.config.AccordSpec.QueueShardModel.THREAD_POOL_PER_SHARD;
33-
import static org.apache.cassandra.config.AccordSpec.QueueSubmissionModel.SYNC;
34-
import static org.apache.cassandra.config.AccordSpec.RangeIndexMode.in_memory;
37+
import static org.apache.cassandra.config.AccordConfig.CatchupMode.NORMAL;
38+
import static org.apache.cassandra.config.AccordConfig.QueuePriorityModel.HLC_FIFO;
39+
import static org.apache.cassandra.config.AccordConfig.QueueShardModel.THREAD_POOL_PER_SHARD;
40+
import static org.apache.cassandra.config.AccordConfig.QueueSubmissionModel.SYNC;
41+
import static org.apache.cassandra.config.AccordConfig.RangeIndexMode.in_memory;
3542

36-
// TODO (expected): rename to AccordConf?
37-
public class AccordSpec
43+
public class AccordConfig
3844
{
3945
public volatile boolean enabled = false;
4046

41-
// TODO (expected): move to JournalSpec
4247
public volatile String journal_directory;
4348

4449
/**
@@ -107,6 +112,37 @@ public enum QueueSubmissionModel
107112
EXEC_ST
108113
}
109114

115+
public enum QueuePriorityModel
116+
{
117+
/**
118+
* All work is queued on a first-come first-serve basis.
119+
* Overload can lead to more rapid degradation, as later phases of the state machine are delayed
120+
* by the arrival of new work.
121+
*/
122+
FIFO,
123+
124+
/**
125+
* If the work has an associated TxnId, prioritise by its HLC (and FIFO otherwise)
126+
*/
127+
HLC_FIFO,
128+
129+
/**
130+
* Prioritise Apply, Stable, Commit, Accept, and PreAccept messages in that order.
131+
* Within a given message type, prioritise by HLC.
132+
* Other messages will be mixed with PreAccept messages, but using the next counter rather than the HLC of the TxnId.
133+
* Note: this can have some performance edge cases for contended keys, as we may process Stable messages for later commands before
134+
* we process earlier Accept/Commit, which may delay execution
135+
*/
136+
PHASE_HLC_FIFO,
137+
138+
/**
139+
* Prioritise Apply, Stable, Commit, Accept, and PreAccept messages from the original coordinator only, in that order.
140+
* Within a given message type, prioritise by HLC.
141+
* Other messages will be mixed with PreAccept messages, but using the next counter rather than the HLC of the TxnId.
142+
*/
143+
ORIG_PHASE_HLC_FIFO
144+
}
145+
110146
public QueueShardModel queue_shard_model = THREAD_POOL_PER_SHARD;
111147
public QueueSubmissionModel queue_submission_model = SYNC;
112148

@@ -115,6 +151,15 @@ public enum QueueSubmissionModel
115151
*/
116152
public volatile OptionaldPositiveInt queue_shard_count = OptionaldPositiveInt.UNDEFINED;
117153

154+
public QueuePriorityModel queue_priority_model = HLC_FIFO;
155+
156+
// yield to other executor threads after executing this many tasks in a row, if there are waiting threads and tasks
157+
public int queue_yield_interval = 100;
158+
159+
/**
160+
* If the HLC is older than this, queue by FIFO instead
161+
*/
162+
public DurationSpec.IntMillisecondsBound queue_priority_age_to_fifo = new DurationSpec.IntMillisecondsBound(500);
118163
/**
119164
* The target number of command stores to create per topology shard.
120165
* This determines the amount of execution parallelism possible for a given table/shard on the host.
@@ -165,6 +210,10 @@ public enum QueueSubmissionModel
165210
public volatile DurationSpec.IntSecondsBound shard_durability_cycle = new DurationSpec.IntSecondsBound(5, TimeUnit.MINUTES);
166211
public volatile DurationSpec.IntSecondsBound global_durability_cycle = new DurationSpec.IntSecondsBound(5, TimeUnit.MINUTES);
167212

213+
public volatile DurationSpec.IntSecondsBound topology_watermark_interval = new DurationSpec.IntSecondsBound(60);
214+
public volatile boolean topology_sync_propagator_enabled_pre_start = false;
215+
public volatile boolean topology_sync_propagator_enabled_post_startup = false;
216+
168217
public enum TransactionalRangeMigration
169218
{
170219
auto, explicit
@@ -178,11 +227,6 @@ public enum TransactionalRangeMigration
178227
*/
179228
public volatile TransactionalRangeMigration range_migration = TransactionalRangeMigration.auto;
180229

181-
public enum RebootstrapMode
182-
{
183-
full_repair, truncate_and_stream
184-
}
185-
186230
public enum CatchupMode
187231
{
188232
DISABLED,
@@ -195,15 +239,44 @@ public enum CatchupMode
195239
* default transactional mode for tables created by this node when no transactional mode has been specified in the DDL
196240
*/
197241
public TransactionalMode default_transactional_mode = TransactionalMode.off;
198-
public boolean ephemeralReadEnabled = true;
242+
243+
// ******** PROTOCOL MODIFIERS ***********
244+
245+
public CoordinatorBacklogExecution coordinator_backlog_execution;
246+
public Boolean permit_local_delivery;
247+
public Boolean permit_coordinator_local_execution; // if disabled, the privileged coordinator optimisation will be counter-productive and should also be disabled
248+
public TxnId.FastPath permit_fast_path;
249+
public Boolean permit_track_stable_medium_path;
250+
public Boolean permit_fast_quorum_medium_path;
251+
public Boolean always_inform_durable_single_key;
252+
public ReplicaExecution replica_execution;
253+
public Float replica_execution_distributed_persist_chance;
254+
public FastExecution fast_write_execution;
255+
public FastExecution fast_read_execution;
256+
public CleanCfkBefore clean_cfk_before;
257+
public SendStableMessages send_stable;
258+
/**
259+
* include the least information expected to be necessary in messages -
260+
* this is more efficient but may lead to some additional traffic and latency when earlier messages had not arrived
261+
*/
262+
public Boolean send_minimal;
263+
// note: simulator incompatible (for now)
264+
public Boolean precise_micros;
265+
266+
public boolean ephemeral_reads = true;
199267
public boolean state_cache_listener_jfr_enabled = false;
200268

201269
public float hard_reject_ratio = 0.5f;
202-
public int min_soft_reject_count = 10;
203-
public int max_soft_reject_count = 100;
270+
public int min_soft_reject_count = 100;
271+
public int max_soft_reject_count = 1000;
204272
public DurationSpec.LongMicrosecondsBound soft_reject_age = new DurationSpec.LongMicrosecondsBound("10s");
205273
public DurationSpec.LongMicrosecondsBound soft_reject_cumulative_age = new DurationSpec.LongMicrosecondsBound("60s");
206274

275+
276+
public DurationSpec.IntSecondsBound commands_for_key_prune_delta = new DurationSpec.IntSecondsBound(1);
277+
public int commands_for_key_prune_interval = 64;
278+
public DurationSpec.IntSecondsBound max_conflicts_prune_delta = new DurationSpec.IntSecondsBound(1);
279+
207280
public DurationSpec.IntSecondsBound catchup_on_start_success_latency = new DurationSpec.IntSecondsBound(60);
208281
public DurationSpec.IntSecondsBound catchup_on_start_fail_latency = new DurationSpec.IntSecondsBound(900);
209282
public int catchup_on_start_max_attempts = 5;
@@ -215,7 +288,7 @@ public enum CatchupMode
215288
public enum RangeIndexMode { in_memory, journal_sai }
216289
public RangeIndexMode range_index_mode = in_memory;
217290

218-
public final JournalSpec journal = new JournalSpec();
291+
public final JournalConfig journal = new JournalConfig();
219292

220293
public enum MixedTimeSourceHandling
221294
{
@@ -224,7 +297,7 @@ public enum MixedTimeSourceHandling
224297

225298
public volatile MixedTimeSourceHandling mixedTimeSourceHandling = MixedTimeSourceHandling.reject;
226299

227-
public static class JournalSpec implements Params
300+
public static class JournalConfig implements Params
228301
{
229302
public enum ReplayMode
230303
{
@@ -264,11 +337,17 @@ public enum StopMarkerFailurePolicy
264337
*/
265338
EXIT,
266339

340+
/**
341+
* @deprecated since alpha release, replaced by ALLOW_UNSAFE_STARTUP for consistency with FailurePolicy.ALLOW_UNSAFE_STARTUP
342+
*/
343+
@Deprecated(since="6.0")
344+
UNSAFE_STARTUP,
345+
267346
/**
268347
* If the start marker exceeds the stop marker startup, assuming the consensus log has been determined complete externally.
269348
* Note this is VERY UNSAFE if you care about isolation guarantees.
270349
*/
271-
UNSAFE_STARTUP,
350+
ALLOW_UNSAFE_STARTUP,
272351

273352
REBOOTSTRAP
274353
}
@@ -289,7 +368,7 @@ public enum StopMarkerFailurePolicy
289368
public Version version = Version.DOWNGRADE_SAFE_VERSION;
290369
public boolean enable_compaction = true;
291370

292-
public JournalSpec setFlushPeriod(DurationSpec newFlushPeriod)
371+
public JournalConfig setFlushPeriod(DurationSpec newFlushPeriod)
293372
{
294373
flushPeriod = newFlushPeriod;
295374
flushCombinedBlockPeriod = Long.MIN_VALUE;

src/java/org/apache/cassandra/config/CassandraRelevantProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public enum CassandraRelevantProperties
4444
{
4545
ACCORD_AGENT_CLASS("cassandra.test.accord.agent"),
4646
ACCORD_ALLOW_TEST_MODES("cassandra.test.accord.allow_test_modes", "false"),
47+
ACCORD_DEBUG_EXECUTION("accord.debug_execution"),
4748
ACCORD_KEY_PARANOIA_COSTFACTOR(Invariants.KEY_PARANOIA_COSTFACTOR),
4849
ACCORD_KEY_PARANOIA_CPU(Invariants.KEY_PARANOIA_CPU),
4950
ACCORD_KEY_PARANOIA_MEMORY(Invariants.KEY_PARANOIA_MEMORY),
@@ -62,6 +63,10 @@ public enum CassandraRelevantProperties
6263
ALLOW_UNSAFE_REPLACE("cassandra.allow_unsafe_replace"),
6364
ALLOW_UNSAFE_TRANSIENT_CHANGES("cassandra.allow_unsafe_transient_changes"),
6465
APPROXIMATE_TIME_PRECISION_MS("cassandra.approximate_time_precision_ms", "2"),
66+
ARTIFICIAL_LATENCIES("cassandra.artificial_latencies"),
67+
ARTIFICIAL_LATENCIES_UNSAFE("cassandra.artificial_latencies_unsafe"),
68+
ARTIFICIAL_LATENCY_LIMIT("cassandra.artificial_latency_limit", "200ms"),
69+
ARTIFICIAL_LATENCY_VERBS("cassandra.artificial_latency_verbs"),
6570
ASYNC_PROFILER_ENABLED("cassandra.async_profiler.enabled", "false"),
6671
ASYNC_PROFILER_UNSAFE_MODE("cassandra.async_profiler.unsafe_mode", "false"),
6772
/** 2 ** GENSALT_LOG2_ROUNDS rounds of hashing will be performed. */

src/java/org/apache/cassandra/config/Config.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ public static Set<String> splitCommaDelimited(String src)
165165
@Replaces(oldName = "cas_contention_timeout_in_ms", converter = Converters.MILLIS_DURATION_LONG, deprecated = true)
166166
public volatile DurationSpec.LongMillisecondsBound cas_contention_timeout = new DurationSpec.LongMillisecondsBound("1800ms");
167167

168-
public volatile DurationSpec.LongMillisecondsBound accord_preaccept_timeout = new DurationSpec.LongMillisecondsBound("1s");
169-
170168
@Replaces(oldName = "truncate_request_timeout_in_ms", converter = Converters.MILLIS_DURATION_LONG, deprecated = true)
171169
public volatile DurationSpec.LongMillisecondsBound truncate_request_timeout = new DurationSpec.LongMillisecondsBound("60000ms");
172170

@@ -1240,7 +1238,7 @@ public enum PaxosOnLinearizabilityViolation
12401238
*/
12411239
public ParameterizedClass default_compaction = null;
12421240

1243-
public final AccordSpec accord = new AccordSpec();
1241+
public final AccordConfig accord = new AccordConfig();
12441242

12451243
public static Supplier<Config> getOverrideLoadConfig()
12461244
{

0 commit comments

Comments
 (0)