diff --git a/src/controller/ha.c b/src/controller/ha.c index 9869c621..6c382434 100644 --- a/src/controller/ha.c +++ b/src/controller/ha.c @@ -8585,7 +8585,7 @@ static void ha_enter_real_election(ha_state_t *ha, cluster_t *c) if (c->myconf && c->myconf->peers_cfg.candidates_count > 0) { const xce_cluster_config_t *cfg = &c->myconf->peers_cfg; int n = cfg->candidates_count > 0 ? cfg->candidates_count - 1 : 0; - xce_candidate_t *peer_ptrs[MAX_HA_CANDIDATES]; + const xce_candidate_t *peer_ptrs[MAX_HA_CANDIDATES]; int np = 0; for (int i = 0; i < cfg->candidates_count && np < n; i++) { if (strcmp(cfg->candidates[i].name, @@ -9313,7 +9313,7 @@ void ha_start_election_async(ha_state_t *ha, cluster_t *c, * this instead of the real ha_start_election_async(). Req 6.3, 6.5, 9.3. */ void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name) = NULL; #endif diff --git a/src/controller/ha.h b/src/controller/ha.h index 0bc43032..be760155 100644 --- a/src/controller/ha.h +++ b/src/controller/ha.h @@ -2237,7 +2237,7 @@ uint64_t ha_trigger_manual_failover_for_test(ha_state_t *ha); * Requirements: 6.3, 6.5, 9.3. */ extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name); diff --git a/src/controller/testsuite/test_ha_failover.c b/src/controller/testsuite/test_ha_failover.c index b5e6164f..cbb4d1c5 100644 --- a/src/controller/testsuite/test_ha_failover.c +++ b/src/controller/testsuite/test_ha_failover.c @@ -262,7 +262,7 @@ static void test_rdhup_on_minus_one_fd_is_safe(void) * async re-election (Req 6.3, 6.5, 9.3). */ extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name); @@ -272,7 +272,7 @@ static int g_rdhup_hook_n_peers = -1; static ha_state_t *g_rdhup_hook_ha = NULL; static void rdhup_election_spy(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name) { diff --git a/src/controller/testsuite/test_ha_prevote.c b/src/controller/testsuite/test_ha_prevote.c index f90e6e41..f0222379 100644 --- a/src/controller/testsuite/test_ha_prevote.c +++ b/src/controller/testsuite/test_ha_prevote.c @@ -1503,7 +1503,7 @@ extern int ha_prevote_active_round_timer_for_test(uint64_t *round_out, extern void ha_prevote_round_timer_clear_for_test(void); extern _Atomic int ha_liveness_arm_count_for_test; extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name); @@ -1705,7 +1705,7 @@ static void test_r2_f2_refused_promotion_steps_down_and_rearms(void) */ static int g_r2_election_spy_calls = 0; static void r2_election_spy(ha_state_t *ha, cluster_t *c, int n_peers, - xce_candidate_t **peers, uint64_t tag, + const xce_candidate_t **peers, uint64_t tag, uint64_t lsn, const char *name) { (void)ha; (void)c; (void)n_peers; (void)peers; (void)tag; (void)lsn; diff --git a/src/controller/testsuite/test_ha_rdhup_integration.c b/src/controller/testsuite/test_ha_rdhup_integration.c index eadad4d7..eb4adb6f 100644 --- a/src/controller/testsuite/test_ha_rdhup_integration.c +++ b/src/controller/testsuite/test_ha_rdhup_integration.c @@ -38,7 +38,7 @@ extern int (*ha_phase2_hook)(void *c); extern int (*ha_push_config_hook)(void *c); extern int (*ha_send_ctrlhello_hook)(void *c); extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name); @@ -115,7 +115,8 @@ typedef struct { static rdhup_hook_state_t g_rdhup_state; static void rdhup_election_drives_evaluate(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, + const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name) @@ -401,7 +402,7 @@ static void test_rdhup_primary_dispatch_gate_opens(void) static int g_guard_hook_calls = 0; static void counting_election_hook(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name) { @@ -521,7 +522,7 @@ static uint64_t g_captured_my_lsn = 0; static uint64_t g_captured_my_tag = 0; static void capture_lsn_hook(ha_state_t *ha, cluster_t *c, - int n_peers, xce_candidate_t **peers, + int n_peers, const xce_candidate_t **peers, uint64_t my_config_tag, uint64_t my_lsn, const char *my_name) { diff --git a/src/controller/testsuite/test_repl_majority.c b/src/controller/testsuite/test_repl_majority.c index f7b8b8b9..0513b0e0 100644 --- a/src/controller/testsuite/test_repl_majority.c +++ b/src/controller/testsuite/test_repl_majority.c @@ -268,13 +268,8 @@ static void test_broadcast_over_limit_removes_standby(void) repl_add_standby(&r, &ep0, "sb0", 7000); /* Artificially inflate pending_ack_count past the limit. - * After overflow the standby should be evicted (in_catch_up=1 or removed). */ - for (int i = 0; i < r.standbys[0].ep != NULL ? 1 : 0; i++) { - /* Access the pending_ack_count field — this will fail to compile if - * the field does not exist on standby_conn_t */ - r.standbys[0].pending_ack_count = MAX_PENDING_ACKS + 1; - } - /* Also verify the field exists via a direct write */ + * After overflow the standby should be evicted (in_catch_up=1 or removed). + * This also fails to compile if the field is missing on standby_conn_t. */ r.standbys[0].pending_ack_count = MAX_PENDING_ACKS + 1; /* Broadcast a wal entry — the over-limit standby should be evicted */ diff --git a/src/include/netio.h b/src/include/netio.h index a5490a02..c67e75d9 100644 --- a/src/include/netio.h +++ b/src/include/netio.h @@ -181,12 +181,12 @@ extern void free_packet(io_packet_t*); extern endpoint_t* endpoint_get(void); extern int endpoint_init(endpoint_t*, int, int, int, int); -extern int endpoint_connect(endpoint_t*, char*, int, int); +extern int endpoint_connect(endpoint_t*, const char*, int, int); /* socket_connect: bounded, non-blocking TCP connect on an existing fd. * connect_timeout_ms == 0 uses DEFAULT_CONNECT_TIMEOUT_MS (config.h). * Returns 0 on success (fd left non-blocking), -ETIMEDOUT on bound expiry, * or - on error. raft-drive-async R2.3. */ -extern int socket_connect(int sock, char* host, int port, +extern int socket_connect(int sock, const char* host, int port, int connect_timeout_ms); extern int endpoint_accept(endpoint_t*, endpoint_t*); extern int endpoint_set_conn_handler(endpoint_t*, conn_handler_t); diff --git a/src/lib/netio.c b/src/lib/netio.c index 287cc3b3..ca983304 100644 --- a/src/lib/netio.c +++ b/src/lib/netio.c @@ -324,7 +324,7 @@ static int socket_create(int domain, int type, int port, int backlog) * -ETIMEDOUT — poll bound expired before the connect completed * - — name resolution / socket / connect error (e.g. -ECONNREFUSED) */ -int socket_connect(int sock, char* host, int port, int connect_timeout_ms) +int socket_connect(int sock, const char* host, int port, int connect_timeout_ms) { struct sockaddr_in server; struct hostent* hp; @@ -899,7 +899,7 @@ int endpoint_init(endpoint_t* ep, int domain, int type, int port, int backlog) return fd; } -int endpoint_connect(endpoint_t* ep, char* host, int port, +int endpoint_connect(endpoint_t* ep, const char* host, int port, int connect_timeout_ms) { int rc = -1; diff --git a/src/meson.build b/src/meson.build index 675fbc3e..6d3b0a34 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,7 +9,11 @@ component = get_option('component') with_debug = false if get_option('buildtype') == 'debug' - # add -DWITH_DEBUG=1 + # Debug profile: -O0 with line-tables-only debug info (-g1). Objects at -g3 + # carry full macro/variable DWARF and were ~16x larger (scheduler.c object: + # 1.3MB at -g3 vs 0.08MB at -g1), which made the build tree balloon to + # multi-GB. -g1 keeps file/line and backtraces; variable/macro inspection + # in gdb is lost -- use the asan profile for that when debugging state. add_project_arguments(['-DWITH_DEBUG=1', '-DDEBUG', '-O0', @@ -18,10 +22,7 @@ if get_option('buildtype') == 'debug' '-fno-inline', '-fno-omit-frame-pointer', '-ggdb', - '-gdwarf-4', - '-g3', - '-fvar-tracking', - '-fvar-tracking-assignments', + '-g1', ], language: ['c', 'cpp']) add_project_link_arguments('-fno-lto', language: ['c', 'cpp']) with_debug = true