CN111090663A - Transaction concurrency control method, device, terminal equipment and medium - Google Patents

Transaction concurrency control method, device, terminal equipment and medium Download PDF

Info

Publication number
CN111090663A
CN111090663A CN201911353223.5A CN201911353223A CN111090663A CN 111090663 A CN111090663 A CN 111090663A CN 201911353223 A CN201911353223 A CN 201911353223A CN 111090663 A CN111090663 A CN 111090663A
Authority
CN
China
Prior art keywords
target object
data
transaction
version
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911353223.5A
Other languages
Chinese (zh)
Other versions
CN111090663B (en
Inventor
王健星
朱鸿斌
夏之春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Kingstar Fintech Co Ltd
Original Assignee
Shanghai Kingstar Fintech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Kingstar Fintech Co Ltd filed Critical Shanghai Kingstar Fintech Co Ltd
Priority to CN201911353223.5A priority Critical patent/CN111090663B/en
Publication of CN111090663A publication Critical patent/CN111090663A/en
Application granted granted Critical
Publication of CN111090663B publication Critical patent/CN111090663B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application is applicable to the technical field of databases, and particularly relates to a transaction concurrency control method, a transaction concurrency control device, terminal equipment and a medium. The method comprises the steps of obtaining a write transaction aiming at a target object, and carrying out corresponding operation on a storage area corresponding to the target object in a recording area; and acquiring target version information of the read transaction aiming at the target object, and accordingly acquiring historical version data corresponding to the target version information from the log area, wherein the historical version data is historical data of different versions generated by the target object in the recording area. According to the method and the device, the writing transaction and the reading transaction aiming at the same target object are respectively carried out in the recording area and the log area, the writing transaction and the reading transaction can be carried out concurrently, the reading of the data of the log area by the reading transaction cannot be influenced when the writing transaction is carried out in the recording area, meanwhile, the log area stores the historical version data which are generated in the recording area, the reading of the data of the historical version by the reading transaction is not influenced, dirty reading and unreal reading are avoided, and repeated reading of the data can be achieved.

Description

Transaction concurrency control method, device, terminal equipment and medium
Technical Field
The application belongs to the technical field of databases, and particularly relates to a transaction concurrency control method, a transaction concurrency control device, terminal equipment and a medium.
Background
In the original memory database data access, a read-write lock mode is adopted, whether a write lock exists or not can be checked every time data is read, and if the write lock exists, the write end is waited; meanwhile, when the write process writes data, all the read processes are blocked, and the data is written preferentially, so that the read processes cannot provide service for a period of time. However, the current memory database already supports a multi-process concurrent write-once and read-many mode, i.e. one process performs read and write, and other processes only perform read, so that in the process of simultaneously performing read and write processes, the problem of dirty read can occur.
Disclosure of Invention
The embodiment of the application provides a transaction concurrent control method, a transaction concurrent control device, terminal equipment and a medium, and can solve the problem of unreal reading in concurrent reading and writing of an existing memory database.
In a first aspect, an embodiment of the present application provides a transaction concurrency control method, where the transaction concurrency control method includes:
acquiring a write transaction for a target object;
according to the write transaction, corresponding operation is carried out on a storage area corresponding to the target object in a recording area;
obtaining a read transaction for the target object;
acquiring target version information of the target object according to the reading transaction;
and acquiring historical version data corresponding to the target version information of the target object from a log area according to the target version information of the target object, wherein the historical version data is the historical data of different versions of the target object generated in the recording area.
In a second aspect, an embodiment of the present application provides a transaction concurrency control apparatus, including:
the write transaction acquisition module is used for acquiring a write transaction aiming at a target object;
the operation module is used for carrying out corresponding operation on the storage area corresponding to the target object in the recording area according to the write transaction;
a read transaction acquisition module, configured to acquire a read transaction for the target object;
the version information acquisition module is used for acquiring the target version information of the target object according to the reading transaction;
the version data acquisition module is used for acquiring historical version data corresponding to the target version information of the target object from a log area according to the target version information of the target object, wherein the historical version data is historical data of different versions generated by the target object in the recording area.
In a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the transaction concurrency control method according to the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, where a computer program is stored, and when executed by a processor, the computer program implements the transaction concurrency control method according to the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a terminal device, causes the terminal device to execute the transaction concurrency control method according to the first aspect.
Compared with the prior art, the embodiment of the application has the advantages that: according to the method, the writing transaction and the reading transaction aiming at the same target object are respectively carried out in the recording area and the log area, the writing transaction and the reading transaction can be carried out concurrently, the reading of the log area data by the reading transaction cannot be influenced when the writing transaction is carried out in the recording area, meanwhile, the log area stores the historical version data which appears in the recording area, the reading of the historical version data by the reading transaction cannot be influenced, dirty reading and unreal reading are avoided, and repeated reading of the data can be achieved, for example, the writing transaction updates 'a-3' in the recording area to 'a-4', the log area has the historical version data 'a-3' after the updating is completed, and the reading transaction can read 'a-3' in the log area according to the version of the 'a-3' and cannot read 'a-4'.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flowchart of a transaction concurrency control method according to an embodiment of the present application;
FIG. 2 is a diagram illustrating a change example of a logging area and a log area after an insert operation in a transaction concurrency control method according to a first embodiment of the present application;
FIG. 3 is a diagram illustrating a change example of a log area and a log area after an update operation in a transaction concurrency control method according to a first embodiment of the present application;
FIG. 4 is a diagram illustrating a change example of a log area and a record area after a delete operation in a transaction concurrency control method according to a first embodiment of the present application;
FIG. 5 is a diagram illustrating a principle example of a transaction concurrency control method according to an embodiment of the present application;
FIG. 6 is a diagram illustrating a log partition segment of a transaction concurrency control method according to a first embodiment of the present application;
fig. 7 is a schematic structural diagram of a transaction concurrency control device according to a second embodiment of the present application;
fig. 8 is a schematic structural diagram of a terminal device according to a third embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The method for controlling the concurrency of the affairs provided by the embodiment of the application can be applied to terminal equipment such as a palm computer, a desktop computer, a notebook computer, a super-mobile personal computer (UMPC), a netbook, a cloud server and a Personal Digital Assistant (PDA), wherein a database is arranged in the terminal equipment, and the database can be a memory database when the affairs access the database.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Referring to fig. 1, which is a schematic flow chart of a transaction concurrency control method provided in an embodiment of the present application, where the transaction concurrency control method may be used in a terminal device, as shown in the figure, the transaction concurrency control method may include the following steps:
step S101, a write transaction for a target object is acquired.
The write transaction may refer to a process of performing write operation on a database, a memory, a disk, and the like of the terminal device, where the write transaction may include operations such as insertion, modification, and deletion, and all write transactions have a data object targeted by the write transaction.
And step S102, according to the write transaction, carrying out corresponding operation on the storage area corresponding to the target object in the recording area.
According to the transaction concurrency control method, a storage space such as a database of the terminal equipment is divided into at least two parts, one part is defined as a recording area, the other part is defined as a log area, wherein corresponding operation can be performed on a write transaction in the recording area to modify the storage area corresponding to a target object, the target object in the recording area only corresponds to one storage area, all operations of the write transaction are performed in the storage area, for example, the operations of the write transaction include but are not limited to an insertion operation, an updating operation and a deleting operation, the insertion operation can be to insert data into the storage area, the updating operation can be to modify data in the storage area, and the deleting operation can be to delete data in the storage area; in addition, the first write transaction for the target object may be an insert operation, that is, before the insert operation is performed, the storage area corresponding to the target object is empty, and at this time, the data corresponding to the target object is null.
Optionally, performing corresponding operations on the storage area corresponding to the target object in the recording area according to the write transaction includes:
if the operation type of the write transaction is an insert operation, acquiring data to be inserted of the target object from the write transaction;
and storing the data to be inserted into a storage area corresponding to the target object in a recording area.
The write transaction may include an insert operation instruction and data to be inserted for the target object, where, for example, the data to be inserted is "a ═ 3", and "a ═ 3" is inserted into the storage area corresponding to the target object in the recording area, and when the write transaction is committed (i.e., the insert operation is completed), the currently stored data in the storage area corresponding to the target object in the recording area is "a ═ 3"; of course, the data to be inserted corresponds to version information, where the version information is information used to describe a version of the data to be inserted, and the version information may be information carried by the data to be inserted itself, or may be generated along with the operation of the write transaction, for example, for a target object, after the first write transaction operation, the version of the data for the target object in the recording area is 1.
Optionally, performing corresponding operations on the storage area corresponding to the target object in the recording area according to the write transaction includes:
if the operation type of the write transaction is an updating operation, acquiring target data of the target object from the write transaction;
and updating the data currently stored in the storage area corresponding to the target object in the recording area into the target data.
The write transaction may include an update operation instruction and target data for the target object, for example, the target data is "a ═ 4", the storage area corresponding to the target object in the recording area is updated to "a ═ 4", and when the write transaction is committed (i.e., the update operation is completed), the currently stored data in the storage area corresponding to the target object in the recording area is "a ═ 4"; of course, the target data corresponds to a version information, the version information is information for describing a version of the corresponding target data, and the version information may be information carried by the target data itself, or may be generated along with the operation of the write transaction, for example, for the target object, the first write transaction operation is an insert operation, the version of the data for the target object in the recording area is 1, the second write transaction operation is an update operation, and the version of the data for the target object is updated to 2.
Optionally, performing corresponding operations on the storage area corresponding to the target object in the recording area according to the write transaction includes:
and if the operation type of the write transaction is a deleting operation, deleting the data currently stored in the storage area corresponding to the target object in the recording area.
The write transaction may include a delete operation instruction for the target object, for example, delete "a ═ 4" in the storage area corresponding to the target object in the recording area after the update operation, and when the write transaction is committed (i.e., the delete operation is completed), the currently stored data in the storage area corresponding to the target object in the recording area is null; of course, even if the currently stored data in the storage area corresponding to the target object in the recording area is null, the data still corresponds to version information, the version information is information for describing the version corresponding to the data, the version information may be information carried in a write transaction (a write transaction of a delete operation), or may be generated along with an operation of the write transaction, for example, after a first write transaction insert operation, the version of the data corresponding to the target object in the recording area is 1, after a second write transaction update operation, the version of the data corresponding to the target object in the recording area is 2, and after a third write transaction delete operation, the version of the data corresponding to the target object in the recording area is 3.
Step S103, acquiring a read transaction aiming at the target object.
The transaction parallel control method mainly describes the transaction parallel control method around one data object, namely the data object is called a target object, and generally the transaction parallel control method refers to a write-once read-many mode, namely that one write transaction and a plurality of read transactions can exist simultaneously for the target object.
Because the areas of the target objects targeted by the read transaction and the write transaction are different, the sequence of the read transaction and the write transaction in this embodiment is not limited, and step S103, step 104, and step 105 may be executed during the execution of step S102, or step S101 and step S102 may be executed during the execution of step S105, in addition, step S101 and step S102 may be executed when no read transaction exists, and of course, step S103, step 104, and step 105 may also be executed when no write transaction exists.
And step S104, acquiring the target version information of the target object according to the reading transaction.
The read transaction includes, but is not limited to, information of a target object to be read and target version information of the target object, and data to be read can be determined according to the target object and the target version information, for example, a 2 nd version of the target object a is read.
Step S105, acquiring historical version data corresponding to the target version information of the target object from a log area according to the target version information of the target object.
Wherein the historical version data is different versions of historical data generated by the target object in the recording area.
Step S102 shows that the log area and the recording area are two areas in the database, the write transaction performs corresponding operation in the recording area, and the read transaction performs read operation in the log area; the log area is used for storing historical version data of a target object of a read transaction, the historical version data is historical data of different versions of the target object generated in the log area, and the historical data can be realized through a snapshot technology and the like.
Optionally, when the operation type of the write transaction is an update operation or a delete operation, before performing a corresponding operation on the storage area corresponding to the target object in the recording area, the method further includes:
acquiring currently stored data and version information of the data in a storage area corresponding to the target object in a recording area;
associating the currently stored data of the storage area corresponding to the target object with the version information of the data to obtain associated data;
correspondingly, after performing corresponding operations on the storage area corresponding to the target object in the recording area, the method further includes:
and storing the associated data to the log area.
In order to store the history data into the log area as history version data, before a write transaction performs a corresponding operation on a storage area corresponding to a target object in the record area, the data currently stored in the storage area corresponding to the target object in the record area and version information of the data are recorded in a correlated manner, after the write transaction is submitted (i.e. the corresponding operation is completed), the data currently stored in the storage area corresponding to the target object and the version information of the data become the history version data in the log area, for example, the write transaction is an update operation, the target data in the write transaction is "a" 4 ", the version number is 3, the data currently stored in the storage area corresponding to the target object is" a "3", the version number is 2, after the update operation is completed, the "a" 3 "and the corresponding version number 2 are stored into the log area, at this time, the data currently stored in the storage area corresponding to the target object in the record area is" a "4", the version number is 3, after the updating operation is completed, the read transaction can read the data with the version number of 2, and the read information cannot change along with time and dirty reading and unreal reading cannot occur because the target version information in the read transaction is determined.
As shown in fig. 2 to 4, a change example graph is stored after the related operation of the transaction concurrency control method according to the first embodiment of the present application, the storage areas in the record area and the log area for the target object include, but are not limited to, information such as record ID, delete flag, data version, rollback pointer, operation type and field (col1, col2 …), and referring to fig. 2, the change example graph of the record area and the log area after the insertion operation of the transaction concurrency control method according to the first embodiment of the present application, when the related operation of the write transaction is the insertion operation, the data version in the storage area of the target object in the record area is filled with 1, the operation type is filled with a, the rollback pointer is filled with NULL (no previous data version), the first roll address of the first storage area of the target object in the log area is stored in the rollback pointer (xxx) of the record area, data version rollback is convenient to realize; of course, in order to keep the log area and the log area version synchronized, since the data of the target object in the log area before the insert operation is null, the data version in the first storage area of the target object in the log area after the insert operation may be filled with 0.
Fig. 3 is a diagram illustrating a change example of a logging area and a log area after an update operation of a transaction concurrency control method according to a first embodiment of the present application; when the related operation of the write transaction is an updating operation, the data version in the storage area of the target object in the recording area is filled with 2 and the operation type is filled with U, the data version in the second storage area of the target object in the log area is filled with 2, the operation type is filled with U, a rollback pointer is filled with xxx1 (pointing to the first storage area of the target object in the log area), and the first address of the second storage area of the target object in the log area is stored in the rollback pointer (xxx2) of the recording area, so that the rollback of the data version is convenient to realize; of course, in order to keep the journal area and the record area version synchronized, the data version in the second storage area of the target object in the journal area after the update operation may be filled with 1, which means the history data with the data version of 1.
Fig. 4 is a diagram illustrating a change example of a log area and a record area after a delete operation in the transaction concurrency control method according to the first embodiment of the present application; when the related operation of the write transaction is a delete operation, the data version in the storage area of the target object in the recording area is filled with 3 and the operation type is filled with U, the data version in the third storage area of the target object in the log area is filled with 3, the operation type is filled with U, a rollback pointer is filled with xxx2 (pointing to the second storage area of the target object in the log area), and the first address of the third storage area of the target object in the log area is stored in the rollback pointer (xxx3) of the recording area, so that the rollback of the data version is facilitated; of course, in order to keep the log area and the record area version synchronized, the data version in the third storage area of the target object in the log area after the update operation may be filled with 2, which means the history data with the data version of 2.
Referring to fig. 5, which is a schematic diagram illustrating a principle of a transaction concurrency control method according to an embodiment of the present application, as shown in the figure, a target object includes a read-write process, a read-only process 1, and a read-only process 2, where the read-write process can perform a read transaction and a write transaction, and in the present application, the read-write process refers to performing a write transaction, and the read-only process can only perform a read transaction; the time sequence is T1, T2, T3, T4, T5 and T6, the read-only process 1 is started first, the T1 read transaction is started, and as the target object has no data inserted before T1, the data corresponding to the target version information of the T1 read transaction does not exist in the log area, and therefore the read data is none; starting a read-write process, starting a T2 write transaction in the read-write process, inserting data with the version number of 1 and the version number of 3, and submitting the data after a certain time (T2 submission, namely completing the insertion operation); starting a T3 write transaction again in the read-write process, wherein the updated data is 'a-4', the version number is 2, and after the T3 write transaction is submitted, the read-only process 1 starts a T4 read transaction, and if the target version information of the T4 read transaction is 1, the data read by the T4 read transaction of the read-only process 1 is 'a-3', and the dirty data 'a-4' cannot be read; the read-write process starts a T5 write transaction, deletes data "a", restarts the read-only process 2, starts a T6 read transaction, and if the target version information of the T6 read transaction is 2, the data read by the T6 read transaction is "a ═ 4", the data read by the following T6 read transaction is still "a ═ 4", and the data cannot be read, that is, the deletion of the read-write process does not affect the T6 read transaction.
Optionally, the log area includes at least one segment memory, and the storing the associated data in the log area includes:
acquiring a segment memory corresponding to the target object in the log area;
judging whether a segment memory corresponding to the target object has space for storing the associated data;
and if the segment memory corresponding to the target object has space for storing the associated data, storing the associated data to the segment memory corresponding to the target object.
The log area is managed by segmentation, wherein segment memories are applied for the target object in the log area as required, and the size of each segment memory is 128M; as shown in fig. 6, except for a first segment memory, each segment memory of the plurality of segment memories includes a segment description header and a content area, and the first segment memory has an extra full segment description information of all segments; for the segment memory of the target object, when the segment memory is insufficient and the previous segment memory is effective, a segment memory needs to be applied again.
Optionally, the version information is a version number, and after the target version information of the target object is obtained, the method further includes:
if the number of the read transactions is multiple, acquiring a minimum target version number from multiple target version numbers;
acquiring the maximum version number of all version numbers in the segment memory corresponding to the target object;
and if the maximum version number is smaller than the minimum target version number, emptying all data in the segment memory corresponding to the target object.
If the version information is a version number and the version number is larger and larger when a write transaction and a read transaction are performed, each segment memory of the target object has a maximum version number, the maximum version number of the target object in the segment memory is described, and if the maximum version number is smaller than the minimum target version number in the target version numbers of all the ongoing read transactions, it is better to indicate that the segment memory cannot be accessed by the read transaction, the segment memory can be reused to write in historical version data, useless historical version data is effectively removed, and the sustainable use of a storage space of a log area is ensured.
According to the method, the writing transaction and the reading transaction aiming at the same target object are respectively carried out in the recording area and the log area, the writing transaction and the reading transaction can be carried out concurrently, the reading of the log area data by the reading transaction cannot be influenced when the writing transaction is carried out in the recording area, meanwhile, the log area stores the historical version data which appears in the recording area, the reading of the historical version data by the reading transaction cannot be influenced, dirty reading and unreal reading are avoided, and repeated reading of the data can be achieved, for example, the writing transaction updates 'a-3' in the recording area to 'a-4', the log area has the historical version data 'a-3' after the updating is completed, and the reading transaction can read 'a-3' in the log area according to the version of the 'a-3' and cannot read 'a-4'.
Fig. 7 shows a block diagram of a transaction concurrency control device according to a second embodiment of the present application, and only shows portions related to the second embodiment of the present application for convenience of description.
Referring to fig. 7, the transaction concurrency control apparatus includes:
a write transaction acquisition module 71, configured to acquire a write transaction for a target object;
an operation module 72, configured to perform corresponding operation on a storage area corresponding to the target object in the recording area according to the write transaction;
a read transaction obtaining module 73, configured to obtain a read transaction for the target object;
a version information obtaining module 74, configured to obtain target version information of the target object according to the read transaction;
a version data obtaining module 75, configured to obtain, according to the target version information of the target object, historical version data corresponding to the target version information of the target object from a log area, where the historical version data is historical data of different versions of the target object generated in the recording area.
Optionally, the operation module 72 is specifically configured to:
if the operation type of the write transaction is an insert operation, acquiring data to be inserted of the target object from the write transaction;
and storing the data to be inserted into a storage area corresponding to the target object in a recording area.
Optionally, the operation module 72 is specifically configured to:
if the operation type of the write transaction is an updating operation, acquiring target data of the target object from the write transaction;
and updating the data currently stored in the storage area corresponding to the target object in the recording area into the target data.
Optionally, the operation module 72 is specifically configured to:
and if the operation type of the write transaction is a deleting operation, deleting the data currently stored in the storage area corresponding to the target object in the recording area.
Optionally, the transaction concurrency control device further includes:
a current data obtaining module, configured to, when the operation type of the write transaction is an update operation or a delete operation, obtain, before performing a corresponding operation on a storage area corresponding to the target object in a recording area, data currently stored in the storage area corresponding to the target object in the recording area and version information of the data;
the data association module is used for associating the currently stored data in the storage area corresponding to the target object with the version information of the data to obtain associated data;
and the data storage module is used for storing the associated data to the log area after corresponding operation is carried out on the storage area corresponding to the target object in the record area.
Optionally, the log area includes at least one segment memory, and the storage processing module includes:
a segment memory obtaining unit, configured to obtain a segment memory corresponding to the target object in the log area;
the space judgment unit is used for judging whether the segment memory corresponding to the target object has space for storing the associated data;
and the storage processing unit is used for storing the associated data to the segment memory corresponding to the target object if the segment memory corresponding to the target object has space for storing the associated data.
Optionally, the version information is a version number, and the transaction concurrence control device further includes:
a first obtaining module, configured to, after obtaining the target version information of the target object, if the number of the read transactions is multiple, obtain a minimum target version number from multiple target version numbers;
the second obtaining module is used for obtaining the maximum version number of all the version numbers in the section memory corresponding to the target object;
and the data emptying module is used for emptying all data in the segment memory corresponding to the target object if the maximum version number is smaller than the minimum target version number.
It should be noted that, because the contents of information interaction, execution process, and the like between the modules are based on the same concept as that of the embodiment of the method of the present application, specific functions and technical effects thereof may be specifically referred to a part of the embodiment of the method, and details are not described here.
Fig. 8 is a schematic structural diagram of a terminal device according to a third embodiment of the present application. As shown in fig. 8, the terminal device 8 of this embodiment includes: at least one processor 80 (only one shown in fig. 8), a memory 81, and a computer program 82 stored in the memory 81 and operable on the at least one processor 80, the steps of any of the various transactional concurrency control method embodiments described above being implemented by the processor 80 when executing the computer program 82.
The terminal device may include, but is not limited to, a processor 80, a memory 81. Those skilled in the art will appreciate that fig. 8 is only an example of the terminal device 8, and does not constitute a limitation to the terminal device 8, and may include more or less components than those shown, or combine some components, or different components, such as an input/output device, a network access device, and the like; and for another example, the parts are required to be arranged in terminal equipment entities such as an RGB camera, a mechanical arm and the like.
The Processor 80 may be a Central Processing Unit (CPU), and the Processor 80 may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 81 may in some embodiments be an internal storage unit of the terminal device 8, such as a hard disk or a memory of the terminal device 8. The memory 81 may also be an external storage device of the terminal device 8 in other embodiments, such as a plug-in hard disk provided on the terminal device 8, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 81 may also include both an internal storage unit of the terminal device 8 and an external storage device. The memory 81 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer program. The memory 81 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the above-mentioned apparatus may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying the computer program code, recording medium, computer Memory, Read-only Memory (ROM), Random-Access Memory (RAM), electrical carrier wave signals, telecommunications signals, and software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
When the computer program product runs on a terminal device, the terminal device implements the steps of the method embodiments when executing the computer program product.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A transaction concurrency control method, comprising:
acquiring a write transaction for a target object;
according to the write transaction, corresponding operation is carried out on a storage area corresponding to the target object in a recording area;
obtaining a read transaction for the target object;
acquiring target version information of the target object according to the reading transaction;
and acquiring historical version data corresponding to the target version information of the target object from a log area according to the target version information of the target object, wherein the historical version data is the historical data of different versions of the target object generated in the recording area.
2. The transaction concurrency control method according to claim 1, wherein performing the corresponding operation on the storage area corresponding to the target object in the recording area according to the write transaction includes:
if the operation type of the write transaction is an insert operation, acquiring data to be inserted of the target object from the write transaction;
and storing the data to be inserted into a storage area corresponding to the target object in a recording area.
3. The transaction concurrency control method according to claim 1, wherein performing the corresponding operation on the storage area corresponding to the target object in the recording area according to the write transaction includes:
if the operation type of the write transaction is an updating operation, acquiring target data of the target object from the write transaction;
and updating the data currently stored in the storage area corresponding to the target object in the recording area into the target data.
4. The transaction concurrency control method according to claim 1, wherein performing the corresponding operation on the storage area corresponding to the target object in the recording area according to the write transaction includes:
and if the operation type of the write transaction is a deleting operation, deleting the data currently stored in the storage area corresponding to the target object in the recording area.
5. The transaction concurrency control method according to claim 1, wherein when the operation type of the write transaction is an update operation or a delete operation, before performing a corresponding operation on the storage area corresponding to the target object in the recording area, the method further comprises:
acquiring currently stored data and version information of the data in a storage area corresponding to the target object in a recording area;
associating the currently stored data of the storage area corresponding to the target object with the version information of the data to obtain associated data;
correspondingly, after performing corresponding operations on the storage area corresponding to the target object in the recording area, the method further includes:
and storing the associated data to the log area.
6. The transaction concurrency control method of claim 5, wherein the log area includes at least one segment memory, the storing the association data to the log area comprising:
acquiring a segment memory corresponding to the target object in the log area;
judging whether a segment memory corresponding to the target object has space for storing the associated data;
and if the segment memory corresponding to the target object has space for storing the associated data, storing the associated data to the segment memory corresponding to the target object.
7. The transaction concurrency control method according to claim 6, wherein the version information is a version number, and after acquiring the target version information of the target object, the method further comprises:
if the number of the read transactions is multiple, acquiring a minimum target version number from multiple target version numbers;
acquiring the maximum version number of all version numbers in the segment memory corresponding to the target object;
and if the maximum version number is smaller than the minimum target version number, emptying all data in the segment memory corresponding to the target object.
8. A transaction concurrency control apparatus, characterized by comprising:
the write transaction acquisition module is used for acquiring a write transaction aiming at a target object;
the operation module is used for carrying out corresponding operation on the storage area corresponding to the target object in the recording area according to the write transaction;
a read transaction acquisition module, configured to acquire a read transaction for the target object;
the version information acquisition module is used for acquiring the target version information of the target object according to the reading transaction;
the version data acquisition module is used for acquiring historical version data corresponding to the target version information of the target object from a log area according to the target version information of the target object, wherein the historical version data is historical data of different versions generated by the target object in the recording area.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the transaction concurrency control method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the transaction concurrency control method according to any one of claims 1 to 7.
CN201911353223.5A 2019-12-25 2019-12-25 Transaction concurrency control method, device, terminal equipment and medium Active CN111090663B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911353223.5A CN111090663B (en) 2019-12-25 2019-12-25 Transaction concurrency control method, device, terminal equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911353223.5A CN111090663B (en) 2019-12-25 2019-12-25 Transaction concurrency control method, device, terminal equipment and medium

Publications (2)

Publication Number Publication Date
CN111090663A true CN111090663A (en) 2020-05-01
CN111090663B CN111090663B (en) 2023-07-07

Family

ID=70397098

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911353223.5A Active CN111090663B (en) 2019-12-25 2019-12-25 Transaction concurrency control method, device, terminal equipment and medium

Country Status (1)

Country Link
CN (1) CN111090663B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984379A (en) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 Read-write transaction control method, system, terminal device and storage medium
CN112231070A (en) * 2020-10-15 2021-01-15 北京金山云网络技术有限公司 Data writing and reading method and device and server
CN112380193A (en) * 2020-12-09 2021-02-19 北京海量数据技术股份有限公司 Method, device and system for processing historical data in database
CN112597123A (en) * 2020-11-20 2021-04-02 贝壳技术有限公司 Data multi-version dynamic switching method and device
CN113032344A (en) * 2020-08-25 2021-06-25 广州锦行网络科技有限公司 Method for cleaning remote login log records
CN114461605A (en) * 2022-01-10 2022-05-10 北京元年科技股份有限公司 Method, device and equipment for realizing multi-version of transaction data of memory multidimensional database
CN115827660A (en) * 2023-02-14 2023-03-21 本原数据(北京)信息技术有限公司 Data updating method and device, electronic equipment and nonvolatile storage medium
WO2023124421A1 (en) * 2021-12-31 2023-07-06 深圳市兆珑科技有限公司 Transaction concurrency control method and apparatus, electronic device and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015101025A1 (en) * 2013-12-31 2015-07-09 华为技术有限公司 Multi-version concurrency control method in database, and database system
CN108363806A (en) * 2018-03-01 2018-08-03 上海达梦数据库有限公司 Multi-version concurrency control method, device, server and the storage medium of database
CN109471851A (en) * 2018-10-17 2019-03-15 上海达梦数据库有限公司 Data processing method, device, server and storage medium
CN109684338A (en) * 2018-11-20 2019-04-26 深圳花儿数据技术有限公司 A kind of data-updating method of storage system
CN110457292A (en) * 2019-08-12 2019-11-15 网易(杭州)网络有限公司 Management method, device, equipment and the storage medium of map

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015101025A1 (en) * 2013-12-31 2015-07-09 华为技术有限公司 Multi-version concurrency control method in database, and database system
CN108363806A (en) * 2018-03-01 2018-08-03 上海达梦数据库有限公司 Multi-version concurrency control method, device, server and the storage medium of database
CN109471851A (en) * 2018-10-17 2019-03-15 上海达梦数据库有限公司 Data processing method, device, server and storage medium
CN109684338A (en) * 2018-11-20 2019-04-26 深圳花儿数据技术有限公司 A kind of data-updating method of storage system
CN110457292A (en) * 2019-08-12 2019-11-15 网易(杭州)网络有限公司 Management method, device, equipment and the storage medium of map

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李文昊;李海芳;: "确定性分布式数据库中长事务处理方法研究" *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984379A (en) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 Read-write transaction control method, system, terminal device and storage medium
CN113032344A (en) * 2020-08-25 2021-06-25 广州锦行网络科技有限公司 Method for cleaning remote login log records
CN112231070A (en) * 2020-10-15 2021-01-15 北京金山云网络技术有限公司 Data writing and reading method and device and server
CN112597123A (en) * 2020-11-20 2021-04-02 贝壳技术有限公司 Data multi-version dynamic switching method and device
CN112380193A (en) * 2020-12-09 2021-02-19 北京海量数据技术股份有限公司 Method, device and system for processing historical data in database
WO2023124421A1 (en) * 2021-12-31 2023-07-06 深圳市兆珑科技有限公司 Transaction concurrency control method and apparatus, electronic device and readable storage medium
CN114461605A (en) * 2022-01-10 2022-05-10 北京元年科技股份有限公司 Method, device and equipment for realizing multi-version of transaction data of memory multidimensional database
CN115827660A (en) * 2023-02-14 2023-03-21 本原数据(北京)信息技术有限公司 Data updating method and device, electronic equipment and nonvolatile storage medium

Also Published As

Publication number Publication date
CN111090663B (en) 2023-07-07

Similar Documents

Publication Publication Date Title
CN111090663B (en) Transaction concurrency control method, device, terminal equipment and medium
JP5211514B2 (en) Update apparatus, update method, and update program
US10261869B2 (en) Transaction processing using torn write detection
US11080260B2 (en) Concurrent reads and inserts into a data structure without latching or waiting by readers
US20190129894A1 (en) Database Transaction Processing Method, Client, and Server
US7849060B2 (en) System and method for managing log information for transaction
KR102287677B1 (en) Data accessing method, apparatus, device, and storage medium
US8108356B2 (en) Method for recovering data in a storage system
CN111125040A (en) Method, apparatus and storage medium for managing redo log
CN113220490A (en) Transaction persistence method and system for asynchronous write-back persistent memory
US10198352B2 (en) Efficient pointer swizzling for persistent objects
US11983159B2 (en) Systems and methods for management of a log-structure
CN110019063B (en) Method for computing node data disaster recovery playback, terminal device and storage medium
CN115878027A (en) Storage object processing method and device, terminal and storage medium
CN113407376B (en) Data recovery method and device and electronic equipment
US9898468B2 (en) Single pass file system repair with copy on write
CN111984379B (en) Read-write transaction control method, system, terminal device and storage medium
CN112231105A (en) Block chain-based block writing method and system
CN107967222A (en) A kind of method and device of SPI-Nand searching datas page
US8966220B2 (en) Optimizing large page processing
CN107562642B (en) Checkpoint elimination method and device
CN117785878A (en) Database table renaming and inquiring method, device and equipment
CN114676165A (en) Data query method and device, electronic equipment and computer readable medium
CN116257519A (en) Data reading and writing method and device, computer equipment and storage medium
CN116842084A (en) Data query method, device and storage medium in cloud environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: No. 210, Liangjing Road, free trade zone, Pudong New Area, Shanghai, 200120

Applicant after: Shanghai Jinshida Software Technology Co.,Ltd.

Address before: No. 210, Liangjing Road, free trade zone, Pudong New Area, Shanghai, 200120

Applicant before: Shanghai Kingstar Software Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant