[Bug]: A gateway shows as inactive while another platform-api replica still holds its session

Aperta
#4,321 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go, postgresql

Direzione di ricerca

Start with platform-api/internal/handler/websocket.go around line 170 and trace how session closure updates the gateway's active state. Check how gateway sessions are represented across replicas and whether the shared Postgres-backed state can determine if any session remains. Done means isActive stays true when another replica still has a live session; add or update coverage for the two-replica case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area/Platform-API Aspect/API Severity/Major Type/Bug
Please select the area the issue is related to

Platform API

Please select the aspect the issue is related to

Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)

Description

With more than one platform-api replica, a gateway is reported as inactive ("isActive": false) while it still has a live session on another replica.

When a gateway's WebSocket session closes, the replica that held it marks the whole gateway inactive if that replica has no other session for it (platform-api/internal/handler/websocket.go:170, len(h.manager.GetConnections(gateway.ID)) == 0). GetConnections only knows this replica's in-memory sessions, so a session the gateway holds on another replica is not counted.

A gateway can have two active tokens, and so two controllers connected at once, each possibly on a different replica. In that case, when one session ends, the gateway shows inactive while the other is still connected and serving. The console shows such a gateway as "Not Active" and greys out its Deploy button (seen on the Deploy page for an inactive gateway).

Since #4315 (revoking a token closes the sessions opened with it), revoking one of the two tokens also triggers this.

Expected: isActive stays true while any replica holds a session for the gateway.
Actual: it becomes false as soon as one replica loses its last session for that gateway.

Related: #1185 (reconnect not updating the state, single replica; closed).

Steps to Reproduce
  1. Run two platform-api replicas, P1 and P2, on one shared Postgres database, each on its own ports.
  2. Register a gateway (POST /api/v0.9/gateways) and mint two tokens for it (POST /api/v0.9/gateways/<id>/tokens twice).
  3. Start one gateway controller with token 1, connected to P1, and a second controller for the same gateway with token 2, connected to P2.
  4. GET /api/v0.9/gateways/<id> returns "isActive": true; P1 and P2 each hold one session for the gateway.
  5. Stop the first controller (docker stop <controller-1>). P1 logs WebSocket connection closed for its session.
  6. GET /api/v0.9/gateways/<id> returns "isActive": false at 2, 8 and 30 seconds after the stop. The second controller is still running and connected to P2, which still holds its session.
Severity Level of the Issue

Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)

Environment Details (with versions)
  • Source: main at a9992d2fe.
  • Two platform-api replicas built from source, sharing a postgres:17-alpine database (schema from schema.postgres.sql).
  • Gateway controllers and runtimes built from that commit (version 2026.09.24).
  • macOS with Rancher Desktop.
Lingua principale
Go
Stelle
85
Fork
137
Merge medio
1g 12h
PR unite (30g)
247

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wso2/api-platform

Tutte le issue di wso2/api-platform

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.