2222
2323import 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 ;
2531import accord .utils .Invariants ;
2632
2733import org .apache .cassandra .journal .Params ;
2834import org .apache .cassandra .service .accord .serializers .Version ;
2935import 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 ,
@@ -196,15 +240,43 @@ public enum CatchupMode
196240 */
197241 public TransactionalMode default_transactional_mode = TransactionalMode .off ;
198242
199- public boolean ephemeralReadEnabled = true ;
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 ;
200267 public boolean state_cache_listener_jfr_enabled = false ;
201268
202269 public float hard_reject_ratio = 0.5f ;
203- public int min_soft_reject_count = 10 ;
204- public int max_soft_reject_count = 100 ;
270+ public int min_soft_reject_count = 100 ;
271+ public int max_soft_reject_count = 1000 ;
205272 public DurationSpec .LongMicrosecondsBound soft_reject_age = new DurationSpec .LongMicrosecondsBound ("10s" );
206273 public DurationSpec .LongMicrosecondsBound soft_reject_cumulative_age = new DurationSpec .LongMicrosecondsBound ("60s" );
207274
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+
208280 public DurationSpec .IntSecondsBound catchup_on_start_success_latency = new DurationSpec .IntSecondsBound (60 );
209281 public DurationSpec .IntSecondsBound catchup_on_start_fail_latency = new DurationSpec .IntSecondsBound (900 );
210282 public int catchup_on_start_max_attempts = 5 ;
@@ -216,7 +288,7 @@ public enum CatchupMode
216288 public enum RangeIndexMode { in_memory , journal_sai }
217289 public RangeIndexMode range_index_mode = in_memory ;
218290
219- public final JournalSpec journal = new JournalSpec ();
291+ public final JournalConfig journal = new JournalConfig ();
220292
221293 public enum MixedTimeSourceHandling
222294 {
@@ -225,7 +297,7 @@ public enum MixedTimeSourceHandling
225297
226298 public volatile MixedTimeSourceHandling mixedTimeSourceHandling = MixedTimeSourceHandling .reject ;
227299
228- public static class JournalSpec implements Params
300+ public static class JournalConfig implements Params
229301 {
230302 public enum ReplayMode
231303 {
@@ -265,11 +337,17 @@ public enum StopMarkerFailurePolicy
265337 */
266338 EXIT ,
267339
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+
268346 /**
269347 * If the start marker exceeds the stop marker startup, assuming the consensus log has been determined complete externally.
270348 * Note this is VERY UNSAFE if you care about isolation guarantees.
271349 */
272- UNSAFE_STARTUP ,
350+ ALLOW_UNSAFE_STARTUP ,
273351
274352 REBOOTSTRAP
275353 }
@@ -290,7 +368,7 @@ public enum StopMarkerFailurePolicy
290368 public Version version = Version .DOWNGRADE_SAFE_VERSION ;
291369 public boolean enable_compaction = true ;
292370
293- public JournalSpec setFlushPeriod (DurationSpec newFlushPeriod )
371+ public JournalConfig setFlushPeriod (DurationSpec newFlushPeriod )
294372 {
295373 flushPeriod = newFlushPeriod ;
296374 flushCombinedBlockPeriod = Long .MIN_VALUE ;
0 commit comments