IP Library Granted Patent US 12699684
Granted Patent B2
US 12699684 · App. 18/996,662 · Granted Aug 4, 2026

Transaction processing method, device, and storage medium

Inventors: Ziliang Lai (Hangzhou, CN); Hua Fan (Hangzhou, CN); Wenchao Zhou (Hangzhou, CN); Zhanfeng Ma (Hangzhou, CN); Xiang Peng (Hangzhou, CN); Feifei Li (Hangzhou, CN)
Assignee: CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PRIVATE LIMITED
G06F16/2343G06F9/466G06F16/2322
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12699684
App. No.
18/996,662
Granted
Aug 4, 2026
Kind
B2
Abstract

Embodiments of the present application provide a transaction processing method, a device, and a storage medium. For a distributed transaction, it is proposed innovatively that exclusive locks are added to data records involved in a read set of the distributed transaction in a read phase; in a write phase, write operations for a write set can be directly executed based on these exclusive locks, and an exclusive lock on a related data record can be released immediately after a write operation is completed. In the write phase, the exclusive locks added to the data records can maintain the exclusivity of the distributed transaction over these data records, which can avoid the write operation abort problem in the write phase.

Claims (77)

1 . A transaction processing method, applied to a transaction coordinator of a distributed system, the method comprising:

receiving a processing request for a target transaction;

determining that the target transaction is a distributed transaction, thereby acquiring in a read phase of the target transaction, an exclusive lock for each data record involved in a read set of the target transaction;

calculating a write set of the target transaction;

releasing an exclusive lock on a data record in the read set on which a write operation does not require to be executed;

in a write phase of the target transaction, releasing an exclusive lock on a related data record after completing a write operation for the write set based on the exclusive lock;

determining, based on logical timestamps respectively corresponding to transactions processed on the transaction coordinator, a minimum logical timestamp of non-persisted transactions on the transaction coordinator as a shard timestamp on the transaction coordinator;

acquiring shard timestamps provided by other shards;

taking a minimum value of shard timestamps respectively corresponding to all shards as a global timestamp; and

determining that the target transaction has completed global persistence processing based on a logical timestamp of the target transaction is less than the global timestamp.

2 . The method according to claim 1 , wherein acquiring, in the read phase of the target transaction, the exclusive lock for each data record involved in the read set of the target transaction comprises:

determining a local data record belonging to the transaction coordinator in the read set;

adding an exclusive lock to the local data record;

triggering a transaction participant to which a non-local data record in the read set belongs to add an exclusive lock to the corresponding data record.

3 . The method according to claim 2 , wherein releasing the exclusive lock on the data record in the read set on which the write operation does not require to be executed comprises:

in the write phase of the target transaction, if any local data record in the read set is determined as no write operation being required to be executed thereon, releasing the exclusive lock on the local data record.

4 . The method according to claim 1 , further comprising:

in the read phase of the target transaction, running pieces of statement logic in the target transaction;

if there is remote read logic in the pieces of statement logic, determining that the target transaction is the distributed transaction.

5 . The method according to claim 4 , further comprising:

if there is no remote read logic in the pieces of statement logic, determining that the target transaction is a local transaction;

in a case that the target transaction is the local transaction, executing a read operation in the read phase of the target transaction in a lock-free manner to obtain the read set of the target transaction;

acquiring, in the write phase of the target transaction, an exclusive lock for each data record involved in the write set of the target transaction to execute a write operation.

6 . The method according to claim 1 , wherein calculating the write set of the target transaction comprises:

calculating the write set of the target transaction in the read phase of the target transaction;

caching the write set locally on the transaction coordinator for being invoked in the write phase.

7 . The method according to claim 1 , wherein in the write phase of the target transaction, releasing the exclusive lock on the related data record after completing the write operation for the write set based on the exclusive lock comprises:

in the write phase of the target transaction, determining a local data record belonging to the transaction coordinator in the write set;

releasing an exclusive lock on the local data record after completing a write operation based on the exclusive lock on the local data record;

initiating, for each non-local data record in the write set, a write operation to a transaction participant to which the non-local data record belongs, so that the transaction participant releases an exclusive lock on the corresponding data record after responding to the write operation.

8 . The method according to claim 1 , further comprising:

in the write phase of the target transaction, allocating a logical timestamp to the target transaction, wherein the logical timestamp is allocated based on an execution order of transactions;

if a read timestamp of a local data record belonging to the transaction coordinator in the read set is less than the logical timestamp of the target transaction, updating the read timestamp of the local data record to the logical timestamp of the target transaction;

updating a read timestamp and a write timestamp of a local data record belonging to the transaction coordinator in the write set to the logical timestamp of the target transaction; and

sending the logical timestamp of the target transaction to a transaction participant involved in the write set, so that the transaction participant updates, based on the logical timestamp of the target transaction, a read timestamp and/or a write timestamp of a data record carried by the transaction participant in the read set and/or the write set.

9 . The method according to claim 8 , further comprising:

if it is determined that the target transaction is a local transaction, performing consistency verification based on a read timestamp and/or a write timestamp possessed by a local data record belonging to the transaction coordinator in a read set of the target transaction.

