Dynamic snapshot isolation protocol selection
Technologies are described for facilitating the processing of requests for database operations in a distributed database environment. Criteria are defined for processing a request for a database operation according to first or second snapshot isolation protocols. A request for a database operation is received and it is determined if the snapshot isolation protocol criteria are met. If the criteria are met, the request can be processed using a local snapshot identifier value of a worker node. If the criteria are not met, the local snapshot identifier value is synchronized with another node, and the request processed using the updated snapshot identifier value.
1. A method, implemented at least in part by a first worker node comprising a processing unit and memory, the first worker node being in communication with a coordinator node and at least a second worker node, for facilitating executing requests for database operations within a distributed database environment, the method comprising:
receiving a first request for a database operation to read or write data to a database implemented in the distributed database environment;
determining criteria specified in the first request for initiating execution of the first request at the first worker node using a current local snapshot identifier value of the first worker node, if the criteria are not met the first worker node requests a global snapshot identifier value from the coordinator node before the initiating execution of the first request, and wherein a snapshot identifier value determines a state of the database used in executing the first request for a database operation, and the database state determines a particular set of values that are available for reading or updating during execution of the first request;
determining that the criteria are met;
in response to determining that the criteria are met, initiating execution of the first request at the first worker node using the current local snapshot identifier value; and
returning execution results for the first request to a database client.
2. The method of claim 1 , the method further comprising:
receiving a second request for a database operation;
determining criteria for executing the second request using a current local snapshot identifier value of the first worker node;
determining that the criteria are not met;
requesting a current global snapshot identifier value from the coordinator node;
receiving the current global snapshot identifier value from the coordinator node;
assigning the global snapshot identifier value as an updated current local snapshot identifier value; and
executing the second request using the updated current local snapshot identifier value.
3. The method of claim 2 , wherein the criteria for executing the first request comprises a threshold lag value and determining that the criteria are met comprises:
determining a time the current local snapshot identifier value was synchronized with the coordinator node;
determining a difference between a current time and the time the current local snapshot identifier value was synchronized with the coordinator node; and
determining that the difference does not satisfy the threshold lag value.
4. The method of claim 2 , the method further comprising:
recording a time associated with assigning the global snapshot identifier value as an updated current local snapshot identifier value.
5. The method of claim 1 , wherein the criteria for executing the first request comprises a result lag value specified in the first request.
6. The method of claim 5 , wherein the result lag value is specified in a query language.
7. The method of claim 1 , wherein the criteria for executing the first request comprises a result lag value specified as a number of seconds.
8. The method of claim 1 , wherein the criteria for executing the second request comprises a default lag value.
9. The method of claim 1 , wherein the criteria for executing the first request comprises a threshold lag value and determining that the criteria are met comprises:
determining a time the current local snapshot identifier value was synchronized with the coordinator node;
determining a difference between a current time and the time the current local snapshot identifier value was synchronized with the coordinator node; and
determining that the difference satisfies the threshold lag value.
10. The method of claim 1 , the method comprising:
synchronizing the local snapshot identifier with a global snapshot identifier; and
recording a time associated with the synchronization.
11. The method of claim 10 , wherein the synchronizing comprises:
receiving a second request for a database operation;
requesting a current value of a global snapshot identifier from the coordinator node;
receiving the current value of the global snapshot identifier from the coordinator node;
assigning the current value of the global snapshot identifier as an updated current value of the local snapshot identifier;
recording a time associated with the assigning;
executing the second request; and
returning execution result for the second request to the database client.
12. The method of claim 10 , wherein the synchronizing comprises:
receiving a request from a database node for the current local snapshot identifier value;
sending the current local snapshot identifier value to the database node;
receiving a snapshot identifier value from the database node;
assigning the snapshot identifier value as an updated current value of the local snapshot identifier; and
recording a time associated with the assigning.
13. The method of claim 1 , the method further comprising:
sending the current local snapshot identifier value and at least a portion of the request to the second worker node for execution; and
receiving execution results from the second worker node.
14. A server comprising a processing unit and memory, wherein the server is configured to operate a first worker node of a database system, the first worker node being in communication with a coordinator node, and the database system further including at least a second worker node, wherein the server is further configured to perform database transaction processing comprising:
receiving a request for a database operation to read or write data to the database system, the request comprising semantic information for determining a snapshot isolation protocol of a plurality of available snapshot isolation protocols to be applied to the request, wherein snapshot isolation protocols of the plurality of available snapshot isolation protocols are different than one another;
synchronizing a local snapshot identifier with a global snapshot identifier maintained by the coordinator node;
recording a time of the synchronizing;
comparing the semantic information with the synchronization time;
based at least in part on the comparing, determining a selected snapshot isolation protocol of the plurality of snapshot isolation protocols to be used with the request;
assigning a snapshot timestamp value to the request according to the selected snapshot isolation protocol;
executing the request; and
returning execution results to a database client.
15. The server of claim 14 , wherein the semantic information is specified in a query language.
16. The server of claim 14 , wherein the semantic information specifies a threshold time between a current time and a time the first worker node synchronized with the coordinator node.
17. The server of claim 16 , the processing further comprising:
determining that the threshold is satisfied.
18. One or more tangible computer-readable media storing computer-executable instructions for causing a server programmed thereby to perform processing of requests for database operations within a database environment implementing a distributed database system using query language statements, the server implementing a first worker node of a database system, the first worker node being in communication with a coordinator node, and the database system further including at least a second worker node, the database transaction processing comprising:
receiving a first multi-node query language statement to read or write data to the distributed database system, the first multi-node query language statement comprising a result lag time value;
determining a difference between a current time and a time the first worker node synchronized a local snapshot identifier with a global snapshot identifier;
determining that the difference is less than, or less than or equal to, the result lag time value specified in the first multi-node query langue statement;
assigning the local snapshot identifier to the multi-node query language statement;
executing the first multi-node query language statement; and
returning execution results of the first multi-node query language statement to a database client.
19. The one or more tangible computer-readable media of claim 18 , the processing further comprising:
synchronizing the local snapshot identifier with the global snapshot identifier; and
recording a time associated with the synchronization.
20. The one or more tangible computer-readable media of claim 18 , the processing further comprising:
receiving a second multi-node query language statement, the second multi-node query language statement comprising a result lag time value;
determining that the difference is greater than, or greater than or equal to, the result lag value of the second-multi node query language statement;
requesting a current global snapshot identifier value from the coordinator node;
receiving the current global snapshot identifier value from the coordinator node;
assigning the current global snapshot identifier value as the local snapshot identifier value;
recording a time associated with the assigning;
assigning the assigned local snapshot identifier value to the second multi-node query language statement;
executing the second multi-node query language statement; and
returning execution results of the second multi-node query language statement to the database client.