Skip to content

fix: reconnect when CAS released under KEEP_CONNECTION=AUTO - #12

Merged
yeongseon merged 2 commits into
cubrid-lab:mainfrom
paikend:fix/cas-reconnect-on-inactive
Jul 26, 2026
Merged

fix: reconnect when CAS released under KEEP_CONNECTION=AUTO#12
yeongseon merged 2 commits into
cubrid-lab:mainfrom
paikend:fix/cas-reconnect-on-inactive

Conversation

@paikend

@paikend paikend commented Mar 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Add checkReconnect() that inspects CAS_INFO[0] status before each request and transparently reconnects when the broker has released the CAS process (KEEP_CONNECTION=AUTO, the default)
  • Update CAS_INFO from every response in sendAndRecv() (was missing)
  • Return driver.ErrBadConn on socket errors so database/sql can retry with a fresh connection

Root Cause

The CUBRID broker may release the CAS process after a transaction commit when KEEP_CONNECTION=AUTO. This sets CAS_INFO[0] to INACTIVE (0). Subsequent requests on the dead socket cause EOF / broken pipe.

Approach

Ported the same reconnection pattern used by the official CUBRID JDBC driver (UClientSideConnection.checkReconnect()). The same fix was applied to:

Test plan

  • DDL → DML sequence (autocommit=true) — failed before fix, passes after
  • DDL → DML sequence (autocommit=false) — passes
  • go build ./... — no compilation errors

🤖 Generated with Claude Code

paikend and others added 2 commits March 26, 2026 12:36
The CUBRID broker may release the CAS process after a transaction commit
when KEEP_CONNECTION=AUTO (the default). This sets CAS_INFO[0] to INACTIVE.
Subsequent requests on the dead socket cause EOF / broken pipe.

Port the same reconnection pattern used by the official JDBC driver
(UClientSideConnection.checkReconnect):

- Add checkReconnect() that inspects CAS_INFO status before each request
- Update CAS_INFO from every response in sendAndRecv()
- Return driver.ErrBadConn on socket errors so database/sql retries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@paikend
paikend force-pushed the fix/cas-reconnect-on-inactive branch from 9b51955 to 21e023c Compare March 26, 2026 12:32
@yeongseon
yeongseon merged commit e9db355 into cubrid-lab:main Jul 26, 2026
11 of 17 checks passed
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.

2 participants