IP Library › Granted Patent US 12,346,303
Granted Patent B2
US 12,346,303 · App. 18/070,758 · Granted Jul 1, 2025

Transaction processing method and apparatus, computer device, and storage medium

Inventor: Haixiang Li (Shenzhen, CN)
Assignee: Tencent Technology (Shenzhen) Company Limited
G06F16/2322G06F16/2365
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 12,346,303
App. No.
18/070,758
Granted
Jul 1, 2025
Kind
B2
Abstract

This application discloses a transaction processing method and apparatus, a computer device, and a storage medium, and relates to the technical field of databases. The method includes: obtaining a read set and a write set of a target transaction in response to a read-write operation of the target transaction; determining a logical begin time and a logical end time of the target transaction in response to a validation instruction of the target transaction; updating the logical begin time based on the write set in response to the logical begin time and the logical end time conforming to a concurrent consistency level of the target transaction, to obtain an updated logical begin time; and committing the target transaction in response to the updated logical begin time being less than or equal to the logical end time.

Claims (81)

1. A method for transaction processing, performed by a computer device, the method comprising:

obtaining a read set and a write set of a target transaction in response to a read-write operation of the target transaction;

determining a logical begin time and a logical end time of the target transaction in response to a validation instruction of the target transaction;

in response to the logical begin time and the logical end time conforming to a concurrent consistency level of the target transaction, to obtain an updated logical begin time:

obtaining to-be-written transaction information of a data item in the write set, the to-be-written transaction information being used for identifying a transaction that is modifying the data item;

in response to each piece of the to-be-written transaction information being null:

using the to-be-written transaction information as a transaction identifier of the target transaction;

updating the logical begin time to make the updated logical begin time greater than a maximum read transaction time stamp of the data item, the maximum read transaction time stamp representing a maximum value in logical end times of transactions that have read the data item;

adjusting the logical begin time based on an active transaction set in response to the updated logical begin time and the logical end time conforming to the concurrent consistency level of the target transaction, the active transaction set identifying transactions that have started but have not been committed; and

rolling back the target transaction in response to the updated logical begin time and the logical end time not conforming to the concurrent consistency level of the target transaction; and

rolling back the target transaction in response to any piece of the to-be-written transaction information being not null; and

committing the target transaction in response to the updated logical begin time being less than or equal to the logical end time.

2. The method according to claim 1 , wherein:

the active transaction set comprises a first transaction set and a second transaction set, the first transaction set identifying transactions in a committing status or in a passing-validation status, and the second transaction set identifying transactions in a running status; and

adjusting the logical begin time comprises:

updating the logical begin time to make the updated logical begin time greater than a maximum logical end time among logical end times of all transactions in the first transaction set;

updating logical end time of each transaction identified by the second transaction set in response to the updated logical begin time being less than or equal to the logical end time, to make the logical end time of the each transaction being less than the updated logical begin time; and

rolling back the target transaction in response to the updated logical begin time being greater than the logical end time.

3. The method according to claim 2 , further comprising:

rolling back a transaction in the second transaction set in response to a logical begin time of the transaction being greater than the updated logical end time.

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

obtaining a concurrent transaction of the target transaction in response to the concurrent consistency level being serialization consistency;

obtaining a latest completed transaction time stamp of a session to which the target transaction belongs in response to the logical end time of the target transaction being less than a logical begin time of the concurrent transaction or the logical begin time of the target transaction being greater than a logical end time of the concurrent transaction; and

determining that the target transaction conforms to the concurrent consistency level in response to the logical end time of the target transaction being greater than or equal to the latest completed transaction time stamp.

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

obtaining a concurrent write transaction of the target transaction in response to the concurrent consistency level is strict serializability consistency and the target transaction is a write transaction;

obtaining a concurrent read-only transaction of the concurrent write transaction in response to the logical end time of the target transaction being less than a logical begin time of the concurrent write transaction or the logical begin time of the target transaction being greater than a logical end time of the concurrent write transaction;

obtaining a latest completed transaction time stamp of a session to which the target transaction belongs in response to a logical begin time of the concurrent read-only transaction being greater than the logical begin time of the concurrent write transaction; and

determining that the target transaction conforms to the concurrent consistency level in a case that the logical end time of the target transaction is greater than or equal to the latest completed transaction time stamp.

