Skip to content

Conversation

@tezc
Copy link
Owner

@tezc tezc commented Aug 27, 2025

Adds background trim.

@tezc tezc requested a review from ShooterIT August 27, 2025 07:09
Copy link
Collaborator

@ShooterIT ShooterIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

resetManualFailover();

/* Cancel all ASM tasks when switching into slave */
if (was_master) clusterAsmCancel(NULL, "switching to replica");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to cancel the trimming task in some cases?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such as cluster reset

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should cancel on emptyData() and this is mostly a concern for active trimming. e.g. after emptyData(), we don't try to unnecessarily continue trimming. I added a commit to cancel pending tasks, in the follow-up PR, it will also cancel active trim tasks. Do you see some other cases that we need to cancel?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, the master switches to replica, we should cancel, right?

and clusterDelNode?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to cancel it if we become a replica. e.g. trimming on master was in progress, replica finished it earlier. We trigger the failover. The new master will not propagate TRIMSLOTS as there is no unowned data. Though, the new replica will still have keys to be trimmed. So, I feel like replica should continue trimming. Let me know if you have a better solution in mind.

for clusterDelNode(), do we call this for our own node? Is this the scenario that we are removed from the cluster?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a scenario that the node sees itself in the clusterDelNode() ?

hmm, seems I mixed up canceling the trim and canceling the task?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we have to cancel the task if other party is deleted. So, looks like a node will never figure out it is deleted from the cluster unless you call CLUSTER RESET.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after second thought, we should cancel trimming task if becoming replica, for active trimming, don't cancel if the trimming is in progress, cancel pending trimming tasks

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is different between pending task and active trimming? Consider this scenario:

e.g. trimming on master was in progress, replica finished it earlier. We trigger the failover. The new master will not propagate TRIMSLOTS as there is no unowned data. Though, the new replica will still have keys to be trimmed.

If we cancel the pending trimming task, replica will never do the clean up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, maybe after active trimming, something will be clear to me.
please merge

@tezc tezc force-pushed the cluster-asm-bgtrim branch from 73e998b to 1f70cfb Compare September 2, 2025 09:01
@tezc tezc merged commit 9735c08 into cluster-asm Sep 2, 2025
35 of 41 checks passed
tezc added a commit that referenced this pull request Sep 10, 2025
background trim
tezc added a commit that referenced this pull request Sep 16, 2025
background trim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants