You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2017/09/13 13:37:04 UTC
[2/6] cassandra git commit: Wait for all management tasks to complete
before shutting down CLSM
Wait for all management tasks to complete before shutting down CLSM
patch by Jan Urbański; reviewed by jasobrown for CASSANDRA-13123
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d826c818
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d826c818
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d826c818
Branch: refs/heads/cassandra-3.11
Commit: d826c81874e5d13a30a418f8b982531cb7e5d158
Parents: 9882cd8
Author: Jan Urbański <ja...@newrelic.com>
Authored: Sat Jan 14 21:26:52 2017 +0100
Committer: Jason Brown <ja...@gmail.com>
Committed: Wed Sep 13 06:28:47 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../db/commitlog/CommitLogSegmentManager.java | 8 ++++--
.../commitlog/CommitLogSegmentManagerTest.java | 30 ++++++++++++++++++++
3 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d826c818/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3d3903e..4d2d5e7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.15
+ * Wait for all management tasks to complete before shutting down CLSM (CASSANDRA-13123)
* INSERT statement fails when Tuple type is used as clustering column with default DESC order (CASSANDRA-13717)
* Fix pending view mutations handling and cleanup batchlog when there are local and remote paired mutations (CASSANDRA-13069)
* Improve config validation and documentation on overflow and NPE (CASSANDRA-13622)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d826c818/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
index 79dd316..7651d1c 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
@@ -108,14 +108,18 @@ public class CommitLogSegmentManager
{
public void runMayThrow() throws Exception
{
- while (run)
+ while (true)
{
try
{
Runnable task = segmentManagementTasks.poll();
if (task == null)
{
- // if we have no more work to do, check if we should create a new segment
+ // if we have no more work to do, check if we were requested to exit before starting background tasks
+ if (!run)
+ return;
+
+ // check if we should create a new segment
if (!atSegmentLimit() && availableSegments.isEmpty() && (activeSegments.isEmpty() || createReserveSegments))
{
logger.trace("No segments in reserve; creating a fresh one");
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d826c818/test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerTest.java
index a9b0669..41f5ed5 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerTest.java
@@ -20,8 +20,10 @@
*/
package org.apache.cassandra.db.commitlog;
+import java.io.File;
import java.nio.ByteBuffer;
import java.util.Random;
+import java.util.UUID;
import java.util.concurrent.Semaphore;
import com.google.common.collect.ImmutableMap;
@@ -134,4 +136,32 @@ public class CommitLogSegmentManagerTest
Thread.currentThread().interrupt();
}
}
+
+ @Test
+ @BMRule(name = "Make removing commitlog segments slow",
+ targetClass = "CommitLogSegment",
+ targetMethod = "discard",
+ action = "Thread.sleep(50)")
+ public void testShutdownWithPendingTasks() throws Throwable {
+ CommitLog.instance.resetUnsafe(true);
+ ColumnFamilyStore cfs1 = Keyspace.open(KEYSPACE1).getColumnFamilyStore(STANDARD1);
+
+ final Mutation m = new RowUpdateBuilder(cfs1.metadata, 0, "k")
+ .clustering("bytes")
+ .add("val", ByteBuffer.wrap(entropy))
+ .build();
+
+ // force creating several commitlog files
+ for (int i = 0; i < 10; i++) {
+ CommitLog.instance.add(m);
+ }
+
+ // schedule discarding completed segments and immediately issue a shutdown
+ UUID cfid = m.getColumnFamilyIds().iterator().next();
+ CommitLog.instance.discardCompletedSegments(cfid, ReplayPosition.NONE, CommitLog.instance.getContext());
+ CommitLog.instance.shutdownBlocking();
+
+ // the shutdown should block until all logs except the currently active one and perhaps a new, empty one are gone
+ Assert.assertTrue(new File(CommitLog.instance.location).listFiles().length <= 2);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org