6. The method according to claim 1 , wherein the method further comprises:

obtaining a concurrent write transaction of the target transaction in response to the concurrent consistency level being linearizability serializability consistency and the target transaction being a write transaction;

obtaining a concurrent read-only transaction of the concurrent write transaction in response to the target transaction and the concurrent write transaction passing serializability validation;

obtaining a latest completed transaction time stamp of a session to which the target transaction belongs in response to a logical begin time of the concurrent read-only transaction being greater than the logical begin time of the concurrent write transaction; and

determining that the target transaction conforms to the concurrent consistency level in response to the logical end time of the target transaction being greater than or equal to the latest completed transaction time stamp.

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

obtaining a concurrent transaction of the target transaction in response to the concurrent consistency level being sequential serializability consistency;

determining a first transaction belonging to a same session with the target transaction in response to the target transaction and the concurrent transaction passing serializability validation;

obtaining a latest completed transaction time stamp of the session in response to the logical end time of the target transaction being less than a logical begin time of the first transaction;

determining that the target transaction conforms to the concurrent consistency level in response to the logical end time of the target transaction being greater than or equal to the newest completed transaction time stamp; and

in response to the target transaction and the first transaction having a causal relationship, updating a logical begin time of a result transaction in the causal relationship, such that an updated logical begin time of the result transaction is greater than a logical end time of a reason transaction in the causal relationship.

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

obtaining a concurrent transaction of the target transaction in response to the concurrent consistency level is serializability consistency;

determining a first transaction belonging to a same session with the target transaction in response to the target transaction and the concurrent transaction pass serializability validation; and

determining that it conforms to the concurrent consistency level in response to the logical end time of the target transaction is less than a logical begin time of the first transaction and the logical begin time is less than or equal to the logical end time.

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

obtaining a result transaction having a causal relationship with the target transaction and caused by the target transaction in response to the concurrent consistency level is causal repeatable read consistency; and

updating a logical begin time of the result transaction to make an updated logical begin time of the result transaction greater than the logical end time of the target transaction, to make the target transaction conform to the concurrent consistency level.

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

determining that the target transaction conforms to the concurrent consistency level in response to the concurrent consistency level being one of repeatable read consistency, read committed consistency, or read uncommitted consistency.

11. A device for transaction processing, the device comprising a memory for storing computer instructions and a processor in communication with the memory, wherein, when the processor executes the computer instructions, the processor is configured to cause the device to:

obtain a read set and a write set of a target transaction in response to a read-write operation of the target transaction;

determine a logical begin time and a logical end time of the target transaction in response to a validation instruction of the target transaction;

in response to the logical begin time and the logical end time conforming to a concurrent consistency level of the target transaction, to obtain an updated logical begin time:

obtain to-be-written transaction information of a data item in the write set, the to-be-written transaction information being used for identifying a transaction that is modifying the data item;

in response to each piece of the to-be-written transaction information being null:

use the to-be-written transaction information as a transaction identifier of the target transaction;

update the logical begin time to make the updated logical begin time greater than a maximum read transaction time stamp of the data item, the maximum read transaction time stamp representing a maximum value in logical end times of transactions that have read the data item;

adjust the logical begin time based on an active transaction set in response to the updated logical begin time and the logical end time conforming to the concurrent consistency level of the target transaction, the active transaction set identifying transactions that have started but have not been committed; and

roll back the target transaction in response to the updated logical begin time and the logical end time not conforming to the concurrent consistency level of the target transaction; and

roll back the target transaction in response to any piece of the to-be-written transaction information being not null; and

commit the target transaction in response to the updated logical begin time being less than or equal to the logical end time.

12. The device according to claim 11 , wherein:

the active transaction set comprises a first transaction set and a second transaction set, the first transaction set identifying transactions in a committing status or in a passing-validation status, and the second transaction set identifying transactions in a running status; and

when the processor is configured to cause the device to adjust the logical begin time, the processor is configured to cause the device to:

update the logical begin time to make the updated logical begin time greater than a maximum logical end time among logical end times of all transactions in the first transaction set;

update logical end time of each transaction identified by the second transaction set in response to the updated logical begin time being less than or equal to the logical end time, to make the logical end time of the each transaction being less than the updated logical begin time; and

