[
https://issues.apache.org/jira/browse/CALCITE-5077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515661#comment-17515661
]
liguozhong commented on CALCITE-5077:
-------------------------------------
from /usr/local/go/src/database/sql/driver/driver.go
I try to implement the SessionResetter interface of go sql to see if this can
solve this “NoSuchConnectionException” problem.
// Before a connection is returned to the connection pool after use, IsValid is
// called if implemented. Before a connection is reused for another query,
// ResetSession is called if implemented. If a connection is never returned to
the
// connection pool but immediately reused, then ResetSession is called prior to
// reuse but IsValid is not called.
// SessionResetter may be implemented by Conn to allow drivers to reset the
// session state associated with the connection and to signal a bad connection.
type SessionResetter interface {
// ResetSession is called prior to executing a query on the connection
// if the connection has been used before. If the driver returns ErrBadConn
// the connection is discarded.
ResetSession(ctx context.Context) error
}
// resetSession checks if the driver connection needs the
// session to be reset and if required, resets it.
func (dc *driverConn) resetSession(ctx context.Context) error {
dc.Lock()
defer dc.Unlock()
if !dc.needReset {
return nil
}
if cr, ok := dc.ci.(driver.SessionResetter); ok {
return cr.ResetSession(ctx)
}
return nil
}
> ResetSession implements driver.SessionResetter.
> -----------------------------------------------
>
> Key: CALCITE-5077
> URL: https://issues.apache.org/jira/browse/CALCITE-5077
> Project: Calcite
> Issue Type: Improvement
> Components: avatica-go
> Reporter: liguozhong
> Assignee: liguozhong
> Priority: Blocker
> Fix For: avatica-go-5.2.0
>
>
> avatica sql query fails after running for a period of time on our online
> loki, this PR attempts to solve this "NoSuchConnectionException" problem.
>
> level=error ts=2022-03-31T12:51:09.356233496Z caller=table_manager.go:233
> msg="error syncing tables" err="An error was encountered while processing
> your request: NoSuchConnectionException\{connectionId='Connection not found:
> invalid id, closed, or expired: ccd95a16-5496-7001-f99b-1ab0e5f19e05'}"
--
This message was sent by Atlassian Jira
(v8.20.1#820001)