CN110059115B - Data reading method and device - Google Patents

Data reading method and device Download PDF

Info

Publication number
CN110059115B
CN110059115B CN201910208212.1A CN201910208212A CN110059115B CN 110059115 B CN110059115 B CN 110059115B CN 201910208212 A CN201910208212 A CN 201910208212A CN 110059115 B CN110059115 B CN 110059115B
Authority
CN
China
Prior art keywords
transaction
target
field
data table
field value
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.)
Active
Application number
CN201910208212.1A
Other languages
Chinese (zh)
Other versions
CN110059115A (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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Advanced New Technologies 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 Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201910208212.1A priority Critical patent/CN110059115B/en
Publication of CN110059115A publication Critical patent/CN110059115A/en
Application granted granted Critical
Publication of CN110059115B publication Critical patent/CN110059115B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • 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

Abstract

The application discloses a data reading method and a device, wherein the method comprises the following steps: receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction; and if the first transaction is not executed, reading a field value before modification of the target field from a preset data table, and returning the field value before modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before modification of the target field based on a write operation instruction of the first transaction.

Description

Data reading method and device
Technical Field
The present application relates to the field of data processing, and in particular, to a data reading method and apparatus.
Background
A distributed transaction is understood to mean that the participants of the transaction, the servers supporting the transaction, the resource servers and the transaction manager are located on different nodes of different distributed systems, respectively. Typically, a distributed transaction has a final consistency, e.g., the distributed transaction modifies a certain data from a to B, then the data may be A, B or other data during execution of the distributed transaction, but after the distributed transaction has ended, the data may only be a (transaction rollback) or B (transaction commit).
In practical applications, when a distributed transaction writes data, other transactions may read the data in parallel. However, there is a case where the distributed transaction rolls back after the execution ends, in which case, in order to guarantee the final consistency of the distributed transaction, the write operation of the distributed transaction to the data will be cancelled, resulting in invalidation of the data read by other transactions.
Disclosure of Invention
The embodiment of the application provides a data reading method and device, which are used for solving the problem that when a distributed transaction performs a writing operation on data and other transactions perform a reading operation on the data in parallel, if rollback occurs after the distributed transaction is finished, the data read by the other transactions are invalid.
In order to solve the technical problems, the embodiment of the application is realized as follows:
in a first aspect, a data reading method is provided, including:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
In a second aspect, a data reading apparatus is provided, including:
the receiving unit is used for receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and the reading unit is used for reading the field value before the modification of the target field from a preset data table and returning the field value before the modification to the second transaction if the first transaction is not executed, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to the write operation instruction of the first transaction.
In a third aspect, an electronic device is presented, the electronic device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
In a fourth aspect, a computer-readable storage medium storing one or more programs that, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
The above at least one technical scheme adopted by the embodiment of the application can achieve the following beneficial effects:
according to the technical scheme provided by the embodiment of the application, before the distributed transaction executes the write operation on the target field in the data table, the field value of the target field is stored in the preset data table, when the read operation instruction of other transactions on the target field is received, if the distributed transaction is not executed to be ended, the field value of the target field in the preset data table can be returned to the other transactions, so that the other transactions can be prevented from reading the data which is being modified by the distributed transaction before the distributed transaction is not executed to be ended, the other transactions can be prevented from reading invalid data, and the dirty reading problem is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a data reading method according to the prior art;
FIG. 2 is a flow chart of a data reading method according to an embodiment of the application;
FIG. 3 is a flow chart of a data reading method according to an embodiment of the application;
FIG. 4 is a schematic diagram of a data reading method according to an embodiment of the application;
FIG. 5 is a schematic diagram of the architecture of an electronic device according to one embodiment of the application;
fig. 6 is a schematic diagram of a data reading apparatus according to an embodiment of the present application.
Detailed Description
In general, distributed transactions may be executed in parallel with other transactions. In a typical application scenario, when a distributed transaction writes data in a data table, other transactions may read the data in parallel. For example, distributed transaction 1 writes data a in the data table and when modifying data a to data B, distributed transaction 2 may read data B.
However, in practical applications, after the distributed transaction is finished, the finishing state includes two states of commit and rollback, and when the finishing state is rollback, in order to ensure the final consistency of the distributed transaction, the write operation of the distributed transaction on the data is cancelled, that is, the data modified before is restored, so that the data read by other transactions is invalid, and the problem of dirty reading occurs.
Please refer to fig. 1 in detail. In fig. 1, t is a time axis, and distributed transaction 1 and distributed transaction 2 execute in parallel. Specifically:
distributed transaction 1 executes SQL1, updates the a field of id=1 row in data table 1, and updates the a field from 10 to 15. After the update is completed, distributed transaction 2 executes SQL2, and queries the a field of row id=1 in data table 1, at which point the data queried by distributed transaction 2 is 15.
After the end of the execution, the distributed transaction 1 causes the transaction to rollback for some reason, at this time, the distributed transaction 1 will cancel the update of the a field of the id=1 row in the data table 1, that is, the a word of the id=1 row in the data table 1 is restored from 15 to 10.
At this time, if the distributed transaction 2 again queries the a field of the id=1 row in the data table 1, the queried data will be 10, which is inconsistent with the previously queried data 15, so that the data queried by the distributed transaction 2 for the first time is invalid, and the problem of dirty reading occurs.
When the problem of dirty reading occurs, although the final consistency of the data is not affected (the distributed transaction is re-executed after rollback), chaotic data is read, and certain interference is brought to the user.
In order to solve the above problems, an embodiment of the present application provides a data reading method and apparatus, where the method includes: receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction; and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
According to the technical scheme provided by the embodiment of the application, before the distributed transaction executes the write operation on the target field in the data table, the field value of the target field is stored in the preset data table, when the read operation instruction of other transactions on the target field is received, if the distributed transaction is not executed to be ended, the field value of the target field in the preset data table can be returned to the other transactions, so that the other transactions can be prevented from reading the data which is being modified by the distributed transaction before the distributed transaction is not executed to be ended, the other transactions can be prevented from reading invalid data, and the dirty reading problem is avoided.
In order to make the technical solution of the present application better understood by those skilled in the art, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, shall fall within the scope of the application.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
FIG. 1 is a flow chart of a data reading method according to an embodiment of the application. The method comprises the following steps.
S102: and receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction.
In S102, before receiving the read operation instruction of the second transaction, the method may further include the steps of:
firstly, receiving a write operation instruction of a first transaction;
second, a field value of a target field of a target record in a target data table is stored in a preset data table before responding to a write operation instruction.
The write operation instruction of the first transaction may be used to write to a target field of a target record in a target data table. After receiving the write operation instruction of the first transaction, before responding to the write operation instruction, the field value of the target field of the target record in the target data table can be queried based on the write operation instruction, and the field value of the target field is stored in the preset data table. The format of the preset data table may be the same as that of the target data table.
In one implementation, the preset data table may preferably be stored in the form of an undo log ("undo log").
After the field value of the target field is stored in the preset data table, the field value of the target field of the target record in the target data table can be modified in response to the write operation instruction of the first transaction, namely based on the write operation instruction, so as to obtain the field value after the modification of the target field.
After obtaining the modified field value of the target field, a read operation instruction of the second transaction on the target field of the target record in the target data table may be received.
In this embodiment, the second transaction may be a distributed transaction or a local transaction, which is not specifically limited herein.
After receiving the read operation instruction of the second transaction, S104 may be performed.
S104: and if the first transaction is not executed, reading the field value before modification of the target field from a preset data table, and returning the field value before modification to the second transaction.
In S104, after receiving the read operation instruction of the second transaction, it may be determined whether the execution of the first transaction is ended.
If the first transaction is not executed, the field value of the target field may be read from the preset data table recorded in S102, and the field value may be returned to the second transaction. The field value read from the preset data table is the field value before the first transaction modifies the target field.
In this way, since the second transaction is not allowed to read the data being modified by the first transaction until the first transaction is not executed is finished, the second transaction can be prevented from reading invalid data, and thus the problem of dirty reading is avoided.
If the execution of the first transaction is finished, the field value of the target field may be read from the target data table, and the read field value may be returned to the second transaction. Specifically:
if the ending state of the first transaction is rollback, it may be stated that the modification of the target field by the first transaction fails, at this time, a field value after rollback of the target field of the target record may be read from the target data table, and the rolled-back field value is returned to the second transaction, where the rolled-back field value may be understood as a field value before the modification of the target field by the first transaction;
if the ending status of the first transaction is commit, it may be stated that the modification of the target field by the first transaction is successful, at this time, the modified field value of the target field of the target record may be read from the target data table, and the modified field value may be returned to the second transaction.
In this way, the second transaction can read valid data in the event that execution of the first transaction is completed.
In this embodiment, if the execution of the first transaction is ended, the field value of the target field stored in the preset data table may be cleared, so as to save the storage space.
According to the technical scheme provided by the embodiment of the application, before the distributed transaction executes the write operation on the target field in the data table, the field value of the target field is stored in the preset data table, when the read operation instruction of other transactions on the target field is received, if the distributed transaction is not executed to be ended, the field value of the target field in the preset data table can be returned to the other transactions, so that the other transactions can be prevented from reading the data which is being modified by the distributed transaction before the distributed transaction is not executed to be ended, the other transactions can be prevented from reading invalid data, and the dirty reading problem is avoided.
For ease of understanding the entire solution, reference may be made to fig. 3. Fig. 3 is a flow chart of a data reading method according to an embodiment of the application, and the embodiment shown in fig. 3 includes the following steps:
s301: and receiving a write operation instruction of the first transaction, wherein the write operation instruction is used for performing write operation on a target field of a target record in a target data table.
Wherein the first transaction is a distributed transaction.
S302: and storing the field value of the target field in a preset data table.
In S302, after receiving the write operation instruction of the first transaction, a field value of a target field of the target record in the target data table may be queried based on the write operation instruction, and the queried field value may be stored in the preset data table. The format of the preset data table may be the same as that of the target data table, and preferably, the preset data table may be stored in the form of a revocation log.
S303: and responding to the write operation instruction, and modifying the target field to obtain a modified field value.
In S303, after storing the field value of the target field in the preset data table, the field value of the target field may be modified based on the write operation instruction of the first transaction.
S304: and receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading the target field of the target record in the target data table.
The second transaction is a transaction executed in parallel with the first transaction, and may be a distributed transaction or a local transaction, which is not particularly limited herein.
S305: and judging whether the execution of the first transaction is ended.
If the first transaction is not completed, S306 may be executed; if the first transaction execution ends, S307 may be executed.
S306: and reading the field value before modification of the target field from the preset data table, and returning the field value before modification to the second transaction.
Thus, when the first transaction is not executed and ends, the second transaction is not allowed to read the data which is being modified by the first transaction, so that the second transaction is prevented from reading invalid data, and the dirty reading problem is prevented.
After returning the field value before the target field modification to the second transaction, S309 may be performed.
S307: and reading the field value of the target field from the target data table, and returning the read field value to the second transaction.
Specifically, if the ending state of the first transaction is rollback, the field value returned to the second transaction is the field value before the first transaction modifies the target field; and if the ending state of the first transaction is commit, the field value returned to the second transaction is the field value after the first transaction modifies the target field.
After returning the read field value to the second transaction, S308 may be performed.
S308: and clearing the field value of the target field stored in the preset data table.
S309: and (5) ending.
Based on the contents described in S301 to S309, by storing the data before the distributed transaction performs the write operation, when the data is read by another transaction before the distributed transaction ends, the data stored before is returned to the other transaction, so that the data that is being modified by the distributed transaction can be prevented from being read by the other transaction, and the problem of dirty reading can be avoided.
To facilitate an understanding of the "dirty read" problem that embodiments of the present application address, reference may be made to FIG. 4. FIG. 4 is a schematic diagram of a data reading method according to an embodiment of the application. In fig. 4, a write operation instruction and a read operation instruction of a transaction are exemplified as SQL manipulation commands.
In fig. 4, t is a time axis, and distributed transaction 1 and distributed transaction 2 execute in parallel. Specifically:
distributed transaction 1 executes SQL1, requiring an update to the a field of row id=1 in data table 1. Before updating, the field value 10 of the a field of the id=1 row in the data table 1 may be stored in the data table 2, and the data table 2 is stored in the form of "undolog".
After storing the field value of the a field 10, SQL1 may be responded to and the field value of the a field updated from 10 to 15.
After execution of SQL1 ends, distributed transaction 2, which is executed in parallel with distributed transaction 1, executes SQL2, SQL2 being used to query the a field of row id=1 in data table 1. At this time, since the distributed transaction 1 has not been executed, the field value 10 before the modification of the a field is read from the data table 2, and returned to the distributed transaction 2, that is, the data queried by the distributed transaction 2 is 10.
After the distributed transaction 1 is executed, assuming that the distributed transaction 1 rolls back for some reason, the field value of the a field of the id=1 row in the data table 1 will roll back to the field value before being unmodified, that is, the field value of the a field is changed from 15 to 10.
At this time, if the distributed transaction 2 executes SQL2 again and queries the a field of the row id=1 in the data table 1, the data returned to the distributed transaction 2 is 10 because the execution of the distributed transaction 1 is completed, that is, the data queried by the distributed transaction 2 is 10, which is consistent with the data queried during the execution of the distributed transaction 1.
Based on the above overall process, although the distributed transaction 1 has rolled back after the execution ends, the distributed transaction 2 does not read invalid data.
The foregoing describes certain embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Fig. 5 is a schematic structural view of an electronic device according to an embodiment of the present application. Referring to fig. 5, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 5, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, and forms a data reading device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
The method performed by the data reading apparatus disclosed in the embodiment of fig. 5 of the present application may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
The electronic device may also execute the methods of fig. 2 to 4 and implement the functions of the data reading apparatus in the embodiments shown in fig. 2 to 4, which are not described herein.
Of course, other implementations, such as a logic device or a combination of hardware and software, are not excluded from the electronic device of the present application, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or a logic device.
The embodiments of the present application also provide a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiments shown in fig. 2-4, and in particular to perform the operations of:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction.
Fig. 6 is a schematic diagram of a data reading device 60 according to an embodiment of the present application. Referring to fig. 6, in a software implementation, the data reading device 60 may include: a receiving unit 61 and a reading unit 62, wherein:
a receiving unit 61, configured to receive a read operation instruction of a second transaction, where the read operation instruction is configured to read a target field of a target record in a target data table, where the target field is modified based on a write operation instruction of a first transaction, where the first transaction is a distributed transaction and is executed in parallel with the second transaction;
and a reading unit 62, configured to read, if the first transaction is not executed, a field value before modification of the target field from a preset data table, and return the field value before modification to the second transaction, where the preset data table is used to store the field value of the target field before modification of the target field according to a write operation instruction of the first transaction.
Optionally, the data reading device 60 further comprises a processing unit 63, wherein:
the receiving unit 61 receives a write operation instruction of the first transaction before receiving a read operation instruction of the second transaction, where the write operation instruction is used to perform a write operation on the target field of the target record in the target data table;
the processing unit 63 stores the field value of the target field in the preset data table before responding to the write operation instruction.
Optionally, the preset data table is stored in the form of a revocation log.
Optionally, after storing the field value of the target field in the preset data table, the processing unit 63 modifies the target field in response to the write operation request to obtain a modified field value.
Optionally, the second transaction is a distributed transaction or a local transaction.
Optionally, the reading unit 62, if determining that the first transaction execution ends,:
if the ending state of the first transaction is rollback, reading the field value of the rolled back target field from the target data table, and returning the field value of the rolled back to the second transaction;
and if the ending state of the first transaction is commit, reading the modified field value of the target field from the target data table, and returning the modified field value to the second transaction.
Optionally, the reading unit 62 clears the field value of the target field stored in the preset data table if the execution of the first transaction is ended.
The data reading device 60 provided in the embodiment of the present application may also execute the methods of fig. 2 to 4, and implement the functions of the data reading device in the embodiment shown in fig. 2 to 4, which are not described herein again.
In summary, the foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The embodiments of the present application are described in a progressive manner, and the same and similar parts of the embodiments are all referred to each other, and each embodiment is mainly described in the differences from the other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.

Claims (9)

1. A data reading method, comprising:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
if the first transaction is not executed, reading a field value before the modification of the target field from a preset data table, and returning the field value before the modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before the modification of the target field according to a write operation instruction of the first transaction;
if the first transaction execution ends, then: if the ending state of the first transaction is rollback, reading the field value of the rolled back target field from the target data table, and returning the field value of the rolled back to the second transaction; and if the ending state of the first transaction is commit, reading the modified field value of the target field from the target data table, and returning the modified field value to the second transaction.
2. The method of claim 1, prior to receiving a read operation instruction for a second transaction, the method further comprising:
receiving a write operation instruction of the first transaction, wherein the write operation instruction is used for performing write operation on the target field of the target record in the target data table;
and before responding to the write operation instruction, storing the field value of the target field in the preset data table.
3. The method according to claim 2,
the preset data table is stored in the form of a revocation log.
4. A method according to claim 2 or 3, after storing the field value of the target field in the preset data table, the method further comprising:
and responding to the write operation request, and modifying the target field to obtain a modified field value.
5. The method according to claim 1,
the second transaction is a distributed transaction or a local transaction.
6. The method of claim 1, the method further comprising:
and if the execution of the first transaction is finished, clearing the field value of the target field stored in the preset data table.
7. A data reading apparatus comprising:
the receiving unit is used for receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
the reading unit is used for reading the field value before the modification of the target field from a preset data table and returning the field value before the modification to the second transaction if the first transaction is not executed, wherein the preset data table is used for storing the field value of the target field before the modification of the target field based on the write operation instruction of the first transaction; if the first transaction execution ends, then: if the ending state of the first transaction is rollback, reading the field value of the rolled back target field from the target data table, and returning the field value of the rolled back to the second transaction; and if the ending state of the first transaction is commit, reading the modified field value of the target field from the target data table, and returning the modified field value to the second transaction.
8. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
if the first transaction is not executed, reading a field value before modification of the target field from a preset data table, and returning the field value before modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before modification of the target field based on a write operation instruction of the first transaction;
if the first transaction execution ends, then: if the ending state of the first transaction is rollback, reading the field value of the rolled back target field from the target data table, and returning the field value of the rolled back to the second transaction; and if the ending state of the first transaction is commit, reading the modified field value of the target field from the target data table, and returning the modified field value to the second transaction.
9. A computer readable storage medium storing one or more programs, which when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of:
receiving a read operation instruction of a second transaction, wherein the read operation instruction is used for reading a target field of a target record in a target data table, the target field is modified based on a write operation instruction of a first transaction, and the first transaction is a distributed transaction and is executed in parallel with the second transaction;
if the first transaction is not executed, reading a field value before modification of the target field from a preset data table, and returning the field value before modification to the second transaction, wherein the preset data table is used for storing the field value of the target field before modification of the target field based on a write operation instruction of the first transaction;
if the first transaction execution ends, then: if the ending state of the first transaction is rollback, reading the field value of the rolled back target field from the target data table, and returning the field value of the rolled back to the second transaction; and if the ending state of the first transaction is commit, reading the modified field value of the target field from the target data table, and returning the modified field value to the second transaction.
CN201910208212.1A 2019-03-19 2019-03-19 Data reading method and device Active CN110059115B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910208212.1A CN110059115B (en) 2019-03-19 2019-03-19 Data reading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910208212.1A CN110059115B (en) 2019-03-19 2019-03-19 Data reading method and device

Publications (2)

Publication Number Publication Date
CN110059115A CN110059115A (en) 2019-07-26
CN110059115B true CN110059115B (en) 2023-08-11

Family

ID=67317199

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910208212.1A Active CN110059115B (en) 2019-03-19 2019-03-19 Data reading method and device

Country Status (1)

Country Link
CN (1) CN110059115B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115422156A (en) * 2022-04-02 2022-12-02 北京奥星贝斯科技有限公司 Constraint relation checking method and device for database

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572506A (en) * 2013-10-18 2015-04-29 阿里巴巴集团控股有限公司 Method and device for concurrent access to memory

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572506A (en) * 2013-10-18 2015-04-29 阿里巴巴集团控股有限公司 Method and device for concurrent access to memory

Also Published As

Publication number Publication date
CN110059115A (en) 2019-07-26

Similar Documents

Publication Publication Date Title
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
JP5010601B2 (en) Direct update software transactional memory
EP1960878B1 (en) Coordinating access to memory locations for hardware transactional memory transactions and software transactional memory transactions
US8473950B2 (en) Parallel nested transactions
CN111898139B (en) Data reading and writing method and device and electronic equipment
CN110018884B (en) Distributed transaction processing method, coordination device, database and electronic equipment
CN111383031B (en) Intelligent contract execution method and system in block chain and electronic equipment
CN111858629B (en) Implementation method and device for two-stage submitting distributed transaction update database
CN106844014B (en) Method and device for realizing suspension prevention of distributed transactions
CN101310258A (en) Protecting shared variables in a software transactional memory system
CN112506671B (en) Transaction processing method and device in block chain and electronic equipment
CN109634974A (en) A kind of data processing method, system and associated component
CN112181902B (en) Database storage method and device and electronic equipment
CN109582398B (en) State processing method and device and electronic equipment
CN110059115B (en) Data reading method and device
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
US9170903B2 (en) System level architecture verification for transaction execution in a multi-processing environment
CN108829498B (en) Service data access method and device
CN111709748B (en) Transaction execution method and device with business attribute and electronic equipment
JP2821345B2 (en) Asynchronous I / O control method
CN115033350A (en) Execution method and device of distributed transaction
CN115269199A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN109271277B (en) Access method, device and system after database downtime
CN108959403A (en) A kind of distributed transaction processing method and device
CN110765144B (en) Distributed heterogeneous database data processing method and device

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
TA01 Transfer of patent application right

Effective date of registration: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant