googleapis / googleapis/google-cloud-go

datastore: Transaction appears to be unsafe to use concurrently

Open
#3,750 1 comment 0 reactions 1 assignee Assigned to @bhshkh View on GitHub
api: datastore priority: p2 type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

**Client**

Datastore

**Environment**

Any

**Go Environment**

Any

**Code**

e.g. https://github.com/googleapis/google-cloud-go/blob/master/datastore/transaction.go#L311

At least the `mutations` field is unguarded by any synchronization mechanism, but the `pending` field is also suspect.

This is a seeming departure from the GAE version of the library e.g. (https://github.com/golang/appengine/blob/master/datastore/datastore.go#L351) where Put requests translated directly to a (concurrency safe) RPC which included the transaction ID as part of the RPC. Direct translations of older GAE code to use the new datastore library could introduce subtle concurrency bugs.

I believe adding mutex would be sufficient to protect the Transaction struct's integrity... however if this is infeasible, it would be great to explicitly call out on Transaction that it is NOT concurrency-safe.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.