10 . The method according to claim 1 , further comprising:

in a case that a shard failure occurs, acquiring a recovery timestamp, wherein the recovery timestamp is a maximum value of global timestamps determined on all shards; and

rolling back a transaction processed after the recovery timestamp.

11 . The method according to claim 1 , further comprising:

if there is a special transaction to which a logical timestamp is not allocated on the transaction coordinator, taking a write timestamp on a data record first accessed by the special transaction as a lower limit of a logical timestamp of the special transaction, wherein the lower limit of the logical timestamp, instead of a logical timestamp, is used as a basis for determining a shard timestamp.

12 . The method according to claim 1 , further comprising:

after determining the shard timestamp on the transaction coordinator, if the transaction coordinator subsequently serves as a coordinator of a new transaction, allocating a logical timestamp not less than the shard timestamp to the new transaction;

if the transaction coordinator subsequently serves as a participant of a new transaction, updating a write timestamp of a data record carried by the participant in a write set of the new transaction to be not less than the shard timestamp of the participant, so as to drive a coordinator of the new transaction to allocate a logical timestamp not less than the shard timestamp to the new transaction.

13 . A transaction processing method, applied to a transaction participant of a distributed system, the method comprising:

determining that a target transaction is a distributed transaction to receive a remote read operation initiated by a transaction coordinator of the target transaction in a read phase of the target transaction;

in the read phase, adding an exclusive lock to a data record requested by the remote read operation;

in a write phase of the target transaction, receiving a remote write operation initiated by the transaction coordinator thereby responding to the remote write operation and releasing an exclusive lock on a corresponding data record;

determining, based on logical timestamps respectively corresponding to transactions processed on the transaction participant, a minimum logical timestamp of non-persisted transactions on the transaction participant as a shard timestamp on the transaction participant; and

providing the shard timestamp of the transaction participant to the transaction coordinator of the target transaction, so that the transaction coordinator takes a minimum value of shard timestamps respectively corresponding to all shards as a global timestamp, and determines that the target transaction has completed global persistence processing based on a logical timestamp of the target transaction is less than the global timestamp.

14 . The method according to claim 13 , further comprising:

acquiring a logical timestamp allocated by the transaction coordinator to the target transaction, wherein the logical timestamp is allocated based on an execution order of transactions;

in the read phase, if a read timestamp of the data record corresponding to the remote read operation is less than the logical timestamp of the target transaction, updating the read timestamp of the data record corresponding to the remote read operation to the logical timestamp of the target transaction;

in the write phase, updating a read timestamp and a write timestamp of the data record corresponding to the remote write operation to the logical timestamp of the target transaction.

15 . The method according to claim 14 , further comprising:

if the transaction participant serves as a transaction coordinator of another transaction, performing, in a case that the another transaction is a local transaction, consistency verification based on a read timestamp and/or a write timestamp of a local data record in a read set of the another transaction.

16 . The method according to claim 13 , further comprising:

after determining the shard timestamp, if the transaction participant subsequently serves as a coordinator of a new transaction, allocating a logical timestamp not less than the shard timestamp to the new transaction; and

if the transaction participant subsequently serves as a participant of a new transaction, updating a write timestamp of a data record carried by the participant in a write set of the new transaction to be not less than the shard timestamp, so as to drive a coordinator of the new transaction to allocate a logical timestamp not less than the shard timestamp to the new transaction.

17 . A transaction coordinator of a distributed system, comprising a memory, a processor, and a communication component;

the memory is configured to store one or more computer instructions;

the processor is coupled to the memory and the communication component, and is configured to execute the one or more computer instructions to:

receive a processing request for a target transaction through the communication component;

determining that the target transaction is a distributed transaction, thereby acquiring, in a read phase of the target transaction, an exclusive lock for each data record involved in a read set of the target transaction;

calculate a write set of the target transaction;

release an exclusive lock on a data record in the read set on which a write operation does not require to be executed;

in a write phase of the target transaction, release an exclusive lock on a related data record after completing a write operation for the write set based on the exclusive lock;

determine, based on logical timestamps respectively corresponding to transactions processed on the transaction coordinator, a minimum logical timestamp of non-persisted transactions on the transaction coordinator as a shard timestamp on the transaction coordinator;

acquire shard timestamps provided by other shards;

take a minimum value of shard timestamps respectively corresponding to all shards as a global timestamp; and

determine that the target transaction has completed global persistence processing based on a logical timestamp of the target transaction is less than the global timestamp.

18 . A transaction participant of a distributed system, comprising a memory, a processor, and a communication component;

the memory is configured to store one or more computer instructions; and

the processor is coupled to the memory and the communication component, and is configured to execute the one or more computer instructions to perform the transaction processing method according to claim 13 .

19 . A non-transitory computer-readable storage medium storing computer instructions, wherein when the computer instructions are executed by one or more processors, the one or more processors are caused to perform the transaction processing method according to claim 1 .

20 . A non-transitory computer-readable storage medium storing computer instructions, wherein when the computer instructions are executed by one or more processors, the one or more processors are caused to perform the transaction processing method according to claim 13 .