This is an automated email from the ASF dual-hosted git repository.
blambov pushed a commit to branch cassandra-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-5.0 by this push:
new 9f187fafbd Revert checks for negative timestamp
9f187fafbd is described below
commit 9f187fafbd47a62be80cae21796178641b5b3627
Author: Branimir Lambov <[email protected]>
AuthorDate: Wed Aug 9 11:40:04 2023 +0300
Revert checks for negative timestamp
Contrary to expectations, we do permit negative timestamps.
This reverts checks that treat such timestamps as corruption
introduced in CASSANDRA-18676.
patch by Branimir Lambov; reviewed by Ekaterina Dimitrova for
CASSANDRA-18735
---
src/java/org/apache/cassandra/db/DeletionTime.java | 7 ++++---
src/java/org/apache/cassandra/db/rows/Cell.java | 2 --
.../org/apache/cassandra/db/rows/UnfilteredSerializer.java | 1 -
test/unit/org/apache/cassandra/db/ReadCommandTest.java | 10 +++++-----
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/java/org/apache/cassandra/db/DeletionTime.java
b/src/java/org/apache/cassandra/db/DeletionTime.java
index 45a5bf841a..5970fbb042 100644
--- a/src/java/org/apache/cassandra/db/DeletionTime.java
+++ b/src/java/org/apache/cassandra/db/DeletionTime.java
@@ -115,13 +115,14 @@ public class DeletionTime implements
Comparable<DeletionTime>, IMeasurableMemory
}
/**
- * Check if this deletion time is valid - markedForDeleteAt can only
negative if the deletion is LIVE.
- * localDeletionTime is not checked as it is stored as an unsigned int and
cannot be negative.
+ * Check if this deletion time is valid. This is always true, because
+ * - as we permit negative timestamps, markedForDeleteAt can be negative.
+ * - localDeletionTime is stored as an unsigned int and cannot be negative.
* @return true if it is valid
*/
public boolean validate()
{
- return markedForDeleteAt >= 0 || isLive();
+ return true;
}
@Override
diff --git a/src/java/org/apache/cassandra/db/rows/Cell.java
b/src/java/org/apache/cassandra/db/rows/Cell.java
index fffcca821a..d60fdda5a0 100644
--- a/src/java/org/apache/cassandra/db/rows/Cell.java
+++ b/src/java/org/apache/cassandra/db/rows/Cell.java
@@ -342,8 +342,6 @@ public abstract class Cell<V> extends ColumnData
}
}
- if (timestamp < 0)
- throw new IOException("Invalid negative timestamp: " +
timestamp);
if (ttl < 0)
throw new IOException("Invalid TTL: " + ttl);
localDeletionTime = decodeLocalDeletionTime(localDeletionTime,
ttl, helper);
diff --git a/src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
b/src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
index cfbcad177c..e31426bf68 100644
--- a/src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
+++ b/src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
@@ -589,7 +589,6 @@ public class UnfilteredSerializer
if (hasTimestamp)
{
long timestamp = header.readTimestamp(in);
- assert timestamp >= 0 : "Invalid negative timestamp " +
timestamp;
int ttl = hasTTL ? header.readTTL(in) : LivenessInfo.NO_TTL;
assert ttl >= 0 : "Invalid TTL " + ttl;
long localDeletionTime = hasTTL ?
header.readLocalDeletionTime(in) : LivenessInfo.NO_EXPIRATION_TIME;
diff --git a/test/unit/org/apache/cassandra/db/ReadCommandTest.java
b/test/unit/org/apache/cassandra/db/ReadCommandTest.java
index 16de3f061c..f1efe97722 100644
--- a/test/unit/org/apache/cassandra/db/ReadCommandTest.java
+++ b/test/unit/org/apache/cassandra/db/ReadCommandTest.java
@@ -798,21 +798,21 @@ public class ReadCommandTest
long nowInSec = FBUtilities.nowInSeconds();
// A simple tombstone
- new RowUpdateBuilder(cfs.metadata(), 100,
keys[0]).clustering("cc").delete("a").build().apply();
+ new RowUpdateBuilder(cfs.metadata(), 0,
keys[0]).clustering("cc").delete("a").build().apply();
// Collection with an associated complex deletion
- PartitionUpdate.SimpleBuilder builder =
PartitionUpdate.simpleBuilder(cfs.metadata(), keys[1]).timestamp(100);
+ PartitionUpdate.SimpleBuilder builder =
PartitionUpdate.simpleBuilder(cfs.metadata(), keys[1]).timestamp(0);
builder.row("cc").add("c", ImmutableSet.of("element1", "element2"));
builder.buildAsMutation().apply();
// RangeTombstone and a row (not covered by the RT). The row contains
a regular tombstone which will not be
// purged. This is to prevent the partition from being fully purged
and removed from the final results
- new RowUpdateBuilder(cfs.metadata(), nowInSec, 100L,
keys[2]).addRangeTombstone("aa", "bb").build().apply();
+ new RowUpdateBuilder(cfs.metadata(), nowInSec, 0L,
keys[2]).addRangeTombstone("aa", "bb").build().apply();
new RowUpdateBuilder(cfs.metadata(), nowInSec+ 1000, 1000L,
keys[2]).clustering("cc").delete("a").build().apply();
// Partition with 2 rows, one fully deleted
- new RowUpdateBuilder(cfs.metadata.get(), 100,
keys[3]).clustering("bb").add("a",
ByteBufferUtil.bytes("a")).delete("b").build().apply();
- RowUpdateBuilder.deleteRow(cfs.metadata(), 100, keys[3], "cc").apply();
+ new RowUpdateBuilder(cfs.metadata.get(), 0,
keys[3]).clustering("bb").add("a",
ByteBufferUtil.bytes("a")).delete("b").build().apply();
+ RowUpdateBuilder.deleteRow(cfs.metadata(), 0, keys[3], "cc").apply();
Util.flush(cfs);
cfs.getLiveSSTables().forEach(sstable -> mutateRepaired(cfs, sstable,
111, null));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]