Skip to content

Two-node cluster: killing the JDBC_PING2 coordinator makes the survivor report split-brain and stay unready for ~40–70 s #55236

Description

@hacker-cb

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

infinispan

Bug Description

In a two-node cluster using the default jdbc-ping discovery (KEYCLOAK_JDBC_PING2), a sudden loss of the coordinator (kill -9, host loss) makes the surviving node log Split-brain detected ... This node ... is in the losing partition and should not be serving requests and report /health/ready as DOWN. The cluster has no ready node for roughly 40–70 seconds, until the dead coordinator's row in JGROUPS_PING goes stale.

The same happens in any cluster where a single node remains after the coordinator dies (e.g. three nodes, two consecutive failures without a node coming back). With three nodes and one failure there is no outage (2 : 1, the live partition wins).

Our reading of the 26.8.2 code:

  • KEYCLOAK_JDBC_PING2.healthStatus() (L370–L380) takes the rows with coord = true that are younger than staleness_timeout (60 s, L86), sorts them with SPLIT_BRAIN_DECIDER (L349–L351) — partition size, then address — and reports UNHEALTHY if the winner is not the coordinator of the local view.
  • After the coordinator dies, the new coordinator rewrites the rows of its own view, but removeAllNotInCurrentView() (L166–L186) only deletes entries "currently allocated to us". The dead coordinator's row is allocated to itself, so it stays with coord = true until it is older than staleness_timeout.
  • Addresses are assigned in start order (JGroupsConfigurator.prepareJGroupsAddress, L289), and the coordinator is the oldest member, so it has the lower address. With partitions of size 1 : 1 the tie is broken by address, and the dead coordinator wins.

Version

26.8.2

Regression

  • The issue is a regression

Expected behavior

When the coordinator of a two-node cluster dies, the survivor becomes the coordinator of a one-member view and stays ready. A member that the local view has already seen leave should not be able to win the split-brain decision.

Actual behavior

On the survivor, about 2 s after kill -9 of the coordinator:

ERROR [org.keycloak.jgroups.protocol.KEYCLOAK_JDBC_PING2] Split-brain detected for cluster 'ISPN'. This node (kc2-...) is in the losing partition and should not be serving requests

/health/ready turns to 503 ("Keycloak cluster health check" DOWN), and about 40–70 s later:

Cluster health restored for cluster 'ISPN'

Per-second snapshots of JGROUPS_PING during the window show two rows with coord = true: the dead coordinator's row (coordinated by itself) and the survivor's row — partitions 1 : 1.

Measurements on the stock image, no extensions:

2 nodes 3 nodes
Coordinator kills 4 14
Survivor not ready 4 of 4, from 2.1–3.5 s to 37.6–46.6 s after the kill 0 of 14
Split-brain detected 4 of 4, after 2.3–7.6 s; Cluster health restored after 42.3–47.7 s 0
Table after the view change partitions 1 : 1 — dead coordinator vs survivor partitions 1 : 2

Under login and refresh load behind a load balancer that checks /health/ready, the two-node case means 40–58 s with no node in rotation (3 of 3 runs).

How to Reproduce?

compose.yaml:

x-kc: &kc
  image: quay.io/keycloak/keycloak:26.8.2
  command: start
  environment:
    KC_DB: postgres
    KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
    KC_DB_USERNAME: keycloak
    KC_DB_PASSWORD: keycloak
    KC_HTTP_ENABLED: "true"
    KC_HOSTNAME_STRICT: "false"
    KC_HEALTH_ENABLED: "true"
    KC_BOOTSTRAP_ADMIN_USERNAME: admin
    KC_BOOTSTRAP_ADMIN_PASSWORD: admin
    KC_LOG_LEVEL: info,org.keycloak.jgroups.protocol.KEYCLOAK_JDBC_PING2:debug,org.jgroups.protocols.pbcast.GMS:debug
  healthcheck:
    test: ["CMD-SHELL", "exec 3<>/dev/tcp/127.0.0.1/9000 && printf 'GET /health/ready HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n' >&3 && head -n 1 <&3 | grep -q ' 200 '"]
    interval: 5s
    timeout: 5s
    retries: 60
    start_period: 20s

services:
  postgres:
    image: postgres:18.6
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: keycloak
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U keycloak -d keycloak"]
      interval: 2s
      timeout: 3s
      retries: 30
  kc1:
    <<: *kc
    hostname: kc1
    depends_on: { postgres: { condition: service_healthy } }
  kc2:
    <<: *kc
    hostname: kc2
    depends_on: { kc1: { condition: service_healthy } }
docker compose up -d --wait
docker compose kill -s SIGKILL kc1        # kc1 started first, so it is the coordinator
docker compose logs -f kc2                 # ~2 s: "Split-brain detected ... losing partition"; ~40–70 s: "Cluster health restored"
# meanwhile, /health/ready of kc2 (port 9000) answers 503

Reproduced on Keycloak 26.8.2 (Infinispan 16.0.15, JGroups 5.5.5.Final), PostgreSQL 18.6, Docker on Linux.

Anything else?

Possible directions, for the team to choose from:

  • break a tie in favour of the partition whose coordinator updated its row last, or ignore a coord = true row of a member that the checking node's current view has already seen leave;
  • let the new coordinator delete the row of the previous coordinator that left its view, instead of waiting for staleness_timeout;
  • make staleness_timeout configurable through a Keycloak option (it is not in JGroupsConfigurator.getProtocolConfigurations today).

Related, but not the same: #38550, #41290, #45980 (cluster formation and partitions), #46298 (node failure on Kubernetes).

Activity

  1. added
    status/labeled-by-bot
    on Nov 16, 2026
  2. added theissue type on Nov 16, 2026
  3. added
    kind/bug
    on Nov 16, 2026
  4. added
    area/infinispan
    on Nov 16, 2026
  5. added and removed
    priority/important
    on Nov 16, 2026
  6. changed the issue type fromtoon Nov 16, 2026
  7. added
    kind/enhancement
    and removed
    kind/bug
    on Nov 16, 2026
  8. ahus1 commented on Nov 16, 2026

    @ahus1
    Member

    Thanks for raising this issue. As the cluster automatically recovers, I see this as an enhancement, not a bug.

  9. ahus1 commented on Nov 16, 2026

    @ahus1
    Member

    As a workaround: On a system like Kubernetes, the health probe would need to fail several times before a Pod is taken out of rotation for the load balancer. You should be able to work around with that until a fix is available.

  10. added a commit that references this issue on Nov 16, 2026
    f6e31fa
  11. added a commit that references this issue on Nov 19, 2026
    7148a5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/infinispanbackport/26.8kind/enhancementpriority/normalrelease/27.0.0status/labeled-by-botteam/production-readiness

    Fields

    Value

    None yet

    Effort

    None yet

    Votes

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions