Skip to content

[Bug]: Activated HAKeeper delivery can lose LogStore StartReplica after a lost heartbeat response #32933

Open

Description

@jiangxinmeng1

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.

  1. Start the real LogService and HAKeeper test service, and activate command delivery through the normal checker barrier.
  2. Register a LogStore with a heartbeat. Generate its StartReplica command using the real operator controller and add the batch to HAKeeper.
  3. Send a heartbeat and discard its successful response, modeling a committed heartbeat whose RPC response is lost before handleCommands runs.
  4. Send the same heartbeat again without an acknowledgment or reported replica.
  5. The first response has the command; the second response has none. getCommandBatch confirms 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions