Add atomic increment/decrement operations to Spanner
(There should be a separate section of this forum for Spanner)
I'd like Spanner to offer a simple API for atomically incrementing or decrementing a counter. Currently, we have to read a record, increment and write back. Compared to regular SQL
SET x = x + 1, or DynamoDB which offers an increment operation, this is much more programmer overhead.
Plus, it allows race conditions where multiple writers are incrementing a column, even given Spanner's external strong consistency, if both read the same value before one writes back an incremented amount. This makes it hard to keep denormalised counts accurate over time.