jonmeredith commented on code in PR #1835:
URL: https://github.com/apache/cassandra/pull/1835#discussion_r965356300
##########
src/java/org/apache/cassandra/hints/HintsDispatchExecutor.java:
##########
@@ -205,21 +205,27 @@ private final class DispatchHintsTask implements Runnable
private final UUID hostId;
private final RateLimiter rateLimiter;
- DispatchHintsTask(HintsStore store, UUID hostId)
+ DispatchHintsTask(HintsStore store, UUID hostId, boolean isTransfer)
Review Comment:
I don't see where this is used.
##########
src/java/org/apache/cassandra/service/StorageService.java:
##########
@@ -4980,9 +4980,19 @@ private void unbootstrap(Runnable onFinish) throws
ExecutionException, Interrupt
logger.debug("waiting for batch log processing.");
batchlogReplay.get();
- setMode(Mode.LEAVING, "streaming hints to other nodes", true);
+ Future<?> hintsSuccess = ImmediateFuture.success(null);
- Future hintsSuccess = streamHints();
+ if (DatabaseDescriptor.getTransferHintsOnDecommission())
+ {
+ setMode(Mode.LEAVING, "streaming hints to other nodes", true);
+ hintsSuccess = streamHints();
+ }
+ else
+ {
+ DatabaseDescriptor.setHintedHandoffEnabled(false);
Review Comment:
wdyt about a `setMode(Mode.LEAVING, "deleting hints on decommission");` here?
##########
src/java/org/apache/cassandra/service/StorageService.java:
##########
@@ -4980,9 +4980,19 @@ private void unbootstrap(Runnable onFinish) throws
ExecutionException, Interrupt
logger.debug("waiting for batch log processing.");
batchlogReplay.get();
- setMode(Mode.LEAVING, "streaming hints to other nodes", true);
+ Future<?> hintsSuccess = ImmediateFuture.success(null);
- Future hintsSuccess = streamHints();
+ if (DatabaseDescriptor.getTransferHintsOnDecommission())
+ {
+ setMode(Mode.LEAVING, "streaming hints to other nodes", true);
+ hintsSuccess = streamHints();
+ }
+ else
+ {
+ DatabaseDescriptor.setHintedHandoffEnabled(false);
+ HintsService.instance.pauseDispatch();
+ HintsService.instance.deleteAllHints();
+ }
// wait for the transfer runnables to signal the latch.
logger.debug("waiting for stream acks.");
Review Comment:
Maybe move this log statement into the block for transferring above?
##########
test/distributed/org/apache/cassandra/distributed/test/HintedHandoffAddRemoveNodesTest.java:
##########
@@ -46,6 +50,36 @@
*/
public class HintedHandoffAddRemoveNodesTest extends TestBaseImpl
{
+ @Test
+ public void shouldAvoidHintTransferOnDecommission() throws Exception
+ {
+ try (Cluster cluster = init(builder().withNodes(3)
+ .withConfig(config ->
config.set("transfer_hints_on_decommission", false).with(GOSSIP))
+ .withoutVNodes()
+ .start()))
+ {
+ cluster.schemaChange(withKeyspace("CREATE TABLE
%s.decom_no_hints_test (key int PRIMARY KEY, value int)"));
+
+ cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE +
".decom_no_hints_test (key, value) VALUES (?, ?)", ALL, 0, 0);
+ long hintsBeforeShutdown = countTotalHints(cluster.get(1));
+ assertThat(hintsBeforeShutdown).isEqualTo(0);
+ long hintsDelivered = countHintsDelivered(cluster.get(1));
+ assertThat(hintsDelivered).isEqualTo(0);
+
+ // Shutdown node 3 so hints can be written against it.
+ cluster.get(3).shutdown().get();
+
+ cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE +
".decom_no_hints_test (key, value) VALUES (?, ?)", TWO, 0, 0);
+ Awaitility.await().until(() -> countTotalHints(cluster.get(1)) >
0);
+ long hintsAfterShutdown = countTotalHints(cluster.get(1));
+ assertThat(hintsAfterShutdown).isEqualTo(1);
+
+ cluster.get(1).nodetoolResult("decommission",
"--force").asserts().success();
+ long hintsDeliveredByDecom = countHintsDelivered(cluster.get(1));
Review Comment:
wdyt about adding a check for `StorageService.instance.operatingMode ==
DECOMMISSIONED`?
--
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]