You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/12/29 03:49:05 UTC
git commit: fix commitlog segment overflow patch by rbranson;
reviewed by jbellis for CASSANDRA-3615
Updated Branches:
refs/heads/trunk ca216f771 -> 48f5d5716
fix commitlog segment overflow
patch by rbranson; reviewed by jbellis for CASSANDRA-3615
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/48f5d571
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/48f5d571
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/48f5d571
Branch: refs/heads/trunk
Commit: 48f5d571641e534bb633f1e4e71a308a0bcba1d1
Parents: ca216f7
Author: Jonathan Ellis <jb...@apache.org>
Authored: Wed Dec 28 12:27:04 2011 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Wed Dec 28 12:27:04 2011 -0600
----------------------------------------------------------------------
CHANGES.txt | 2 +-
.../cassandra/db/commitlog/CommitLogSegment.java | 9 ++++++---
.../org/apache/cassandra/db/CommitLogTest.java | 11 +++++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/48f5d571/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6baaa20..5e370ed 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,7 +8,7 @@
* removed in-tree redhat spec (CASSANDRA-3567)
* "defragment" rows for name-based queries under STCS, again (CASSANDRA-2503)
* Recycle commitlog segments for improved performance
- (CASSANDRA-3411, 3543, 3557)
+ (CASSANDRA-3411, 3543, 3557, 3615)
* update size-tiered compaction to prioritize small tiers (CASSANDRA-2407)
* add message expiration logic to OutboundTcpConnection (CASSANDRA-3005)
* off-heap cache to use sun.misc.Unsafe instead of JNA (CASSANDRA-3271)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/48f5d571/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
index 9537e6b..d979a48 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
@@ -255,9 +255,12 @@ public class CommitLogSegment
checksum.update(serializedRow);
buffer.putLong(checksum.getValue());
- // writes end of segment marker and rewinds back to position where it starts
- buffer.putInt(CommitLog.END_OF_SEGMENT_MARKER);
- buffer.position(buffer.position() - CommitLog.END_OF_SEGMENT_MARKER_SIZE);
+ if (buffer.remaining() >= 4)
+ {
+ // writes end of segment marker and rewinds back to position where it starts
+ buffer.putInt(CommitLog.END_OF_SEGMENT_MARKER);
+ buffer.position(buffer.position() - CommitLog.END_OF_SEGMENT_MARKER_SIZE);
+ }
needsSync = true;
return repPos;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/48f5d571/test/unit/org/apache/cassandra/db/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CommitLogTest.java b/test/unit/org/apache/cassandra/db/CommitLogTest.java
index 27cabbe..83f780c 100644
--- a/test/unit/org/apache/cassandra/db/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/CommitLogTest.java
@@ -159,6 +159,17 @@ public class CommitLogTest extends CleanupHelper
assert CommitLog.instance.activeSegments() == 1 : "Expecting 1 segment, got " + CommitLog.instance.activeSegments();
}
+ // CASSANDRA-3615
+ @Test
+ public void testExceedSegmentSizeWithOverhead() throws Exception
+ {
+ CommitLog.instance.resetUnsafe();
+
+ RowMutation rm = new RowMutation("Keyspace1", bytes("k"));
+ rm.add(new QueryPath("Standard1", null, bytes("c1")), ByteBuffer.allocate((128 * 1024 * 1024) - 83), 0);
+ CommitLog.instance.add(rm);
+ }
+
protected void testRecoveryWithBadSizeArgument(int size, int dataSize) throws Exception
{
Checksum checksum = new CRC32();