Skip to content

[Bug]: CN/TN remain unavailable after transient logservice network partition #27362

Closed

Description

@XuPeng-SH

Branch Name

main

Commit ID

6f42b19508f31ef04ae2857172893f13d48afddf

Other Environment Information

  • Isolated Docker deployment: 2 CN + 1 TN + 1 logservice + proxy + MinIO
  • Image: matrixorigin/matrixone:local
  • Host: Debian 13, Docker 28.5.1
  • Analysis window: 2026-08-19 16:24:41–16:29 UTC
  • No production source changes were made

Actual Behavior

After disconnecting only the logservice container from the compose network for about 30 seconds while a 16-thread read workload was active, reconnecting the same logservice endpoint did not restore HAKeeper/CN availability.

Observed sequence:

  1. At 16:24:41 UTC, the logservice network endpoint was disconnected.
  2. At 16:25:13 UTC, the endpoint was reconnected. DNS resolved again to the logservice container.
  3. A new SQL connection still returned 20101: internal error: no available CN server.
  4. The error persisted for at least 60 seconds after DNS and the logservice endpoint were healthy.
  5. Restarting the proxy alone did not recover the cluster. Restarting CN0 alone did not recover it. Restarting CN1 and TN finally restored a successful SQL probe.
  6. Existing read traffic continued for part of the window, while new connections and routing failed.

The logs showed:

hakeeper.checker.cnservice.no.cn.found
internal error: no available CN server
hakeeper-client-backend ... can-retry=false
dial tcp4: lookup logservice on 127.0.0.11:53: no such host

After the endpoint was restored, getent hosts logservice succeeded, but the long-lived CN/TN/proxy MORPC clients remained unusable until service generations were restarted.

Expected Behavior

A transient logservice network/DNS outage should have a bounded recovery path:

  • MORPC should retry/re-resolve a transient DNS/network failure after the endpoint returns.
  • CN/TN should resume HAKeeper heartbeats and re-register, or enter a controlled drain/restart state.
  • Proxy should refresh cluster details and route new connections once an eligible CN is available.
  • New SQL requests should fail fast with a bounded unavailable error during the outage, rather than leaving a healthy-looking cluster unavailable indefinitely.

Steps to Reproduce

  1. Start an isolated 2CN + TN + logservice + proxy deployment.
  2. Run continuous read traffic through the proxy.
  3. Disconnect only the logservice container from the service network for 30 seconds:
    docker network disconnect <network> <logservice-container>
  4. Reconnect it with the logservice network aliases.
  5. Confirm that DNS resolves and the logservice process is running.
  6. Open a new SQL connection and observe 20101 no available CN server.
  7. Wait at least 60 seconds; the condition persists.
  8. Restart CN/TN service generations; the SQL probe recovers.

Code Analysis

The HAKeeper client creates a MORPC backend in pkg/logservice/client.go:getRPCClient. In pkg/common/morpc/backend.go:1131-1175, resetConn retries only when the connection error is a timeout. A DNS resolution error such as lookup logservice: no such host is treated as non-retryable (can-retry=false) and returned as ErrBackendCannotConnect.

During the fault, the CN/TN heartbeat backends therefore remain unavailable after the endpoint comes back. HAKeeper expires the CNs, logs no.cn.found, and proxy has no routable CN. The process liveness probes remain positive, so process health does not represent SQL availability.

Related but distinct:

This report covers recovery after a transient HAKeeper network/DNS partition and the non-retryable MORPC backend state.

Impact

  • New SQL sessions fail with 20101 and cannot be routed.
  • DDL/write requests can block or fail while existing cache-hit reads continue, making the outage difficult to detect from superficial liveness checks.
  • CN/TN heartbeats and lockservice/HAKeeper control-plane progress stop.
  • Recovery requires restarting multiple service generations rather than waiting for the network to recover.
  • No data corruption was observed in this reproduction.

Regression Coverage

Add a deterministic integration/chaos test that:

  • partitions logservice DNS/network during active CN/TN/proxy traffic;
  • restores the endpoint without restarting clients;
  • asserts that MORPC re-resolves and reconnects;
  • asserts that CN/TN heartbeat and registration resume;
  • asserts that new SQL sessions recover within a bounded interval;
  • covers DNS NXDOMAIN, connection refused, timeout, endpoint IP change, cancellation, and service restart generations.

