Repository navigation
Description
Problem
An activated HAKeeper command-delivery cluster can still consume a LogStore StartReplica schedule command before the target LogStore has observed it. If the committed heartbeat response is lost, the next LogStore heartbeat receives no command, and HAKeeper's pending batch is empty. This affects LogService replica placement and recovery, including deployments with only one TN. The operator checker may eventually create a new operation after expiry; this reproduction does not claim permanent unavailability.
Root cause
pkg/hakeeper/rsm.go uses getCommandBatchWithAck for capable CN and TN heartbeats when CommandDeliveryPreparing or CommandDeliveryEnabled is set. handleLogHeartbeat still always calls getCommandBatchFiltered, which removes non-bootstrap commands from replicated ScheduleCommands during the first heartbeat proposal. pkg/logservice/service_commands.go then executes commands only after the response reaches the LogStore. LogStoreHeartbeat has no acknowledged-batch field, so the activated protocol cannot acknowledge these LogStore commands.
operator.CreateStartReplica / Controller.Dispatch generates a normal LogService StartReplica command with Bootstrapping=false, so the bootstrap retry exception does not retain it.
Deterministic reproduction
Test: TestAuditLogHeartbeatDropsUnacknowledgedReplicaCommand. Audit report.
- Start the real LogService and HAKeeper test service, and activate command delivery through the normal checker barrier.
- Register a LogStore with a heartbeat. Generate its
StartReplicacommand using the real operator controller and add the batch to HAKeeper. - Send a heartbeat and discard its successful response, modeling a committed heartbeat whose RPC response is lost before
handleCommandsruns. - Send the same heartbeat again without an acknowledgment or reported replica.
- The first response has the command; the second response has none.
getCommandBatchconfirms that HAKeeper has already deleted it.
Observed in 3/3 ordinary runs and 3/3 race runs. This is a controlled lost-response test, not a captured network incident or a full three-node outage.
Expected behavior
Do not remove a LogStore command merely because HAKeeper committed a heartbeat. Keep it deliverable until the target has acknowledged or reported the corresponding replica state, with stable identity and deduplication across retries. Cover both command redelivery after response loss and command completion after the target reports the replica.
Related issue
#30443 covered TN StartReplica in the legacy pre-activation delivery path. This issue concerns LogStore commands after command delivery is enabled; the CN/TN acknowledged path does not address it.
Activity