Skip to content

fix(deps): [OCISDEV-834] recover from dead NATS connections in nats-js-kv#12404

Merged
kobergj merged 1 commit into
owncloud:masterfrom
kobergj:fix/OCISDEV-834-natsjskv-hasconn-master
Jun 12, 2026
Merged

fix(deps): [OCISDEV-834] recover from dead NATS connections in nats-js-kv#12404
kobergj merged 1 commit into
owncloud:masterfrom
kobergj:fix/OCISDEV-834-natsjskv-hasconn-master

Conversation

@kobergj

@kobergj kobergj commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

The nats-js-kv go-micro store plugin's hasConn() only checked n.conn != nil, not whether the connection was still alive. Once the underlying NATS client exhausted its reconnect attempts (e.g. a NATS pod restart longer than the client's reconnect window), n.conn stayed non-nil but permanently closed. Because initConn() is gated on !hasConn(), it never re-ran, so every subsequent KV operation failed with nats: connection closed until the affected pod was restarted.

This is a base-layer bug in the store plugin used by every oCIS service backed by the NATS KV cache. Confirmed BYCS production manifestations:

  • storage-users → ListStorageSpaces: all spaces become invisible to all users (SE-1220, SE-1329, SE-1335)
  • ocs → signing-key: 500s, desktop client cannot construct signed download URLs, "X-Request Error downloading Files" (SE-1366)
  • sharing pods: same dead-connection symptom (SE-1335)

OPS workaround to date: rolling-restart the affected pod(s).

Fix

This is a dependency bump only. The replace directive for github.com/go-micro/plugins/v4/store/nats-js-kv is pointed at kobergj/plugins commit fc78af4, whose hasConn() now treats a closed connection as no connection:

func (n *natsStore) hasConn() bool {
    return n.conn != nil && !n.conn.IsClosed()
}

so the next operation transparently re-initializes the connection. (See go-micro/plugins#142 for the upstream change.)

No oCIS source changes — only go.mod, go.sum, the re-vendored plugin, and a changelog entry.

Already backported to stable-8.0 (#12401, merged) and stable-8.1 (#12402).

Follow-up (not in this PR)

The complementary proactive hardening from OCISDEV-834 — MaxReconnect=-1 + connection-state logging in reva's pkg/store, the loadAttributes cache-error tolerance in reva's messagepack_backend.go, and MaxReconnect on ocis-pkg/natsjsregistry — will land in a separate PR (the reva pieces require a reva change + pin bump first). This PR ships the load-bearing self-heal fix on its own.

Refs OCISDEV-834.

…s-kv

Bumps the kobergj/plugins nats-js-kv replace pin to fc78af4, which fixes
hasConn() to treat a permanently-closed NATS connection as no connection.
Previously hasConn() only checked n.conn != nil, so once the client
exhausted its reconnect attempts the connection stayed non-nil but dead,
initConn() never re-ran, and every KV operation failed with
'nats: connection closed' until the pod was restarted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com>
@kw-security

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kobergj kobergj merged commit 9eebf48 into owncloud:master Jun 12, 2026
60 checks passed
@kobergj kobergj deleted the fix/OCISDEV-834-natsjskv-hasconn-master branch June 12, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants