Quorum-based scalable database system
Techniques are disclosed relating to a database system. The database system includes multiple coordinator nodes storing replicas of a partition. Each partition describes the state of locks and transactions for keys covered by that partition of keys. Each partition is, in turn, replicated. The multiple coordinator nodes receive, from multiple worker nodes, requests to grant a lock for a key to permit a worker node to write a record for the key as part of executing a transaction. A given coordinator node of the multiple coordinator nodes sends an approval response for the lock to at most one of the worker nodes. A single worker node acquires the lock in response to receiving approval responses from a majority of the multiple coordinator nodes, and none of the multiple worker nodes acquire the lock in response to none of them receiving approval responses from a majority of the multiple coordinator nodes.
1 . A method, comprising:
storing, by a plurality of coordinator nodes of a database system, a respective replica of a data partition, wherein the respective replica includes information about locks granted to ones of a plurality of worker nodes that perform database transactions;
determining, by a first coordinator node of the plurality of coordinator nodes, to relocate at least a portion of the respective replica to a second coordinator node;
copying, by the first coordinator node, the portion of the respective replica to the second coordinator node;
during the copying, receiving, by the plurality of coordinator nodes and the second coordinator node, requests from multiple worker nodes to grant a lock for a key that permits a worker node to write a record for the key as part of executing a database transaction;
determining, by multiple of the plurality of coordinator nodes and the second coordinator node independently, whether to grant the lock based on whether the lock conflicts with granted locks stored in their respective replica; and
sending, by a given coordinator node that determines to grant the lock, an approval response for the lock to at most one of the multiple worker nodes, wherein a single one of the multiple worker nodes acquires the lock in response to receiving approval responses from a majority of a quorum having ones of the plurality of coordinator nodes and the second coordinator node.
2 . The method of claim 1 , wherein the plurality of coordinator nodes form a first quorum for the data partition, and the second coordinator node and the plurality of coordinator nodes without the first coordinator node form a second quorum for the data partition, wherein, to acquire the lock, the single worker node has to acquire approval responses from a majority of coordinator nodes in at least one of the first and second quorums.
3 . The method of claim 1 , wherein a given one of the plurality of worker nodes is operable to issue requests to the second coordinator node for locks and to store new uncommitted work for the data partition in response to the first coordinator node determining to relocate the at least a portion of the first coordinator node's respective replica.
4 . The method of claim 1 , further comprising:
determining, by the first coordinator node based on a set of characteristics of the first coordinator node's respective replica, to locally split the first coordinator node's respective replica into a plurality of replicas corresponding to a plurality of subpartitions representing a splitting of the data partition; and
splitting, by the first coordinator node, the first coordinator node's respective replica into the plurality of replicas.
5 . The method of claim 4 , further comprises:
informing, by the first coordinator node, one or more of remaining ones of the plurality of coordinator nodes about the splitting to cause the one or more coordinator nodes to split their respective replica of the data partition.
6 . The method of claim 4 , wherein the plurality of replicas include fewer replicas than a number of replicas into which a third coordinator node of the plurality of coordinator nodes has split the third coordinator node's respective replica of the data partition.
7 . The method of claim 1 , further comprising:
determining, by the first coordinator node based on a set of characteristics of the first coordinator node's respective replica, to locally merge the first coordinator node's respective replica with a replica of an adjacent data partition into a single replica corresponding to a single data partition representing a merging of the data partition and the adjacent data partition; and
merging, by the first coordinator node, the first coordinator node's respective replica with the replica of the adjacent data partition into the single replica.
8 . The method of claim 7 , further comprising:
after the merging, the first coordinator node splitting the single data partition into a different number of data partitions than two data partitions.
9 . The method of claim 7 , wherein key ranges of the first coordinator node's respective replica and the replica of the adjacent data partition are adjacent.
10 . A non-transitory computer-readable medium having program instructions stored thereon that are capable of causing a computer system to implement a first coordinator node that performs operations comprising:
storing a replica of a data partition, wherein the replica includes information about locks granted to ones of a plurality of worker nodes that perform database transactions for a database system, and wherein the first coordinator node is one of a plurality of coordinator nodes that is operable to ensure transactional consistency for database transactions;
determining to relocate at least a portion of the replica to a second coordinator node;
copying the portion of the replica to the second coordinator node;
during the copying, receiving, from multiple worker nodes of the plurality of worker nodes, requests to grant a lock for a key that permits a worker node to write a record for the key as part of executing a database transaction, wherein the multiple worker nodes are operable to send requests to the second coordinator node to grant the lock; and
sending an approval response for the lock to at most one of the multiple worker nodes, wherein a single one of the multiple worker nodes acquires the lock in response to receiving approval responses from a majority of a quorum having ones of the plurality of coordinator nodes and the second coordinator node.
11 . The non-transitory computer-readable medium of claim 10 , wherein the operations further comprise:
performing a split operation on the replica to logically split the replica into two or more replicas corresponding to two or more subpartitions that represent a splitting of the data partition; and
performing a merge operation on the replica to logically merge the replica and another replica into a single replica corresponding to a single partition representing a merging of two partitions, wherein the split and merge operations are performed independent of other ones of the plurality of coordinator nodes.
12 . The non-transitory computer-readable medium of claim 10 , wherein the operations further comprise:
removing committed records from the replica based on committed records associated with the replica being persisted in a persistent store.
13 . The non-transitory computer-readable medium of claim 10 , wherein the operations further comprise:
receiving a different replica from a different coordinator node of the database system; and
while information of the different replica is being received, process requests from ones of the plurality of worker nodes, wherein processing at least one of the requests includes storing a lock in the different replica that is granted in association with the at least one request.
14 . A system, comprising:
at least one processor; and
memory having program instructions stored thereon that are executable by the at least one processor to cause the system to implement a first coordinator node that performs operations comprising:
storing a replica of a data partition, wherein the replica includes information about locks granted to ones a plurality of worker nodes that perform database transactions for a database system, and wherein the first coordinator node is one of a plurality of coordinator nodes that is operable to ensure transactional consistency for database transactions;
determining to relocate at least a portion of the replica to a second coordinator node;
copying the portion of the replica to the second coordinator node;
during the copying, receiving, from multiple worker nodes of the plurality of worker nodes, requests to grant a lock for a key that permits a worker node to write a record for the key as part of executing a database transaction, wherein the multiple worker nodes are operable to send requests to the second coordinator node to grant the lock; and
sending an approval response for the lock to at most one of the multiple worker nodes, wherein a single one of the multiple worker nodes acquires the lock in response to receiving approval responses from a majority of a quorum having ones of the plurality of coordinator nodes and the second coordinator node.
15 . The system of claim 14 , wherein the operations further comprise:
performing a split operation on the replica to logically split the replica into two or more replicas corresponding to two or more subpartitions that represent a splitting of the data partition, wherein the portion corresponds to one of the two or more replicas.
16 . The system of claim 14 , wherein the operations further comprise:
receiving a different replica from a different coordinator node of the database system; and
performing a merge operation to logically merge the replica and the different replica into a single replica corresponding to a single data partition.
17 . The system of claim 14 , wherein the operations further comprise:
receiving a different replica from a different coordinator node of the database system; and
while information of the different replica is being received, process requests from ones of the plurality of worker nodes, wherein processing at least one of the requests includes storing a lock in the different replica that is granted in association with the at least one request.
18 . The system of claim 14 , wherein the operations further comprise:
removing committed records from the replica based on committed records associated with the replica being persisted in a persistent store.