diff --git a/src/controller/myapp.c b/src/controller/myapp.c index 837082b..20370cb 100644 --- a/src/controller/myapp.c +++ b/src/controller/myapp.c @@ -75,6 +75,21 @@ int myapp_run(myconf_t* myconf) iomgr_start(&(c.iomgr)); vtaskmgr_start(&(c.vtaskmgr)); + /* Pre-load config from disk if a local config file exists, so that this + * node's config_tag is known before election. This allows the freshness gate + * in am_i_primary_quorum() (Req 2.4) to work correctly: a node with a valid + * local config will win over nodes that have no config (tag=0). + * If no config file exists yet, config_version_tag stays 0 and the node will + * defer the config fetch to after election via bootstrap_config_if_needed. */ + { + int pre_rc = load_primary_config(&c); + if (pre_rc == 0) { + INFO("Pre-election config loaded: tag=%016llx", + (unsigned long long)c.myconf->config_version_tag); + } + /* Ignore errors — node may have no config yet (first boot or standby) */ + } + /* Req 3.1–3.4: probe peers for config tags before election so that a node * joining an existing cluster knows to defer its config fetch to post-election * rather than participating as a first-boot candidate with no config. */