taka-2628 opened a new pull request, #178:
URL: https://github.com/apache/iotdb-client-go/pull/178

   ## Description
   
   `Session.initClusterConn()` builds its `TSOpenSessionReq` without a 
`Configuration` map, while `Session.Open()` and `Session.OpenCluster()` both 
populate `Configuration["sql_dialect"]`, `["version"]`, and `["db"]`. Since 
`reconnect()` — the sole transparent-reconnect path, invoked from every 
insert/query/execute method on a transport error — routes exclusively through 
`initClusterConn()`, any session that reconnects after a server restart 
silently reverts to the server-default dialect with no database bound.
   
   For table-model sessions this poisons the session: every subsequent 
statement is rejected with a `SqlParseError` (700) / `SemanticError` (701). 
Because these are valid server responses (`*ExecutionError`) rather than Go 
transport errors, `TableSessionPool.isConnectionError` returns false for them 
and the poisoned session is returned to the pool until the process restarts. 
The reference Java client re-sends this configuration on reconnect 
(`SessionConnection.init()` via `reconnect()`); the Go client did not.
   
   Full analysis, including the diagnosis path and the pool-poisoning 
mechanism, in #177.
   
   This bug exists because the same request-configuration block was 
hand-duplicated across three open paths and one copy was missed. This change 
extracts a single helper, `buildOpenSessionConfiguration`, and wires all three 
sites (`Open`, `OpenCluster`, `initClusterConn`) through it so they cannot 
drift again.
   
   `s.config` already carries `sqlDialect`/`Database` at reconnect time. 
Cluster sessions carry no `Version` (`ClusterConfig` has no such field), so for 
them the empty-`Version` → `DEFAULT_VERSION` fallback reproduces exactly what 
`OpenCluster()` already sends.
   
   ## Verification
   
   - **Reproduced and fixed against a live server.** 
`apache/iotdb:2.0.3-standalone` with a `TableSessionPool` bound to a database: 
insert (succeeds) → `docker restart` the server → insert again on the 
reconnected pooled session. On the current code the post-restart insert fails 
with `error code: 700 ... mismatched input 't' expecting ROOT` (session 
reverted to tree dialect); with this change the post-restart insert succeeds. 
Same test, only the library changed.
   - Added `TestBuildOpenSessionConfiguration` (table-driven, matching the 
existing `session_test.go` style). `go build ./...`, `go vet ./client/`, and 
`go test ./client/` pass.
   
   ## Out of scope (noted for maintainers)
   
   `initClusterConn` also never sets `s.timeFactor` via `getTimeFactor(resp)`, 
which `Open`/`OpenCluster` do — a reconnected session keeps a stale 
`timeFactor`. Benign on homogeneous clusters; happy to fold it into this PR if 
preferred.
   
   Fixes #177
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to