feat(ha-repl-hardening): populate stateReport in standby heartbeat reply (task 2.3)

OPCode_nop handler now sends stateReport {applied_lsn, config_tag}
instead of nodata. Function in ha.c for unit-test linkability.
Two tests: warm state and zero-state fresh standby (Req 1.4).
This commit is contained in:
Rongsong Shen 2026-06-04 16:08:11 +00:00
parent 6bbcff62ca
commit 7dc657b1bd
5 changed files with 128 additions and 5 deletions

View file

@ -172,6 +172,7 @@ static int handle_wal_catchup_entry(cluster_t *c, xce_request_t *req)
return 0;
}
static int myreq_handler(vtask_t* task)
{
vtask_data_t* data = (vtask_data_t*)task->data;
@ -240,9 +241,13 @@ static int myreq_handler(vtask_t* task)
xce_reply(ep, c->myhost, &reply);
}
break;
case OPCode_nop:
reply.status = 0;
reply.data_which = RequestReply_data_nodata;
case OPCode_nop: {
/* Task 2.3: standby populates stateReport in every heartbeat reply so
* the primary can track convergence (Req 1.1, 1.3, 1.4). */
state_report_t sr;
memset(&sr, 0, sizeof(sr));
reply.status = 0;
ha_nop_reply_state_report(&c->ha, c->myconf, &sr, &reply);
xce_reply(ep, c->myhost, &reply);
/* Req 1.3: any NOP from primary resets liveness deadline on standby.
* Role check is safe from any primary-connected ep — no fd comparison needed. */
@ -250,6 +255,7 @@ static int myreq_handler(vtask_t* task)
== CTRL_STANDBY)
ha_on_heartbeat_received(&c->ha);
break;
}
case OPCode_join:
rc = handle_join(c, ep, &request);
break;