Database / Google Spanner Database Interview questions
Explain the execution flow of a read-write transaction in Spanner?
A read-write transaction in Spanner moves through acquisition of locks, buffered writes, and a two-phase commit if the transaction spans more than one split.
Reads within the transaction take shared locks on the rows they touch, and writes take exclusive locks, held until commit or abort. If the transaction only touches one split, the leader for that split can commit directly through its own Paxos group. If it spans multiple splits, one participant is chosen as the transaction coordinator, running two-phase commit: it collects a "prepared" vote from every participant group, then picks a commit timestamp using TrueTime and applies commit wait before releasing locks and returning success to the client. Any lock conflict with a concurrent transaction can cause an abort, which the client library typically retries transparently.
More Related questions...