-
Notifications
You must be signed in to change notification settings - Fork 38
Call VerifySuccess before return to user #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR simplifies the Go client session APIs by internalizing TSStatus verification (VerifySuccess) and updating many write/DDL-style methods to return only error. This reduces the chance of callers forgetting to validate status codes and standardizes error handling across the client.
Changes:
- Refactors many
Sessionmethods to returnerroronly, callingVerifySuccessinternally after RPCs. - Updates table-session interfaces (
ITableSession) and session pool wrappers to match the simplified signatures. - Updates e2e tests and examples to use the new error-only APIs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
client/session.go |
Refactors many methods to return only error and verifies status internally. |
client/tablesession.go |
Updates ITableSession and TableSession methods to return error only. |
client/tablesessionpool.go |
Updates pooled table session wrappers to the new error-only API. |
test/e2e/e2e_test.go |
Adjusts e2e tests to the new error-only APIs. |
test/e2e/e2e_table_test.go |
Adjusts table e2e tests to the new error-only APIs. |
example/session_example.go |
Updates example code to handle error-only returns. |
example/session_pool/session_pool_example.go |
Updates session pool example code to handle error-only returns. |
example/table/table_session_example.go |
Updates table session example code to handle error-only returns. |
example/session_pool/table/table_session_pool_example.go |
Updates table session pool example code to handle error-only returns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (s *PooledTableSession) Insert(tablet *Tablet) error { | ||
| err := s.session.insertRelationalTablet(tablet) | ||
| if err == nil { | ||
| return | ||
| return nil | ||
| } | ||
| s.sessionPool.dropSession(s.session) | ||
| atomic.StoreInt32(&s.closed, 1) | ||
| s.session = Session{} | ||
| return | ||
| return err |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PooledTableSession.Insert now drops/invalidates the pooled session on any returned error. Since insertRelationalTablet now calls VerifySuccess internally, non-success server status codes (e.g., user/SQL/data errors) will also cause the session to be dropped even though the connection is still healthy. Consider only dropping the session for transport/connection errors, or otherwise preserve a way to distinguish retryable/connection failures from application-level status errors.
| func (s *PooledTableSession) ExecuteNonQueryStatement(sql string) error { | ||
| err := s.session.ExecuteNonQueryStatement(sql) | ||
| if err == nil { | ||
| return | ||
| return nil | ||
| } | ||
| s.sessionPool.dropSession(s.session) | ||
| atomic.StoreInt32(&s.closed, 1) | ||
| s.session = Session{} | ||
| return | ||
| return err |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PooledTableSession.ExecuteNonQueryStatement drops the underlying session for any error returned by Session.ExecuteNonQueryStatement. After this refactor, that error can come from VerifySuccess (i.e., a non-success TSStatus) and not necessarily a broken connection. Dropping the session for application-level errors can cause unnecessary churn in the pool; consider only dropping on connection/transport failures.
This pull request refactors the
Sessionmethods inclient/session.goto standardize error handling and simplify method signatures. The main change is that several methods which previously returned both a status and an error now return only an error, with status verification handled internally. This makes the API easier to use and less error-prone for clients.API simplification and error handling improvements:
SetStorageGroup,DeleteStorageGroup,DeleteStorageGroups,CreateTimeseries,CreateAlignedTimeseries,CreateMultiTimeseries,DeleteTimeseries,DeleteData,InsertStringRecord,SetTimeZone,ExecuteNonQueryStatement,InsertRecord,InsertAlignedRecord,InsertRecordsOfOneDevice,InsertAlignedRecordsOfOneDevice,InsertRecords, andInsertAlignedRecords) to return only anerrorinstead of both a status and an error. Status checking is now done internally usingVerifySuccess. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27]Internal logic and consistency improvements:
VerifySuccessafter RPC calls and to return early if an error is encountered, ensuring consistent error propagation and reducing code duplication. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27]These changes make the session API cleaner and help prevent misuse by encapsulating status verification and error handling within each method.