A data query method and device, electronic equipment and storage medium
By releasing the global block of data pages in a shared storage database cluster and generating mirror data pages for querying, the high cost problem caused by the global block is solved and the concurrency efficiency and consistency of data query are improved.
Patent Information
- Application Number
- CN202410905038.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-07-08
AI Technical Summary
In a shared storage database cluster, the global blocking operation of data pages is costly, causing query operations to block data pages or roll back pages for a long time, affecting the efficiency of concurrent data processing in the cluster.
Before the query operation, the global lock of the data page to be queried is released, a mirror data page is generated, and data query is performed based on the mirror data page. The mirror data page and concurrent lock control ensure data consistency and reduce lock conflicts.
It improves the efficiency of cluster concurrent data processing, avoids the impact of global blocking on data query, and ensures data consistency.
Smart Images

Figure CN118885508B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of database technology, and in particular to a data query method, device, electronic device, and storage medium. Background Art
[0002] In a shared storage database cluster (DSC), multi-version transaction concurrency control is supported. Each time data in a table is updated, the latest data can be saved through physical records, and historical version data at the row level can be maintained through rollback records.
[0003] When executing a query on a data page, the page must be globally blocked and all visible physical records on the page must be batch-scanned and output. If no physical records are visible, the page remains blocked, and historical version data is retrieved from the rollback records on the rollback page. The global block on the page is released after the query is complete. However, in a DSC environment, globally blocking data pages is expensive. Query operations may block data pages or rollback pages for extended periods, impacting the efficiency of concurrent data processing in the cluster. Summary of the Invention
[0004] The present invention provides a data query method, device, electronic device and storage medium, which can improve the efficiency of cluster concurrent data processing.
[0005] In a first aspect, an embodiment of the present invention provides a data query method, which is applied to any node in a database cluster, and the method includes:
[0006] Perform a global lock and a local read-write lock on the data page to be queried, and obtain all physical records in the data page to be queried;
[0007] Release the global lock of the data page to be queried, and keep the local read-write lock of the data page to be queried;
[0008] The obtained physical records are traversed, and if it is determined during the traversal process that a concurrent blocking request exists for the data page to be queried, a mirror data page corresponding to the data page to be queried is generated, and data query is performed based on the mirror data page.
[0009] In a second aspect, an embodiment of the present invention provides a data query device, which is configured at any node in a database cluster, and includes:
[0010] A blocking module is used to perform global blocking and local read-write locks on the data page to be queried, and obtain all physical records in the data page to be queried;
[0011] A release module is used to release the global lock of the data page to be queried and maintain the local read-write lock of the data page to be queried;
[0012] The query module is used to traverse the obtained physical records, and if it is determined during the traversal process that there is a concurrent blocking request for the data page to be queried, generate a mirror data page corresponding to the data page to be queried, and perform data query based on the mirror data page.
[0013] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the method according to the first aspect.
[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0018] According to the technical solution of an embodiment of the present invention, when any node in a database cluster is querying a data page to be queried, it releases the global lock on the data page to be queried before the query is completed. If there is a concurrent lock request for the data page to be queried, the data query is performed based on the mirror data page corresponding to the data page to be queried. By releasing the global lock on the data page to be queried in advance during the data query process, data consistency is ensured through the mirror data page and concurrent lock control. This does not affect the data query, reduces lock conflicts in concurrent data processing of the data page to be queried, and improves the efficiency of concurrent data processing in the cluster.
[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1This is a flow chart of a data query method provided according to the first embodiment of the present invention;
[0022] Figure 2 This is a structural diagram of a data query device provided according to the second embodiment of the present invention;
[0023] Figure 3 It is a schematic structural diagram of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0025] It should be noted that the terms "first," "second," and the like in the present invention are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or apparatuses.
[0026] Before describing a data query method provided by an embodiment of the present invention, the application background of the embodiment of the present invention is introduced as follows:
[0027] In a shared storage database cluster (DSC), multi-version transaction concurrency control is supported. Each time data in a table is updated, the latest data is saved using physical records, while historical row-level version data is maintained using rollback records. A physical record indicates the latest version of the data in the table, while a rollback record indicates the historical version of the data corresponding to the physical record.
[0028] In DSC, a physical record can include four fields: the latest data field, which is used to store the latest version of data; the row number identifier field (also known as ROWID), which indicates the row number automatically generated when data is inserted; the transaction identifier field (also known as TID), which indicates the identifier of the transaction that updates the data; the rollback record address field (also known as RPTR), which indicates the physical address of the latest rollback record corresponding to the physical record, and points to the latest rollback record corresponding to the physical record through RPTR.
[0029] In a DSC, a rollback record can include four fields: a historical version data field, which stores the data of the historical version corresponding to the rollback record; a ROWID field, which indicates the row number corresponding to the rollback record; a TID field, which identifies the transaction corresponding to the rollback record; and an RPTR field, which indicates the physical address of the previous rollback record corresponding to the rollback record, used to point to the previous rollback record of the previous version. A single-linked list is formed by the physical record and one or more corresponding rollback records. A single-linked list records the changes to a row of data.
[0030] DSC can process user requests concurrently. Concurrent operations may read or modify the same data page simultaneously. DSC uses "concurrency blocking control" to protect data page consistency. Concurrent operations include, but are not limited to, those generated using Data Definition Language (DDL), Data Manipulation Language (DML), or Data Query Language (DQL).
[0031] In a standalone environment, concurrent access requests to data pages are controlled using read-write locks. Before reading a data page, an S lock (also known as a shared lock) is obtained; before modifying a data page, an X lock (also known as an exclusive lock) is obtained. Data page read operations are executed concurrently, while data page write operations are executed mutually exclusive. The read-write lock is released after the operation is completed.
[0032] In a DSC environment, multiple database instances may access the same data page concurrently, and concurrent access requests to the data page are controlled through global locking and local read-write locks. Global locking can be understood as global concurrent locking control performed by the Global Buffer System (GBS) and the Local Buffer System (LBS). All database instances in DSC support GBS / LBS services. The GBS coordinates locking requests between nodes and is responsible for the authorization and revocation of global data page locks. The LBS agent initiates locking requests to the GBS or reclaims local locking authorizations based on GBS commands. Local read-write locks can be understood as concurrent locking control for local instances performed through shared locks and exclusive locks.
[0033] In a DSC environment, when locking a data page, you must first apply for global GBS / LBS authorization, then apply for a local read / write lock to ensure data page consistency across instances. Data page read operations can be performed concurrently by multiple instances, while data page write operations are performed exclusively by a single instance. After the operation is completed, the global GBS / LBS authorization is released first, followed by the local read / write lock.
[0034] Currently, when performing a query on a data page in a DSC environment, the page must be globally blocked and all physical records on that page must be retrieved. Visible physical records are then traversed and their visibility determined. For invisible physical records, historical version data is retrieved from the rollback records on the rollback page, and visible records are further searched within this historical version data. After the query is complete, the global block on the data page is released. However, performing a global block on a data page in a DSC environment is costly, and queries may block the data page or rollback page for extended periods, impacting the efficiency of concurrent data processing in the cluster.
[0035] By providing a data query method according to an embodiment of the present invention, the above-mentioned query operation process and concurrent blocking control are optimized, thereby solving the above-mentioned problem.
[0036] Example 1
[0037] Figure 1 This is a flow chart of a data query method according to Embodiment 1 of the present invention. This embodiment is applicable to querying data within a page of data to be queried. The method can be performed by a data query device, which can be implemented in software and / or hardware and integrated into an electronic device serving as any node in a database cluster. Furthermore, the electronic device includes, but is not limited to, computers and laptops.
[0038] like Figure 1As shown, the method includes S110-S130, where S110-S130 can be understood as steps in which any node in the database cluster performs a query operation on the data page to be queried. Optionally, the database cluster can be a DSC. The query operation can be an operation of querying data, specifically an operation of querying the visible version of data in the data page to be queried.
[0039] S110 , executing a global lock and a local read-write lock on the data page to be queried, and obtaining all physical records in the data page to be queried.
[0040] The data page to be queried may be a data page to be queried, that is, a data page whose visible version of data is to be queried through a query operation. Optionally, the data page to be queried may be any data page stored in the DSC.
[0041] In this step, first, a global block is performed on the data page to be queried, that is, a global GBS / LBS authorization is performed; then a local read-write lock is performed on the data page to be queried, that is, a shared lock and an exclusive lock are performed on the data page to be queried; finally, all physical records in the data page to be queried are obtained, and the number of physical records is not limited.
[0042] S120: Release the global lock of the data page to be queried, and maintain the local read-write lock of the data page to be queried.
[0043] In this step, releasing the global block on the data page being queried can be understood as the query operation releasing the LBS authorization for the data page being queried. Compared to releasing the LBS authorization for the data page being queried after the query operation completes, releasing the LBS authorization in advance has the advantage that after the query operation releases the global block on the data page being queried, operations in the cluster concurrent with the query operation that target the data page being queried can execute the global block on the data page being queried.
[0044] In one embodiment, an operation on the data page to be queried that is concurrent with a query operation in a cluster may be a data modification operation on the data page to be queried that is initiated by a node in the cluster that is different from any of the above-mentioned nodes. Among them, any of the above-mentioned nodes may serve as a local node, and a node that is different from any of the above-mentioned nodes may be a remote node. The data modification operation may be an operation that modifies the data on the data page to be queried. For a remote node, after the query operation of the local node releases the global blockade of the data page to be queried, the data modification operation may request authorization for the global blockade of the data page to be queried, and then modify the data on the data page to be queried. That is, while the local node is performing a query operation on the data page to be queried, the remote node may concurrently perform a data modification operation on the data page to be queried.
[0045] In one embodiment, an operation on the data page to be queried concurrently with a query operation in the cluster may be a data synchronization operation initiated by any of the aforementioned nodes. The data synchronization operation may synchronize data on the data page to be queried, such as synchronizing the data on the data page to be queried, after the remote node has modified the data page based on a data modification operation, to any of the aforementioned nodes. For any of the aforementioned nodes, after the query operation releases the global block on the data page to be queried, the data synchronization operation may request authorization for the global block on the data page to achieve data synchronization.
[0046] In this step, maintaining the local read-write lock of the data page to be queried can be understood as the query operation not releasing the authorization of the local read-write lock of the data page to be queried, so that any of the above nodes can still perform the query operation on the data page to be queried.
[0047] In one embodiment, the method further comprises:
[0048] A query mark is set in the data page to be queried, and the query mark indicates that a data query is being performed in the data page to be queried.
[0049] The query mark can be a mark indicating that a data query is being performed on the data page to be queried, that is, indicating that the data page to be queried is being accessed by a query operation. The query mark is not limited, and can be a mark R, for example.
[0050] In an embodiment of the present invention, while releasing the global block of the data page to be queried and maintaining the local read-write lock of the data page to be queried, a query mark can be set in the data page to be queried, so that operations concurrent with the query operation in any of the above nodes, such as data synchronization operations, can determine that there are concurrent query operations and data synchronization operations in the data page to be queried.
[0051] S130 , traversing the obtained physical records, and if it is determined during the traversal process that there is a concurrent blocking request for the data page to be queried, generating a mirror data page corresponding to the data page to be queried, and performing data query based on the mirror data page.
[0052] The mirror data page corresponding to the data page being queried may be a copy of the data page being queried, generated by duplicating the data page being queried. The physical records in the mirror data page may be considered consistent with the physical records in the data page being queried. The rollback record corresponding to a physical record in the mirror data page may be considered consistent with the rollback record corresponding to a physical record in the data page being queried that is consistent with the aforementioned physical record.
[0053] In this step, the acquired physical records are traversed, and for each acquired physical record, a determination is made as to whether a mirror data page corresponding to the data page being queried has been generated. If a concurrent blocking request for the data page being queried is determined, i.e., if an operation concurrent with the query operation, such as a data synchronization operation, is detected in any of the aforementioned nodes, requesting authorization for a global blocking of the data page being queried, a mirror data page corresponding to the data page being queried is generated, and data queries are subsequently performed in the mirror data page.
[0054] In one embodiment, when a concurrent blocking request mark exists in the data page to be queried, it is determined that a concurrent blocking request exists for the data page to be queried.
[0055] The concurrent blocking request mark may be a mark indicating that an operation concurrent with the query operation exists in any of the above nodes, and requesting global blocking authorization for the data page to be queried.
[0056] The concurrent blocking request flag can be an operation concurrent with the query operation in any of the aforementioned nodes. When applying for global blocking authorization for a data page to be queried, the flag set on the data page to be queried is not limited to the concurrent blocking request flag, and can be, for example, flag W. If the concurrent blocking request flag is set for an operation concurrent with the query operation, the query operation can determine, based on the concurrent blocking request flag, whether a concurrent blocking request exists for the data page to be queried.
[0057] In one embodiment, performing a data query based on the mirrored data page includes:
[0058] Obtain all physical records in the mirror data page;
[0059] If the physical record obtained from the mirror data page is visible, it is output; otherwise, a visible record is obtained from the rollback record corresponding to the invisible physical record.
[0060] If the physical record obtained from the mirror data page is visible, it is output; if it is not visible, the physical address of the latest rollback record indicated by the invisible physical record is read to further find out whether there is a visible version of the record.
[0061] The rollback record is loaded based on the physical address of the most recent rollback record. If the record is visible, it is output; if not, the next rollback record is retrieved to further determine visibility. If no visible record exists in the one-way linked list of rollback records, the record is considered invisible to the user. After the rollback record is read, the mirror data page is cleaned up.
[0062] It should be noted that the embodiment of the present invention does not limit the method for determining whether a record is visible or invisible, and it can be implemented by using existing methods for determining whether a record is visible or invisible.
[0063] According to the technical solution of an embodiment of the present invention, when any node in a database cluster is querying a data page to be queried, it releases the global lock on the data page to be queried before the query is completed. If there is a concurrent lock request for the data page to be queried, the data query is performed based on the mirror data page corresponding to the data page to be queried. By releasing the global lock on the data page to be queried in advance during the data query process, data consistency is ensured through the mirror data page and concurrent lock control. This does not affect the data query, reduces lock conflicts in concurrent data processing of the data page to be queried, and improves the efficiency of concurrent data processing in the cluster.
[0064] In one embodiment, the method further comprises:
[0065] When a mirror data page corresponding to the data page to be queried is generated, releasing the local read-write lock of the data page to be queried;
[0066] A blocking request for the data page to be queried is awakened.
[0067] When a mirror data page corresponding to the data page to be queried is generated, the query operation can be performed in the mirror data page, so the query mark R in the data page to be queried can be cleared and the local read-write lock of the data page to be queried can be released.
[0068] On any of the above nodes, before a query operation releases the local read-write lock on the data page being queried, concurrent operations such as data synchronization operations, which require a local read-write lock on the data page being queried, will be blocked and waiting. After the query operation releases the local read-write lock on the data page being queried, any node can wake up the blocked lock request for the data page being queried and clear the lock request flag W on the data page being queried, allowing concurrent operations such as data synchronization operations to apply for the local read-write lock on the data page being queried.
[0069] The following is the data synchronization process for operations concurrent with query operations, such as data synchronization operations, in any of the above nodes:
[0070] In one embodiment, the method further comprises:
[0071] In the case of applying for a global blockade for the data page to be queried, if the data page to be queried is updated and a query mark exists in the data page to be queried, setting a concurrent block request mark in the data page to be queried;
[0072] A global block is performed on the data page to be queried.
[0073] When a data synchronization operation requests global block authorization (GBS / LBS), the LBS authorization checks the data page to be queried. If the data page to be queried has been modified by a remote node, a data synchronization operation is required to synchronize the updated data page to any of the aforementioned nodes. Furthermore, if a query flag R is present on the data page to be queried, this indicates that concurrent block requests for both the query operation and the data synchronization operation exist on the data page to be queried. Therefore, a concurrent block request flag W can be set on the data page to allow the query operation to determine, based on flag W, whether a concurrent block request exists.
[0074] After setting the concurrent blocking request flag in the data page to be queried, the data synchronization operation can perform GBS / LBS authorization normally.
[0075] In one embodiment, after performing a global blockade on the data page to be queried, the method further includes:
[0076] In the case of applying for a local read-write lock for the data page to be queried, if there is a query mark in the data page to be queried, blocking and waiting until the data query operation corresponding to the query mark releases the local read-write lock;
[0077] Execute a local read-write lock on the data page to be queried;
[0078] The data page to be queried after synchronization update.
[0079] When a local read-write lock is applied for a data synchronization operation, the mark in the data page to be queried is checked. If the query mark R exists in the data page to be queried, it indicates that the data page to be queried is being accessed by a query operation, so blocking and waiting are performed.
[0080] When the data query operation corresponding to the query tag, that is, the query operation, releases the local read-write lock, the blocking waiting lock request of the data synchronization operation will be awakened. The data synchronization operation can execute the local read-write lock on the data page to be queried and synchronize the updated data page to be queried to any of the above nodes.
[0081] In the above technical solution, when any node is executing a query operation, the remote node concurrently updates the data page to be queried; when a data synchronization operation concurrent with the query operation in any node initiates a blocking request, the updated data page to be queried will be synchronized to the local. At this time, the query operation can generate a mirror data page, avoiding invalid data page duplication.
[0082] Example 2
[0083] Figure 2is a structural schematic diagram of a data query device according to Embodiment Two of the present application. The embodiment can be applied to the case of data query in a data page to be queried. The device can be configured in an electronic device as any node in a database cluster. As shown in the figure, the specific structure of the device comprises: Figure 2
[0084] a blocking module 21, configured to perform global blocking and local read-write locking on a data page to be queried, and acquire all physical records in the data page to be queried;
[0085] a releasing module 22, configured to release the global blocking of the data page to be queried, and maintain the local read-write locking of the data page to be queried;
[0086] a query module 23, configured to traverse the acquired physical records, and in the process of traversal, if it is determined that there is a concurrent blocking request for the data page to be queried, generate a mirror data page corresponding to the data page to be queried, and perform data query based on the mirror data page.
[0087] The technical solution provided in the embodiment performs global blocking and local read-write locking on a data page to be queried by the blocking module, and acquires all physical records in the data page to be queried. The releasing module releases the global blocking of the data page to be queried, and maintains the local read-write locking of the data page to be queried. The query module traverses the acquired physical records, and in the process of traversal, if it is determined that there is a concurrent blocking request for the data page to be queried, generates a mirror data page corresponding to the data page to be queried, and performs data query based on the mirror data page. In the process of data query, the global blocking of the data page to be queried is released in advance, the consistency of data is ensured through the mirror data page and concurrent blocking control, the lock conflict of concurrent data processing for the data page to be queried is reduced, and the efficiency of concurrent data processing of the cluster is improved.
[0088] Further, if there is a concurrent blocking request mark in the data page to be queried, it is determined that there is a concurrent blocking request for the data page to be queried.
[0089] Further, the query module 23 is specifically configured to:
[0090] acquire all physical records in the mirror data page;
[0091] if the physical records acquired from the mirror data page are visible, output, otherwise, acquire visible records from rollback records corresponding to the invisible physical records.
[0092] Further, the device further comprises a query mark setting module, configured to:
[0093] A query mark is set in the data page to be queried, and the query mark indicates that a data query is being performed in the data page to be queried.
[0094] Furthermore, the device also includes a wake-up module, which is used to:
[0095] When a mirror data page corresponding to the data page to be queried is generated, releasing the local read-write lock of the data page to be queried;
[0096] A blocking request for the data page to be queried is awakened.
[0097] Furthermore, the device also includes a concurrent global blocking module for:
[0098] In the case of applying for a global blockade for the data page to be queried, if the data page to be queried is updated and a query mark exists in the data page to be queried, setting a concurrent block request mark in the data page to be queried;
[0099] A global block is performed on the data page to be queried.
[0100] Furthermore, the device also includes a concurrent local blocking module, which is used to:
[0101] After executing a global block on the data page to be queried, in the case of applying for a local read-write lock for the data page to be queried, if there is a query mark in the data page to be queried, blocking and waiting until the data query operation corresponding to the query mark releases the local read-write lock;
[0102] Execute a local read-write lock on the data page to be queried;
[0103] The data page to be queried after synchronization update.
[0104] The data query device provided by the embodiment of the present invention can execute the data query method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0105] Example 3
[0106] Figure 3is a structural schematic diagram of an electronic device that implements embodiments of the present application. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices such as personal digital assistants, cellular telephones, smartphones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.
[0107] As shown in Figure 3 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected in communication with the at least one processor 11, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0108] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0109] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the data query method.
[0110] In some embodiments, the data query method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the data query method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the data query method in any other appropriate manner (e.g., by means of firmware).
[0111] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0112] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0113] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0114] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0115] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0116] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0117] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0118] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A data query method, characterized in that: Applied to any node in a database cluster, the method includes: Perform a global lock and a local read-write lock on the data page to be queried, and obtain all physical records in the data page to be queried; Release the global lock of the data page to be queried, and keep the local read-write lock of the data page to be queried; Traversing the obtained physical records, if it is determined during the traversal process that there is a concurrent blocking request for the data page to be queried, generating a mirror data page corresponding to the data page to be queried, and performing data query based on the mirror data page; The method further comprises: Setting a query mark in the data page to be queried, wherein the query mark indicates that a data query is being performed in the data page to be queried; The method further comprises: When a mirror data page corresponding to the data page to be queried is generated, releasing the local read-write lock of the data page to be queried; Waking up a blocking request for the data page to be queried; The method further comprises: In the case of applying for a global blockade for the data page to be queried, if the data page to be queried is updated and a query mark exists in the data page to be queried, setting a concurrent block request mark in the data page to be queried; Performing a global blockade on the data page to be queried; After performing a global blockade on the data page to be queried, the method further includes: In the case of applying for a local read-write lock for the data page to be queried, if there is a query mark in the data page to be queried, blocking and waiting until the data query operation corresponding to the query mark releases the local read-write lock; Execute a local read-write lock on the data page to be queried; The data page to be queried after synchronization update.
2. The method according to claim 1, characterized in that In a case where a concurrent blocking request mark exists in the data page to be queried, it is determined that a concurrent blocking request exists for the data page to be queried.
3. The method according to claim 1, characterized in that Performing data query based on the mirrored data page includes: Obtain all physical records in the mirror data page; If the physical record obtained from the mirror data page is visible, it is output; otherwise, a visible record is obtained from the rollback record corresponding to the invisible physical record.
4. A data query device, characterized in that: The device is configured on any node in the database cluster and includes: A blocking module is used to perform global blocking and local read-write locks on the data page to be queried, and obtain all physical records in the data page to be queried; A release module is used to release the global lock of the data page to be queried and maintain the local read-write lock of the data page to be queried; a query module configured to traverse the acquired physical records, and if it is determined during the traversal process that a concurrent blocking request exists for the data page to be queried, generate a mirror data page corresponding to the data page to be queried, and perform a data query based on the mirror data page; The device further includes a query flag setting module, configured to: Setting a query mark in the data page to be queried, wherein the query mark indicates that a data query is being performed in the data page to be queried; The device further includes a wake-up module, configured to: When a mirror data page corresponding to the data page to be queried is generated, releasing the local read-write lock of the data page to be queried; Waking up a blocking request for the data page to be queried; The device also includes a concurrent global blocking module, which is used to: In the case of applying for a global blockade for the data page to be queried, if the data page to be queried is updated and a query mark exists in the data page to be queried, setting a concurrent block request mark in the data page to be queried; Performing a global blockade on the data page to be queried; The apparatus further comprises a concurrent local blocking module, configured to: After executing a global block on the data page to be queried, in the case of applying for a local read-write lock for the data page to be queried, if there is a query mark in the data page to be queried, blocking and waiting until the data query operation corresponding to the query mark releases the local read-write lock; Execute a local read-write lock on the data page to be queried; The data page to be queried after synchronization update.
5. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Virtual machine startup acceleration method and apparatus
CN108255577A
Method of controlling computer resource
JP1993204872A