ydb-go-sdk icon indicating copy to clipboard operation
ydb-go-sdk copied to clipboard

bug: Session leak on Table().Do()

Open rekby opened this issue 1 year ago • 0 comments

Bug Report

YDB GO SDK version: 3.74.7

Reproduced on local ydb.

Code:

Details
	ctx := context.Background()
	db := must(ydb.Open(
		ctx,
		connectionString,
		yc.WithInternalCA(),
		ydb.WithAccessTokenCredentials(internalOAuthToken),
		// yc.WithServiceAccountKeyFileCredentials(serviсeAccountFile),
		// ydb.WithDiscoveryInterval(time.Second),
		ydb.WithLogger(log.Default(os.Stderr), trace.DetailsAll),
	))

	for {
		readCtx, cancel := context.WithTimeout(ctx, time.Millisecond*10)
		_ = db.Table().Do(readCtx, func(ctx context.Context, s table.Session) error {
			_, res, err := s.Execute(ctx, table.SerializableReadWriteTxControl(table.CommitTx()), "SELECT 1", nil)
			if res != nil {
				res.Close()
			}
			switch {
			case err == nil:
				return nil
			case ydb.IsTransportError(err):
				return err
			case ctx.Err() != nil:
				return nil
			default:
				panic(err)
			}
		})
		cancel()
	}

Session leaks can see on diagnostics page: http://localhost:8765/actors/kqp_proxy

Active session_actors count on node: 167

rekby avatar Jun 25 '24 15:06 rekby