Skip to content

Conversation

@HTHou
Copy link
Contributor

@HTHou HTHou commented Feb 11, 2026

This pull request refactors the Session methods in client/session.go to 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:

  • Changed multiple methods (such as SetStorageGroup, DeleteStorageGroup, DeleteStorageGroups, CreateTimeseries, CreateAlignedTimeseries, CreateMultiTimeseries, DeleteTimeseries, DeleteData, InsertStringRecord, SetTimeZone, ExecuteNonQueryStatement, InsertRecord, InsertAlignedRecord, InsertRecordsOfOneDevice, InsertAlignedRecordsOfOneDevice, InsertRecords, and InsertAlignedRecords) to return only an error instead of both a status and an error. Status checking is now done internally using VerifySuccess. [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:

These changes make the session API cleaner and help prevent misuse by encapsulating status verification and error handling within each method.

@HTHou HTHou changed the title Call VerifySuccess before return to User Call VerifySuccess before return to user Feb 11, 2026
Copy link

Copilot AI left a 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 Session methods to return error only, calling VerifySuccess internally 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.

Comment on lines +83 to +91
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
Copy link

Copilot AI Feb 11, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +109
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
Copy link

Copilot AI Feb 11, 2026

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.

Copilot uses AI. Check for mistakes.
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.

1 participant