for the second part, have you seen write preconditions? they may help with the notion of a race condition. because there isn't a locking primitive, you'd need to potentially retry a write, but it sidesteps the question of writing an external locking mechanism.