roll back the target transaction in response to the updated logical begin time being greater than the logical end time.

13. The device according to claim 12 , wherein, when the processor executes the computer instructions, the processor is configured to further cause the device to:

roll back a transaction in the second transaction set in response to a logical begin time of the transaction being greater than the updated logical end time.

14. A non-transitory storage medium for storing computer readable instructions, the computer readable instructions, when executed by a processor, causing the processor to:

obtain a read set and a write set of a target transaction in response to a read-write operation of the target transaction;

determine a logical begin time and a logical end time of the target transaction in response to a validation instruction of the target transaction;

in response to the logical begin time and the logical end time conforming to a concurrent consistency level of the target transaction, to obtain an updated logical begin time:

obtain to-be-written transaction information of a data item in the write set, the to-be-written transaction information being used for identifying a transaction that is modifying the data item;

in response to each piece of the to-be-written transaction information being null:

use the to-be-written transaction information as a transaction identifier of the target transaction;

update the logical begin time to make the updated logical begin time greater than a maximum read transaction time stamp of the data item, the maximum read transaction time stamp representing a maximum value in logical end times of transactions that have read the data item;

adjust the logical begin time based on an active transaction set in response to the updated logical begin time and the logical end time conforming to the concurrent consistency level of the target transaction, the active transaction set identifying transactions that have started but have not been committed; and

roll back the target transaction in response to the updated logical begin time and the logical end time not conforming to the concurrent consistency level of the target transaction; and

roll back the target transaction in response to any piece of the to-be-written transaction information being not null; and

commit the target transaction in response to the updated logical begin time being less than or equal to the logical end time.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 29, 2022
From: LI, HAIXIANG
To: TENCENT TECHNOLOGY (SHENZHEN) COMPANY LIMITED
Reel/Frame 061908/0029 →
Priority Claims (1)
CN 202110115847.4 · Jan 28, 2021 · national
Continuity (2)
Continuation PCTCN2022073455 · Jan 24, 2022
Related Publication 20230100223A1 · Mar 30, 2023
References Cited (23)
US 10983981B1 · Sharma · 2021 [cited by examiner]
US 20060149698A1 · Haselden · 2006 [cited by examiner]
US 20140310253A1 · Meng et al. · 2014 [cited by applicant]
US 20150143064A1 · Bhargava · 2015 [cited by examiner]
US 20160378819A1 · Bishop · 2016 [cited by examiner]
US 20190266176A1 · Hsieh et al. · 2019 [cited by applicant]
US 20200226011A1 · Ye · 2020 [cited by examiner]
US 20210081372A1 · Lee · 2021 [cited by examiner]
CN 109977171A · 2019 [cited by applicant]
CN 110196760A · 2019 [cited by applicant]
CN 111259071A · 2020 [cited by applicant]
CN 111338766A · 2020 [cited by applicant]
CN 111459920A · 2020 [cited by applicant]
CN 111597015A · 2020 [cited by applicant]
CN 111736964A · 2020 [cited by applicant]
CN 112463311A · 2021 [cited by applicant]
Ardekani, “Ensuring consistency in partially replicated data stores”, HAL open science, Nov. 24, 2014. [cited by examiner]
Extended European Search Report issued for EP 22745183.8 dated May 29, 2024 (6 pages). [cited by applicant]
Chaudhary et al. “Achieving starvation-freedom in multi-version transactional memory systems.” Networked Systems: 7th International Conference, NETYS May 2019 (53 pages). [cited by applicant]
Office Action issued in related Japanese Application No. 2023-524479 dated Mar. 15, 2024 with English Translation. 4 pages. [cited by applicant]
Office Action with English Translation of Concise Explanation of Relevance for Chinese Patent Application No. 202110115847.4 dated Mar. 18, 2021, 11 pages. [cited by applicant]
International Search Report and Written Opinion with English Translation for International Patent Application No. PCT/CN2022/073455 dated Apr. 11, 2022, 12 pages. [cited by applicant]
Li, Qingxia, “An Improved Concurrency Control Strategy of Distributed Transaction Based on Timestamp Ordering”, Journal of Dongguan University of Technology, vol. 20, No. 3, dated Jun. 30, 2013, Relevant pp. 58-63. [cited by applicant]