dcapwell commented on code in PR #4220:
URL: https://github.com/apache/cassandra/pull/4220#discussion_r2240886728
##########
test/distributed/org/apache/cassandra/distributed/test/cql3/StatefulASTBase.java:
##########
@@ -206,10 +211,55 @@ protected <S extends BaseState>
Property.StatefulSuccess<S, Void> onSuccess(Logg
});
}
+ protected static <S extends CommonState> Property.Command<S, Void, ?>
validateUsingTimestamp(RandomSource rs, S state)
+ {
+ if (state.operations == 0)
+ return ignoreCommand();
+ var builder = Select.builder(state.metadata);
+ for (var c : state.model.factory.regularAndStaticColumns)
+ builder.selection(FunctionCall.writetime(c));
+ ByteBuffer upperboundTimestamp = LongType.instance.decompose((long)
state.operations);
+ var select = builder.build();
+ var inst = state.selectInstance(rs);
+ return new Property.SimpleCommand<>(state.humanReadable(select, null),
s -> {
+ var result = s.executeQuery(inst, Integer.MAX_VALUE, s.selectCl(),
select);
+ for (var row : result)
+ {
+ for (var col : state.model.factory.regularAndStaticColumns)
+ {
+ int idx =
state.model.factory.regularAndStaticColumns.indexOf(col);
+ ByteBuffer value = row[idx];
+ if (value == null) continue;
+ if (col.type().isMultiCell())
+ {
+ List<ByteBuffer> timestamps =
LONG_LIST_TYPE.unpack(value);
+ int cellIndex = 0;
+ for (var timestamp : timestamps)
+ {
+
Assertions.assertThat(LongType.instance.compare(timestamp, upperboundTimestamp))
+ .describedAs("Unexected timestamp at
multi-cell index %s for col %s: %s > %s", cellIndex, col,
LongType.instance.compose(timestamp), state.operations)
+ .isLessThanOrEqualTo(state.operations);
+ cellIndex++;
+ }
+ }
+ else
+ {
+ Assertions.assertThat(LongType.instance.compare(value,
upperboundTimestamp))
+ .describedAs("Unexected timestamp for col
%s: %s > %s", col, LongType.instance.compose(value), state.operations)
+ .isLessThanOrEqualTo(state.operations);
+ }
+ }
+ }
+ });
+ }
+
protected static <S extends CommonState> Property.Command<S, Void, ?>
insert(RandomSource rs, S state)
{
int timestamp = ++state.operations;
- Mutation mutation =
state.mutationGen().next(rs).withTimestamp(timestamp);
+ Mutation original = state.mutationGen().next(rs);
+ Mutation mutation = state.allowUsingTimestamp()
+ ? original.withTimestamp(timestamp)
Review Comment:
sorry thought this comment was for main code and not test.
`withTimestamp` is currently only implemented in INSERT / UPDATE / DELETE.
Batch support never got merged (see
https://issues.apache.org/jira/browse/CASSANDRA-20503) as there were annoying
edge cases with unexpected behavior and things were ready to start testing
`BEGIN TRANSACTION`.
Even if batch was added, it would just add the timestamp to the top level
batch and wouldn't do the "mix" that this patch guards against
--
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]