
SIGMOD-Companion ’25, June 22–27, 2025, Berlin, Germany Donghui Wang et al.
Most academic implementations of these novel protocols are
found in in-memory database prototypes (e.g., DBX1000 [
72
]), while
industry practitioners tend to be cautious about modifying concur-
rency control protocols. For example, systems like MySQL and SQL
Server rely on traditional 2PL and multi-version concurrency con-
trol (MVCC) [
7
], or a combination of both. Also, rather than altering
the transaction layer to mitigate hotspot workloads, they often fo-
cus on modifying the application layer. For instance, most of our
Tencent Cloud database instances implement request restrictions at
the application layer to prevent sudden spikes in hotspot requests
(for further details, see Section 4.6). Additionally, some databases
employ proactive hotspot identication and SQL rewriting [
29
] at
the application layer to address ad-hoc high-contented workloads
(e.g., [
50
]). However, these implementations may not necessarily
represent the most eective solutions for managing hotspot access
in commercial databases, and in certain dynamic scenarios, they
may not be applicable at all.
In certain high-contented workloads at Tencent, we have found
that request restrictions can eectively mitigate excessive lock
contention. However, this approach is less eective in dynamic
hotspot situations (see Section 2.3), where transactions concentrate
on updating one or a few data items. In these cases, executing trans-
actions serially may yield better performance by eliminating lock
contention and associated overhead. To oer a practical solution for
managing hotspots, this paper provides insights into lock optimiza-
tion within Tencent Database TXSQL [
14
]. First, we discuss our
motivations and the overarching lock optimization process, includ-
ing lightweight lock management, a lock-free active transaction
list, and a queue lock mechanism. These optimizations enhance
concurrency and improve performance in typical high-contention
scenarios. Secondly, we place particular emphasis on its optimiza-
tions for hotspot situations. Specically, TXSQL is designed to meet
the following two criteria for concurrency control when addressing
hotspots: (1) the protocol is workload-agnostic and does not inter-
fere with existing application logic; and (2) the protocol maintains
performance when concurrency increases.
Inspired by the benets of deterministic protocols in scheduling
high-conicted transactions, we propose a group locking mecha-
nism within the 2PL protocol framework for managing hotspots.
Unlike traditional 2PL, which treats all data uniformly, our ap-
proach distinguishes between hotspot and non-hotspot data. We
group transactions updating hotspot data, allowing them to proceed
without locking, as long as they adhere to a total order. When there
are no hotspot updates, TXSQL reverts to traditional 2PL, ensuring
minimal impact on overall throughput. Our main contributions are
as follows:
•
We provide motivation, optimizations, and insights in TXSQL
to address lock conict issues.
•
When involving hotspot data, we propose a group locking
mechanism that groups hotspot data accesses and executes
them serially without locking. Also, we describe its correct-
ness in terms of deadlock, rollback, and failure recovery.
•
Compared to state-of-the-art methods and systems, evalu-
ation shows that our approach achieves performance im-
provements of up to 6.5x and 22.3x, respectively.
Connection Pool
Parser Optimizer
Server Engine InnoDB-like Storage Engine
Trx Coordinate Log
Execution Engine
Trx Manager
Active trx list
trx_start
lock/unlock
trx_commit
trx_rollback
Lock Manager
Lock hash table
lock_rec_lock
unlock_rec_lock
Log BufferBuffer Pool
Binlog Cache
Redo Log FilesUndo TablespaceData TablespacesBinary Log Files
Disk Files & Logs
Figure 1: The core architecture of TXSQL.
2 Preliminary
This section introduces the basic 2PL design, as well as TXSQL’s
system architecture and its applications.
2.1 Two-Phase Locking (2PL)
The 2PL protocol, widely implemented in many database man-
agement systems, is designed to prevent data conicts between
concurrent transactions. Transaction execution is divided into two
distinct phases: the growing phase and the shrinking phase. In the
growing phase, a transaction can acquire locks and access data but
is prohibited from releasing any locks. In the shrinking phase, a
transaction may release locks but cannot acquire any new locks.
The 2PL ensures transactions do not conict with one another
during execution, thereby maintaining transaction isolation.
Mutual Exclusion (Mutex) is a synchronization mechanism used
in multithreaded programming, designed to prevent multiple threads
from simultaneously accessing shared resources, thereby avoiding
data races and inconsistencies. A mutex ensures that only one
thread can access a specic resource or code segment at any given
time. It is commonly utilized in 2PL lock management.
2.2 Transaction Execution Workow
TXSQL [
15
], an open-source MySQL branch maintained by Tencent
Cloud, is fully compatible with MySQL’s syntax and APIs. Figure 1
depicts the core system architecture of TXSQL. The primary opti-
mizations discussed in this paper focus on the transaction manager
and the lock manager at the Storage layer. The transaction man-
ager is responsible for the lifecycle of transactions, including their
initiation, execution, commit, and rollback. It ensures the atomicity
of transactions, meaning that they either complete successfully in
their entirety or do not execute at all. In contrast, the lock manager
implements a locking mechanism to regulate access to database
resources during transaction execution, such as rows and tables.
When a transaction initiates a row update in the transaction
manager, the specic row can be uniquely identied by locating the
record’s associated tablespace through the
𝑠𝑝𝑎𝑐𝑒_𝑖𝑑
, identifying the
page containing the record via the
𝑝𝑎𝑔𝑒_𝑛𝑜
, and pinpointing the
exact position of the record within a page using the
ℎ𝑒𝑎𝑝_𝑛𝑜
. There-
fore, the combination of <
𝑠𝑝𝑎𝑐𝑒_𝑖𝑑
,
𝑝𝑎𝑔𝑒_𝑛𝑜
,
ℎ𝑒𝑎𝑝_𝑛𝑜
> serves as a
unique identier for a row. Once the corresponding record is located,
文档被以下合辑收录
评论