box: make bootstrap_leader cfg option dynamic#10769
Merged
sergepetrenko merged 1 commit intotarantool:masterfrom Nov 12, 2024
Merged
box: make bootstrap_leader cfg option dynamic#10769sergepetrenko merged 1 commit intotarantool:masterfrom
sergepetrenko merged 1 commit intotarantool:masterfrom
Conversation
Totktonada
approved these changes
Oct 31, 2024
Contributor
Totktonada
left a comment
There was a problem hiding this comment.
I see no flaws. Thank you!
Serpentian
reviewed
Oct 31, 2024
xuniq
approved these changes
Nov 1, 2024
3c36ff4 to
b429ae7
Compare
Serpentian
approved these changes
Nov 1, 2024
Contributor
Serpentian
left a comment
There was a problem hiding this comment.
Thank you! No objections from my side
Collaborator
Author
|
Found a memory leak: |
Collaborator
Author
|
Changes since the previous version: diffdiff --git a/src/box/box.cc b/src/box/box.cc
index 2b25f14502..d53dc7ac3c 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1579,6 +1579,8 @@ static int
box_check_bootstrap_leader(struct uri *uri, struct tt_uuid *uuid, char *name)
{
*uuid = uuid_nil;
+ if (!uri_is_nil(uri))
+ uri_destroy(uri);
uri_create(uri, NULL);
*name = '\0';
const char *source = cfg_gets("bootstrap_leader");
@@ -1977,6 +1979,7 @@ box_check_config(void)
box_check_replication_sync_timeout();
if (box_check_bootstrap_strategy() == BOOTSTRAP_STRATEGY_INVALID)
diag_raise();
+ uri_create(&uri, NULL);
if (box_check_bootstrap_leader(&uri, &uuid, name) != 0)
diag_raise();
uri_destroy(&uri);
diff --git a/src/box/replication.cc b/src/box/replication.cc
index 2b228a8098..ac4d8cbe3e 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -265,6 +265,9 @@ replication_free(void)
latch_destroy(&replicaset.applier.order_latch);
applier_free();
+ if (!uri_is_nil(&cfg_bootstrap_leader_uri))
+ uri_destroy(&cfg_bootstrap_leader_uri);
+
TRASH(&replicaset);
}
|
bootstrap_leader configuration option only takes effect during instance bootstrap. For this reason, the option was made static. One can't change the bootstrap_leader after initial box.cfg() call. So when a user has bootstrap_strategy = 'config' and joins new nodes during replicaset lifespan, he ends up with instances having different `bootstrap_leader` configuration, depending on which node was writable at the moment of each instance bootstrap. It would be better to have matching configuration on each replica set member with no exceptions and to be able to set bootstrap_leader to the same value on all the instances of the replica set, even on the ones which are already bootstrapped. Let's allow changing `bootstrap_leader` option even though it affects nothing. While we're at it, fix a memory leak of bootstrap leader uri on tarantool shutdown. Closes tarantool#10604 @TarantoolBot document Title: clarify `bootstrap_leader` configuration option meaning The option `bootstrap_leader` is dynamic, but it's important to note that changing it after instance bootstrap affects nothing. It's left dynamic simply for the sake of centralized configuration, when it's preferable to have matching configurations on all instances of a replica set.
b429ae7 to
b5779ea
Compare
Collaborator
Author
|
@Serpentian, PTAL. I've fixed the memory leak. |
Serpentian
reviewed
Nov 6, 2024
Serpentian
approved these changes
Nov 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bootstrap_leader configuration option only takes effect during instance bootstrap. For this reason, the option was made static. One can't change the bootstrap_leader after initial box.cfg() call.
So when a user has bootstrap_strategy = 'config' and joins new nodes during replicaset lifespan, he ends up with instances having different
bootstrap_leaderconfiguration, depending on which node was writable at the moment of each instance bootstrap.It would be better to have matching configuration on each replica set member with no exceptions and to be able to set bootstrap_leader to the same value on all the instances of the replica set, even on the ones which are already bootstrapped.
Let's allow changing
bootstrap_leaderoption even though it affects nothing.Closes #10604
NO_DOC=the doc already states the option is dynamic