Skip to content

spanner: Add lastUseTime parameter to session #8943

@harshachinta

Description

@harshachinta

In the current golang implementation, there is no track of when the session was last used with in a transaction. This would be helpful to implement session leaks cleanup and other behaviours of session.

  1. Add a new field lastuseTime in sessionHandle similar to Java client to keep track of when the session was last used in a transaction.
  2. If we make successive RPC calls within a transaction, this parameter is not tracked, and should get updated with subsequent RPC calls. For ex, consider the below sample,
_, err := client.ReadWriteTransaction(ctx, func(ctx context.Context, tx *ReadWriteTransaction) error {
	// first RPC, session lastUseTime should be updated
	_, err := tx.Update(ctx, NewStatement(UpdateBarSetFoo))
	if err != nil {
		return err
	}

	// second rpc, session lastUseTime should be updated
	_, err = tx.Update(ctx, NewStatement(UpdateBarSetFoo))
	if err != nil {
		return err
	}

	return nil
})

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions