A non-transitory computer-readable storage medium, storing one or more instructions, the one or more instructions, when executed by one or more processors of a first electronic device of a plurality of electronic devices, cause the first electronic device to perform operations for processing transactions of a database system, the operations comprising:
- determining a concurrent transaction of a target transaction, the concurrent transaction and the target transaction include a read-write operation acting on a same variable, and the target transaction is a transaction to be committed;
- storing, as a hash table in an internal memory of the first electronic device, a read set of the target transaction, a write set of the concurrent transaction, a write set of the target transaction, and a read set of the concurrent transaction;
- obtaining, according to the hash table stored in the internal memory, a first intersection between the read set of the target transaction and the write set of the concurrent transaction;
- obtaining, according to the hash table stored in the internal memory, a second intersection between the write set of the target transaction and the read set of the concurrent transaction;
- in accordance with a determination that at least one of the first intersection and the second intersection is a non-empty data set, determining that the target transaction conflicts with the concurrent transaction;
- determining, based on a version change count of the same variable on which the target transaction and the concurrent transaction act and a target variable list, a data anomaly type, the target variable list including the same variable on which the target transaction and the concurrent transaction act;
- obtaining a first conflict cycle graph that represents an association between the concurrent transaction and the target transaction, the conflict cycle graph including a plurality of vertices representing transaction identifiers corresponding to transactions and a plurality of edges representing an association between the transactions and variables on which a read-write operation corresponding to the transactions acts;
- determining a transaction to be rolled back from the target transaction and the concurrent transaction;
- obtaining, for the target transaction and the concurrent transaction, a global commit timestamp generated by a global timestamp generating cluster, wherein the global commit timestamp is a timestamp identifier that is (a) globally unique across the plurality of electronic devices, (b) monotonically increasing, and (c) indicative of a chronological order in which all transactions are globally committed;
- rolling back the transaction, including coordinating rollback and commit by applying (i) the global commit timestamp so as to reflect relationships between transactions according to the chronological order in which the transactions are globally committed and (ii) a two-phase commit (2PC) protocol, wherein an electronic device of the plurality of electronic devices is a coordinator in the 2PC protocol and remaining electronic devices of the plurality of electronic devices are participants in the 2PC protocol;
- after the rolling back the transaction, generating an updated conflict cycle graph, including deleting a variable on which the transaction acts and a corresponding read-write operation from the initial conflict cycle graph;
- determining, according to the updated conflict cycle, that the target transaction no longer conflicts with the concurrent transaction;
- and
- in accordance with the determination that the target transaction no longer conflicts with the concurrent transaction, merging the target transaction and the concurrent transaction to obtain a merged transaction.