Activity

  1. added
    kind/bug
    on Aug 19, 2026
  2. XuPeng-SH commented on Aug 19, 2026

    @XuPeng-SH
    ContributorAuthor

    Follow-up reproduction: single-CN network partition

    The same recovery defect was reproduced by partitioning only one CN from the compose network for about 35 seconds during a 16-thread read workload:

    • Existing proxy traffic continued with no reported sysbench errors because the second CN remained available.
    • The affected CN repeatedly logged MORPC failures to logservice and TN with can-retry=false / network is unreachable.
    • After the network endpoint was reattached, the affected CN logged all local lock table invalid; proxy connections to that CN were repeatedly disconnected while the unaffected CN continued serving new SQL.
    • The affected CN did not become a healthy routable generation until it was restarted. After restart it received HAKeeper CreateTask and JoinGossipCluster schedule commands.
    • The 85-second load had zero reported errors but a 54.9-second maximum latency, showing that existing sessions can hide the control-plane failure while individual requests wait for the invalid CN path.

    This confirms the issue is not limited to DNS NXDOMAIN: a transient network-unreachable MORPC failure can leave a long-lived CN control-plane client unusable after the network is restored. No data corruption was observed.

  3. XuPeng-SH commented on Aug 19, 2026

    @XuPeng-SH
    ContributorAuthor

    Follow-up reproduction: TN network partition

    The same MORPC failure mode was observed when only TN was partitioned from the service network during a 16-thread read workload:

    • Partition window: 2026-08-19 16:54:20–16:55:00 UTC.
    • The workload reported no SQL errors, but reached a 41.3-second maximum latency, had a zero-throughput interval, and only returned to normal throughput after the endpoint was restored.
    • During the partition/recovery window, TN heartbeat and CN/TN RPC backends repeatedly logged can-retry=false with network is unreachable / temporary DNS absence.
    • Background paths exposed Write Sync error, failed flush/merge tasks, lock table bind changed, invalid timestamp, orphan-transaction errors, and context-deadline errors. These were recovery-window symptoms; no data corruption was observed.
    • After the TN endpoint was reattached, a fresh small write transaction succeeded and the recent backend-error stream stopped without a TN process restart, but recovery was not immediate.

    This extends the evidence beyond HAKeeper-only traffic: the same non-timeout MORPC failure classification can stall timestamp/lock/flush paths and create long tails while liveness probes remain positive.

  4. LeftHandCold commented on Aug 21, 2026

    @LeftHandCold
    Collaborator

    Reassessment against current main (2026-08-21)

    I traced the complete CN/TN heartbeat recovery path and ran deterministic counterfactual tests against current base/main (853fb9bf9b1d0ea1aa09b3cc7443ad3828ffab4a). The issue's reproduction commit (6f42b19508f31ef04ae2857172893f13d48afddf) is an ancestor, and the relevant paths are unchanged between the two commits:

    • pkg/common/morpc
    • pkg/logservice
    • pkg/cnservice/server_heartbeat.go
    • pkg/tnservice/store_heartbeat.go

    Conclusion

    The availability incident described here may be real, but the proposed root cause is not correct:

    can-retry=false does not make a long-lived CN/TN/proxy HAKeeper client permanently unusable.

    That flag only decides whether one physical remoteBackend generation retries the same failed Connect call in place. A non-timeout DNS/network error terminates that backend generation and returns ErrBackendCannotConnect; the outer MORPC client and managed HAKeeper client both have replacement paths.

    Therefore, the currently documented causal chain — non-timeout connect error -> permanently poisoned MORPC client -> no recovery until process restart — is disproved by both the implementation and deterministic tests. The underlying post-reconnect unavailability is not yet attributable to a specific MatrixOne defect with the evidence attached to this issue.

    Actual recovery path

    The relevant object hierarchy is:

    CN/TN heartbeat ticker
      -> managedHAKeeperClient
        -> hakeeperClient
          -> MORPC client
            -> remoteBackend (one physical connection generation)
    
    1. In remoteBackend.resetConn, DNS NXDOMAIN, network is unreachable, and connection refusal are classified as can-retry=false. This only stops in-place retry by the current physical backend.
    2. The failed backend becomes inactive/stopping. On a later Send, getBackendForOperation detaches inactive capacity and, with auto-create enabled by default, queues a new backend generation. The new generation resolves the address and connects again. The circuit breaker is disabled by default.
    3. CN/TN heartbeats have an additional recovery layer. SendCNHeartbeat and SendTNHeartbeat call resetClientIfCurrent for non-context failures. The next heartbeat prepares a new hakeeperClient, creates a new MORPC client, and runs CHECK_HAKEEPER again.
    4. CN and TN heartbeat tasks are ticker loops. A failed heartbeat logs and returns from that iteration; it does not terminate the task (CN loop, TN loop).
    5. HAKeeper does not permanently fence a CN UUID after expiry/deletion. A resumed heartbeat calls CNState.Update, which inserts a missing UUID and refreshes its tick.

    The can-retry=false branch itself dates to 2023; it is not a recent regression. PR #25869 was also checked as a candidate. It prevents a caller-scoped cancellation/deadline from closing a shared healthy HAKeeper client; an actual transport failure is still detected independently by MORPC's configured 8-second read timeout and enters the backend/client replacement path.

    Deterministic counterfactual results

    I used temporary diagnostic tests only; no product files were changed.

    MORPC-level test

    1. Start a real MORPC server and send successfully through one RPC client.
    2. Remove its endpoint.
    3. Observe a non-timeout connect failure, can-retry=false, and ErrBackendCannotConnect.
    4. Restore the same endpoint.
    5. Without recreating the outer RPC client, send again.
    6. Assert success and assert that the stopped backend was replaced by a new generation.

    Result: 20/20 passed.

    Managed HAKeeper-level test

    1. Start a real MORPC server implementing the HAKeeper check/heartbeat methods.
    2. Complete CHECK_HAKEEPER and a CN heartbeat.
    3. Remove the endpoint and observe the same can-retry=false branch.
    4. Restore the endpoint.
    5. Reuse the same managedHAKeeperClient object.
    6. Verify that it reconnects, runs CHECK_HAKEEPER again, and delivers another CN heartbeat.

    Result: 20/20 passed.

    These tests do not reproduce Docker's network namespace behavior, but they directly disprove the claimed state-machine failure: taking the exact non-timeout/ErrBackendCannotConnect branch does not leave the long-lived client permanently poisoned.

    How the reported evidence should be interpreted

    hakeeper.checker.cnservice.no.cn.found proves that, at that checker tick, HAKeeper had no working or expired CN entry. It does not identify why no heartbeat was accepted.

    Likewise, getent hosts logservice proves only that Docker DNS resolves the name. It does not prove that, from each CN/TN/proxy namespace:

    • TCP to logservice:32001 succeeds;
    • logservice accepts the connection on the restored network endpoint;
    • CHECK_HAKEEPER receives a valid response;
    • CN/TN heartbeats reach the HAKeeper state machine;
    • CNState ticks advance; or
    • proxy receives refreshed cluster details.

    If repeated can-retry=false / network is unreachable messages really occurred after 16:25:13 UTC, they point in the opposite direction from the current analysis: upper layers were creating/using connection generations and the network path was still failing from those containers. However, the issue currently contains summarized snippets rather than timestamped raw logs with backend IDs, so pre-restore failures cannot be separated from post-restore failures.

    The TN follow-up is also a counterexample to permanent client poisoning: after TN was reattached, a fresh write succeeded and the backend error stream stopped without restarting TN. The single-CN follow-up includes additional lock-table invalidation, gossip membership, scheduling, routing, and elapsed-time changes, so recovery after a CN restart does not isolate MORPC as the cause.

    Evidence required to pin the remaining root cause

    A corrected reproduction should preserve one aligned UTC timeline and capture the following before any service restart:

    Observation after reconnect Failure layer isolated
    DNS succeeds, TCP logservice:32001 fails Docker endpoint/route/alias/listener restoration
    TCP succeeds, no successful CHECK_HAKEEPER client creation/dial/request path
    CHECK_HAKEEPER succeeds, no heartbeat arrives managed client or heartbeat loop
    heartbeat arrives, CN UUID/tick does not update HAKeeper state machine
    CN UUID/tick is healthy, proxy reports no CN proxy cluster cache/routing
    proxy selects a CN, SQL still fails CN SQL listener/session path

    Please capture:

    • exact UTC timestamps for disconnect, reconnect, every SQL probe, and every restart;
    • getent plus a bounded TCP probe to logservice:32001 from each CN, TN, and proxy container;
    • docker network inspect before disconnect and after reconnect, including endpoint IPs, aliases, and routes;
    • raw MORPC logs containing backend ID/generation, connect start/failure/success, and backend creation;
    • logservice-side CHECK_HAKEEPER and heartbeat receipt;
    • HAKeeper CNState UUID, tick, and work state through the recovery window;
    • proxy cluster-detail refresh and selected-CN evidence.

    Recommendation

    Do not change resetConn to retry every non-timeout error based on this report. That would duplicate outer-generation recovery and could keep bad DNS/configuration, permanently refused endpoints, and obsolete backends alive longer, introducing lifecycle and availability regressions.

    I recommend keeping the availability symptom open only for a corrected evidence-bearing reproduction, while removing the current “permanently unusable MORPC client” root-cause claim. With the present artifacts there is no safe, evidence-backed MatrixOne patch to submit. The strongest unresolved hypothesis is incomplete Docker network/endpoint restoration from one or more service namespaces, but that remains a hypothesis until the layer-by-layer probes above are captured.

  5. added
    severity/s0
    and removed on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions