Skip to content
Permalink
Browse files
Use TimeUUID serializer for BATCH_REMOVE_REQ
Patch by marcuse; reviewed by Benedict Elliott Smith for CASSANDRA-17451
  • Loading branch information
krummas committed May 4, 2022
1 parent 523d380 commit 3b648ca09ecfc100d5ad2e3b462d4949dbc03498
Showing 2 changed files with 58 additions and 1 deletion.
@@ -96,6 +96,7 @@
import org.apache.cassandra.service.paxos.v1.PrepareVerbHandler;
import org.apache.cassandra.service.paxos.v1.ProposeVerbHandler;
import org.apache.cassandra.streaming.ReplicationDoneVerbHandler;
import org.apache.cassandra.utils.TimeUUID;
import org.apache.cassandra.utils.UUIDSerializer;

import static java.util.concurrent.TimeUnit.NANOSECONDS;
@@ -118,7 +119,7 @@
BATCH_STORE_RSP (65, P1, writeTimeout, REQUEST_RESPONSE, () -> NoPayload.serializer, () -> ResponseVerbHandler.instance ),
BATCH_STORE_REQ (5, P3, writeTimeout, MUTATION, () -> Batch.serializer, () -> BatchStoreVerbHandler.instance, BATCH_STORE_RSP ),
BATCH_REMOVE_RSP (66, P1, writeTimeout, REQUEST_RESPONSE, () -> NoPayload.serializer, () -> ResponseVerbHandler.instance ),
BATCH_REMOVE_REQ (6, P3, writeTimeout, MUTATION, () -> UUIDSerializer.serializer, () -> BatchRemoveVerbHandler.instance, BATCH_REMOVE_RSP ),
BATCH_REMOVE_REQ (6, P3, writeTimeout, MUTATION, () -> TimeUUID.Serializer.instance, () -> BatchRemoveVerbHandler.instance, BATCH_REMOVE_RSP ),

PAXOS_PREPARE_RSP (93, P2, writeTimeout, REQUEST_RESPONSE, () -> PrepareResponse.serializer, () -> ResponseVerbHandler.instance ),
PAXOS_PREPARE_REQ (33, P2, writeTimeout, MUTATION, () -> Commit.serializer, () -> PrepareVerbHandler.instance, PAXOS_PREPARE_RSP ),
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.cassandra.distributed.upgrade;

import org.junit.Test;

import org.apache.cassandra.distributed.api.ConsistencyLevel;

import static org.junit.Assert.assertEquals;

public class BatchUpgradeTest extends UpgradeTestBase
{
@Test
public void batchTest() throws Throwable
{
new TestCase()
.nodes(2)

.nodesToUpgrade(2)
.upgradesFrom(v40).setup((cluster) -> {
cluster.schemaChange("CREATE TABLE "+KEYSPACE+".users (" +
"userid uuid PRIMARY KEY," +
"firstname ascii," +
"lastname ascii," +
"age int) WITH COMPACT STORAGE");
}).runAfterNodeUpgrade((cluster, node) -> {
cluster.coordinator(2).execute("BEGIN BATCH\n" +
" UPDATE "+KEYSPACE+".users SET age = 37 WHERE userid = f47ac10b-58cc-4372-a567-0e02b2c3d479\n" +
" DELETE firstname, lastname FROM "+KEYSPACE+".users WHERE userid = 550e8400-e29b-41d4-a716-446655440000\n" +
"APPLY BATCH", ConsistencyLevel.ALL);
}).runAfterClusterUpgrade((cluster) -> {
assertEquals(0, cluster.get(1).executeInternal("select * from system.batches").length);
assertEquals(0, cluster.get(2).executeInternal("select * from system.batches").length);
assertEquals(0, cluster.get(1).logs().grep("ClassCastException").getResult().size());
assertEquals(0, cluster.get(2).logs().grep("ClassCastException").getResult().size());
})
.run();

}
}

0 comments on commit 3b648ca

Please sign in to comment.