CN112905614B - Data updating method and device, electronic equipment and computer readable storage medium - Google Patents

Data updating method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN112905614B
CN112905614B CN202110189554.0A CN202110189554A CN112905614B CN 112905614 B CN112905614 B CN 112905614B CN 202110189554 A CN202110189554 A CN 202110189554A CN 112905614 B CN112905614 B CN 112905614B
Authority
CN
China
Prior art keywords
data
update
current
version
updated
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
CN202110189554.0A
Other languages
Chinese (zh)
Other versions
CN112905614A (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.)
Postal Savings Bank of China Ltd
Original Assignee
Postal Savings Bank of China 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 Postal Savings Bank of China Ltd filed Critical Postal Savings Bank of China Ltd
Priority to CN202110189554.0A priority Critical patent/CN112905614B/en
Publication of CN112905614A publication Critical patent/CN112905614A/en
Application granted granted Critical
Publication of CN112905614B publication Critical patent/CN112905614B/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/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
    • G06F16/219Managing data history or versioning

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 invention discloses a data updating method and device, electronic equipment and a computer readable storage medium. The data updating method comprises the following steps: and reading the object data, wherein the object data is operated by a plurality of transaction objects, detecting whether update data exists in the object data, wherein the update data is changed based on a current data version, the current data version corresponds to a current data value, if the update data exists in the object data, merging all the update data, and finally loading the merged update data into the current data value. The invention solves the technical problem of low success rate when data update is carried out under concurrent transactions in the related technology.

Description

Data updating method and device, electronic equipment and computer readable storage medium
Technical Field
The present invention relates to the field of data updating technologies, and in particular, to a data updating method and apparatus, an electronic device, and a computer readable storage medium.
Background
The lock is used for concurrency control, and aims to avoid unreasonable phenomenon when different users operate the same data, and currently, pessimistic locks and optimistic locks are mainly used, wherein the pessimistic locks are characterized by exclusive and exclusive, and typical pessimistic locks are mainly shared locks or exclusive locks; the optimistic lock will assume that the data will not collide under the general condition, so when the data is submitted and updated, it will be detected whether the data is collided or not, if the collision is found, the information is returned to the user, so that the user decides how to do so, which essentially solves the problem of reading the data under concurrent transaction, but after the data is read, the data is updated, only the data Version (Version) is checked, if the collision is not found, and the update is not carried out, so that the problem of updating the data under high concurrent transaction is not solved, i.e. the optimistic lock optimistically reflects that only one transaction reads and updates, and no other transaction updates the data, so that once there are other transactions to update the data during one transaction reading and updating, the optimistic lock loses effect.
In the related art, the steps of using an optimistic lock under concurrent transactions are: 1, reading data from a data source, including a version of the data; 2, processing the data according to the need, and preparing the data to be updated; 3, judging the data version before updating; 4, if the versions are consistent, updating the processed data to a data source; and 5, if the versions are inconsistent, not updating the data. If the versions are inconsistent, the data update cannot be performed, that is, the change of the data is zero tolerant, and once the data change occurs, all the data update fails, and under the scenario of a large number of concurrent updates, a large number of update operations need to be retried, that is, the data is read again, the data processing is performed again, the version judgment is performed again, once the versions are inconsistent again, the steps are repeated again, the transaction timeout failure is likely to be caused, and even if the final update is successful, a large amount of system resources are wasted for repeated calculation.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The embodiment of the invention provides a data updating method and device, electronic equipment and a computer readable storage medium, which at least solve the technical problem of low success rate when data updating is performed under concurrent transactions in the related technology.
According to an aspect of an embodiment of the present invention, there is provided a data updating method including: reading object data, wherein the object data is operated and processed by a plurality of transaction objects; detecting whether update data exists in the object data, wherein the update data is changed data based on a current data version, and the current data version corresponds to a current data value; if the update data exists in the object data, combining all the update data; and loading the merged updated data into the current value of the data.
Optionally, the step of detecting whether there is update data in the object data includes: based on the current data value, detecting whether another transaction object changes the current data value in the current data version, and determining whether updated data exists in the object data.
Optionally, after detecting whether there is update data in the object data, the data update method further includes: detecting that no update data exists in the object data, and recording all the read object data; all object data is stored in the transaction database.
Optionally, if update data exists in the object data, the step of merging all update data includes: if the object data has update data, calculating a difference value between the update data and original data stored in a current value of the data; and if the difference value is within the preset difference value range, combining all the updated data.
Optionally, if update data exists in the object data, the step of merging all update data further includes: if updated data exists in the object data, judging whether the current data version is consistent with the historical record version or not; if the current data version is inconsistent with the history version, merging all updated data in the current data version; and loading all the merged updated data to the current value of the data.
Optionally, after determining whether the current data version and the history version are consistent, the data updating method further includes: and if the current data version is consistent with the historical record version, recording the current data version.
According to another aspect of the embodiment of the present invention, there is also provided a data updating apparatus, including: a reading unit configured to read object data, where the object data is subjected to operation processing by a plurality of transaction objects; the detection unit is used for detecting whether update data exist in the object data, wherein the update data are changed data on the basis of a current data version, and the current data version corresponds to a current data value; a merging unit, configured to merge all update data if the update data exists in the object data; and the loading unit is used for loading the combined updated data into the current value of the data.
Optionally, the detection unit includes: and the first detection module is used for detecting whether another transaction object carries out change operation on the current value of the data in the current data version based on the current value of the data and determining whether updated data exists in the object data.
Optionally, the data updating apparatus further includes: the second detection module is used for detecting whether the update data exist in the object data or not and recording all the read object data after detecting that the update data do not exist in the object data; and the first storage module is used for storing all object data in the transaction database.
Optionally, the merging unit includes: the first calculation module is used for calculating the difference value between the updated data and the original data stored in the current value of the data if the updated data exists in the object data; and the first merging module is used for merging all the updated data if the difference value is within a preset difference value range.
Optionally, the merging unit further includes: the first judging module is used for judging whether the current data version is consistent with the historical record version or not if updated data exists in the object data; the second merging module is used for merging all updated data in the current data version if the current data version is inconsistent with the historical record version; and the first loading module is used for loading all the merged updated data to the current value of the data.
Optionally, the data updating apparatus further includes: and the first recording module is used for recording the current data version if the current data version is consistent with the historical record version after judging whether the current data version is consistent with the historical record version.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the data update method described above via execution of the executable instructions.
According to another aspect of the embodiment of the present invention, there is also provided a computer readable storage medium, where the computer readable storage medium includes a stored computer program, and when the computer program runs, the device where the computer readable storage medium is controlled to execute the above-mentioned data updating method.
According to another aspect of the embodiment of the present invention, there is also provided a processor, where the processor is configured to execute a program, and the program executes the data updating method described above.
In the embodiment of the invention, the object data is read, wherein the object data is operated and processed by a plurality of transaction objects, and then whether update data exists in the object data is detected, wherein the update data is changed data based on a current data version, the current data version corresponds to a current data value, if the update data exists in the object data, all the update data are combined, and finally the combined update data are loaded into the current data value. In the embodiment, the optimistic lock is enhanced in terms of data update on the basis of the existing optimistic lock, so that during the reading and updating of one or more transactions, even if other transactions update data, the data update of part or all of the concurrent transactions can be completed within a certain tolerance range, thereby improving the success rate of the data update of the concurrent transactions and further solving the technical problem of low success rate when the data update is performed under the concurrent transactions in the related art.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
FIG. 1 is a flow chart of an alternative data update method according to an embodiment of the invention;
FIG. 2 is a flow chart of another alternative data update method according to an embodiment of the invention;
FIG. 3 is a schematic diagram of an alternative data updating apparatus according to an embodiment of the present invention;
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
To facilitate an understanding of the invention by those skilled in the art, some terms or nouns involved in the various embodiments of the invention are explained below:
optimistic lock is a mechanism which adopts a looser locking mechanism to avoid data processing errors caused by reasons such as unreal reading of a database, overlong service processing time and the like.
Tolerance mechanism refers to a mechanism capable of accepting the degree of data change, namely, the tolerance degree of the data change, within a certain range and completing data updating as much as possible based on the tolerance degree.
And the arbitration recording mechanism is used for judging whether the rule condition of the data recording is carried out.
And the arbitration updating mechanism is used for judging whether the rule condition of data updating is carried out or not.
The following embodiments of the invention are applicable to a variety of industrial transactions, including but not limited to: the invention increases tolerance mechanism based on the existing optimistic lock, can combine the update data which happens before when needed (i.e. when the update is needed), reduces the number of times of modifying the current value of the data, makes the concurrent data update of the same field possible, and simultaneously, can process the data update as much as possible through arbitration mechanism in terms of tolerance of concurrent update data, and improves the success rate of concurrent transaction processing.
The present invention will be described in detail with reference to examples.
Example 1
In accordance with an embodiment of the present invention, a data update method embodiment is provided, it being noted that the steps shown in the flowchart of the figures may be performed in a computer system, such as a set of computer executable instructions, and, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order other than that shown or described herein.
FIG. 1 is a flow chart of an alternative data update method according to an embodiment of the invention, as shown in FIG. 1, comprising the steps of:
step S102, reading object data, wherein the object data is operated and processed by a plurality of transaction objects;
step S104, whether update data exist in the object data is detected, wherein the update data are changed data on the basis of a current data version, and the current data version corresponds to a current data value;
step S106, if the object data has update data, combining all the update data;
step S108, the combined updated data is loaded into the current value of the data.
Through the steps, the object data can be read, wherein the object data is operated and processed by a plurality of transaction objects, then whether update data exists in the object data is detected, wherein the update data is changed based on a current data version, the current data version corresponds to a current data value, if the update data exists in the object data, all the update data are combined, and finally the combined update data are loaded into the current data value. In the embodiment, the optimistic lock is enhanced in terms of data update on the basis of the existing optimistic lock, so that during the reading and updating of one or more transactions, even if other transactions update data, the data update of part or all of the concurrent transactions can be completed within a certain tolerance range, thereby improving the success rate of the data update of the concurrent transactions and further solving the technical problem of low success rate when the data update is performed under the concurrent transactions in the related art.
Embodiments of the present invention will be described in detail below with reference to the foregoing steps.
Step S102, reading object data, wherein the object data is operated by a plurality of transaction objects.
In this embodiment, the read object data is generally performed in a case where the object data is simultaneously processed by a plurality of transaction objects, and the data types include, but are not limited to: the number type (for example, integer type, floating point type, etc.), the character string type, the collection, the dictionary, etc., the plurality of transaction objects can be a plurality of ordinary users, a plurality of administrators, or a plurality of ordinary users and administrators, and the operation processing performed on the data can be four types of operations of adding, deleting, modifying, and checking.
Taking bank accounting as an example, the data types are digital, the addition is completed when the account is signed, and the deletion is completed when the account is opened, so that the data types are basically disposable; "look-up" is the most frequently occurring of the four types of operations, but since no change is made to the data itself, multiple transaction objects are unaffected (but affected by the other three types of operations) when operated simultaneously; "change" (i.e., data update), while not occurring "look-up" more often, is the most influential data and is a relatively frequent data operation throughout the life of the data (from add to delete).
Step S104, whether update data exist in the object data is detected, wherein the update data are changed data based on a current data version, and the current data version corresponds to a current value of the data.
Since, in the concurrent transaction process, when one transaction invokes the object data, another transaction may also synchronously invoke the object data and perform operations such as querying, modifying, etc. on the object data, it is required to determine whether the object data is updated before performing the operations on the object data.
In this embodiment, if a transaction a involves a data update, it may be a "check" -logic processing- "change" process, and the "change" direction (i.e. the direction of data change) may be an increase (abbreviated as direction W) or decrease (abbreviated as direction M), and since this embodiment is applied in a concurrent transaction scenario, while the transaction a occurs with other transactions, taking two concurrent transactions as an example, another transaction B involves a data update, then, in addition to the direction of the transaction itself for the data "change", the direction of the other transaction "change" is also concerned, that is, the data update may be influenced by the direction of the other concurrent transaction for the data "change", which may be expressed as the "data change permission direction" (i.e. the "tolerance" of data change) of one transaction in the data change, may be divided into "permission increase" (abbreviated as direction Z), "permission decrease" (abbreviated as direction J), and permission limit (abbreviated as direction Z2), and permission limit (abbreviated as permission limit (direction J2).
The "arbitration mechanism" established in this embodiment is based on an optimistic lock, and arbitrates data update in the event of concurrent multi-transaction according to the "data change direction" and the "data change permission direction" and related parameters, so as to determine whether each transaction can successfully update data. The data structures involved in this embodiment are shown in table 1 (for one determined account):
TABLE 1
If the transactions with TransOrder 2, 3 and 5 in Table 1 fail based on the existing optimistic lock, only the transaction with TransOrder 2 fails and the transaction with TransOrder 3 and 5 succeeds by adopting the optimistic lock based on the tolerance mechanism strengthening in the embodiment.
Optionally, the step of detecting whether the update data exists in the object data includes: based on the current value of the data, detecting whether another transaction object changes the current value of the data in the current data version, and determining whether updated data exists in the object data.
In this embodiment, while reading data, it is checked whether other transactions have been data updated (e.g., "changed") based on the current version, and if so, an "arbitration update mechanism" is triggered, otherwise an "arbitration record mechanism" is triggered.
As an optional implementation manner of this embodiment, after detecting whether update data exists in the object data, the data update method further includes: detecting that no update data exists in the object data, and recording all the read object data; all object data is stored in the transaction database.
In this embodiment, when there is no update data in the detection target data, an "arbitration recording mechanism" is triggered, and related data is directly recorded and stored in the transaction database while the data is acquired.
Step S106, if the update data exists in the object data, combining all the update data.
In this embodiment, when the update data exists in the detection object data, an "arbitration update mechanism" is triggered, which indicates that the current version of data needs to be merged and updated, and at this time, all the data needing to be updated are merged and updated to the current value of the data.
Optionally, if the update data exists in the object data, the step of merging all the update data includes: if the update data exist in the object data, calculating a difference value between the update data and the original data stored in the current value of the data; if the difference value is within the preset difference value range, all the updated data are combined.
The above-mentioned alternative embodiment is that a tolerance mechanism is added on the basis of the optimistic lock, that is, the data with the difference value within the preset difference value range can be processed continuously, without excluding the object data which will not affect the result.
If an arbitration update mechanism is triggered, it indicates that the data of the current version needs to be merged and updated, and at the moment, all the data needing to be updated are merged and updated to the current value of the data, which is different from the existing optimistic lock, the optimistic lock modifies the current value of the data when each data is updated, and the invention creates that the data which is updated before is merged when the data is needed (has to be updated), so that the number of times of modifying the current value of the data can be reduced through a tolerance mechanism.
Alternatively, if the update data exists in the object data, the step of merging all the update data further includes: if the update data exists in the object data, judging whether the current data version is consistent with the historical record version or not; if the current data version is inconsistent with the historical record version, merging all updated data in the current data version; and loading all the merged updated data to the current value of the data.
Alternatively, after determining whether the current data version and the history version are consistent, the data update method further includes: and if the current data version is consistent with the historical record version, recording the current data version.
In this embodiment, when updating data, it is necessary to determine whether the versions of the data are consistent, if so, an "arbitration record mechanism" is triggered, otherwise, an "arbitration update mechanism" is triggered. If an arbitration recording mechanism is triggered, in a data updating scene, arbitration is required according to the related data recorded when the data is acquired, if the arbitration condition is met, the data recording is completed and is used as the basis for the subsequent data updating, otherwise, the data is refused; if an arbitration update mechanism is triggered, it indicates that the data of the current version needs to be merged and updated, and at the moment, all the data needing to be updated are merged and updated to the current value of the data, which is different from the existing optimistic lock, the existing optimistic lock directly refuses once the data version is found inconsistent, but in the embodiment, the data update is facilitated as much as possible through the processing of the arbitration mechanism, so that the success rate of the data update is improved.
Step S108, the combined updated data is loaded into the current value of the data.
In this embodiment, when data needs to be updated, all data that needs to be updated are combined and updated to the current value of the data.
FIG. 2 is a flow chart of another alternative data update method according to an embodiment of the invention, as shown in FIG. 2, comprising the steps of:
transaction performs a data read operation (e.g., "look up"), which may be performed based on an optimistically lock-like manner;
2, while reading data, checking whether other transactions are updated (for example, "changed") on the basis of the current version, if so, triggering an arbitration update mechanism, otherwise, triggering an arbitration record mechanism;
and 3.1, if an arbitration update mechanism is triggered, the data of the current version is required to be merged and updated, and at the moment, all the data which need to be updated are merged and updated to the current value of the data. Compared with the existing optimistic lock which modifies the current value of the data when each piece of data is updated, the embodiment performs merging processing on the update data which occurs before when the current value of the data is required (namely when the current value of the data is required to be updated), so that the number of times of modifying the current value of the data is reduced;
3.2, if an arbitration recording mechanism is triggered, directly recording related data when the data is read;
4, after the transaction reads the data, performing various logic processes and applying for updating the data;
5, judging whether the data versions are consistent when updating the data, if so, triggering an arbitration record mechanism, otherwise, triggering an arbitration update mechanism;
6.1, if an arbitration record mechanism is triggered, when data is updated, arbitration is required according to the related data recorded when the data is read, if the arbitration condition is met, data recording is completed and is used as the basis for subsequent data updating, otherwise, rejection is carried out;
and 6.2, if an arbitration update mechanism is triggered, merging and updating the data of the current version are needed, and at the moment, merging all the data needing to be updated and updating the data to the current value of the data. Compared with the existing optimistic lock which directly refuses once the data version is inconsistent, the embodiment processes the data update as much as possible through the arbitration mechanism, thereby improving the success rate of the data update.
Based on the tolerance mechanism in the embodiment, the same data is allowed to be updated concurrently under the scene of updating a large amount of concurrent data, so that the updating success rate is effectively improved, and the processing efficiency is improved.
The invention is described below in connection with alternative embodiments.
Example two
An embodiment of the present invention provides a data updating apparatus, where each implementation unit included in the processing apparatus corresponds to each implementation step in the above-mentioned embodiment.
Fig. 3 is a schematic diagram of an alternative data updating apparatus according to an embodiment of the present invention, as shown in fig. 3, the data updating apparatus includes: a reading unit 30, a detecting unit 32, a merging unit 34, a loading unit 36, wherein,
a reading unit 30 for reading object data, wherein the object data is operated by a plurality of transaction objects;
a detecting unit 32, configured to detect whether update data exists in the object data, where the update data is data that has changed based on a current data version, and the current data version corresponds to a current value of the data;
a merging unit 34, configured to merge all the update data if there is update data in the object data;
and a loading unit 36, configured to load the merged updated data into the current value of the data.
In the above data updating apparatus, the reading unit 30 may read the object data, where the object data is processed by a plurality of transaction objects, and then the detecting unit 32 detects whether there is update data in the object data, where the update data is data that has changed based on a current data version, and the current data version corresponds to a current data value, if there is update data in the object data, all the update data are combined by the combining unit 34, and finally the combined update data is loaded into the current data value by the loading unit 36. In the embodiment, the optimistic lock is enhanced in terms of data update on the basis of the existing optimistic lock, so that during the reading and updating of one or more transactions, even if other transactions update data, the data update of part or all of the concurrent transactions can be completed within a certain tolerance range, thereby improving the success rate of the data update of the concurrent transactions and further solving the technical problem of low success rate when the data update is performed under the concurrent transactions in the related art.
Optionally, the detection unit includes: the first detection module is used for detecting whether another transaction object changes the current value of the data in the current data version based on the current value of the data and determining whether updated data exists in the object data.
Optionally, the data updating apparatus further includes: the second detection module is used for detecting whether the update data exist in the object data or not, detecting that the update data do not exist in the object data, and recording all the read object data; and the first storage module is used for storing all object data in the transaction database.
Optionally, the merging unit includes: the first calculation module is used for calculating the difference value between the updated data and the original data stored in the current value of the data if the updated data exists in the object data; and the first merging module is used for merging all the updated data if the difference value is within a preset difference value range.
Optionally, the merging unit further includes: the first judging module is used for judging whether the current data version is consistent with the historical record version or not if updated data exists in the object data; the second merging module is used for merging all the updated data in the current data version if the current data version is inconsistent with the historical record version; and the first loading module is used for loading all the merged updated data to the current value of the data.
Optionally, the data updating apparatus further includes: and the first recording module is used for recording the current data version if the current data version is consistent with the historical record version after judging whether the current data version is consistent with the historical record version.
The data updating apparatus may further include a processor and a memory, and the reading unit 30, the detecting unit 32, the combining unit 34, the loading unit 36, and the like may be stored in the memory as program units, and the processor may execute the program units stored in the memory to implement the corresponding functions.
The processor includes a kernel, and the kernel fetches a corresponding program unit from the memory. The kernel may set one or more kernel parameters for merging all the update data if there is update data in the object data, and then for loading the merged update data into the current value of the data.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), which includes at least one memory chip.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the data update method described above via execution of the executable instructions.
According to another aspect of the embodiments of the present invention, there is also provided a computer readable storage medium, including a stored computer program, where the computer program when executed controls a device in which the computer readable storage medium is located to perform the above-described data updating method.
According to another aspect of the embodiment of the present invention, there is also provided a processor, configured to execute a program, where the program executes the data updating method described above.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: and reading the object data, detecting whether the object data has the updated data, merging all the updated data if the object data has the updated data, and finally loading the merged updated data into the current value of the data.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
In the foregoing embodiments of the present invention, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed technology content may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, for example, may be a logic function division, and may be implemented in another manner, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
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 units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (8)

1. A data updating method, applied to a scenario of data updating using an optimistic lock under concurrent transactions, the data updating method comprising:
reading object data, wherein the object data is operated and processed by a plurality of transaction objects;
detecting whether update data exists in the object data, wherein the update data is changed data based on a current data version, and the current data version corresponds to a current data value;
if the update data exists in the object data, merging all the update data, including: if the object data has update data, calculating a difference value between the update data and original data stored in a current value of the data; if the difference value is within the preset difference value range, combining all the updated data;
and loading the merged updated data into the current value of the data.
2. The method of claim 1, wherein the step of detecting whether update data exists in the object data comprises:
based on the current data value, detecting whether another transaction object changes the current data value in the current data version, and determining whether updated data exists in the object data.
3. The method according to claim 2, wherein after detecting whether update data exists in the object data, the data update method further comprises:
detecting that no update data exists in the object data, and recording all the read object data;
all object data is stored in the transaction database.
4. The method of claim 1, wherein if update data exists in the object data, the step of merging all update data further comprises:
if updated data exists in the object data, judging whether the current data version is consistent with the historical record version or not;
if the current data version is inconsistent with the history version, merging all updated data in the current data version;
and loading all the merged updated data to the current value of the data.
5. The method of claim 1, wherein after determining whether the current data version and the history version are consistent, the data updating method further comprises:
and if the current data version is consistent with the historical record version, recording the current data version.
6. A data updating apparatus for use in a scenario where concurrent transactions use an optimistic lock to update data, the data updating apparatus comprising:
a reading unit configured to read object data, where the object data is subjected to operation processing by a plurality of transaction objects;
the detection unit is used for detecting whether update data exist in the object data, wherein the update data are changed data on the basis of a current data version, and the current data version corresponds to a current data value;
a merging unit, configured to merge all update data if the update data exists in the object data, where the merging unit includes: the first calculation module is used for calculating the difference value between the updated data and the original data stored in the current value of the data if the updated data exists in the object data; the first merging module is used for merging all the updated data if the difference value is within a preset difference value range;
and the loading unit is used for loading the combined updated data into the current value of the data.
7. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the data updating method of any of claims 1 to 5 via execution of the executable instructions.
8. A computer readable storage medium, characterized in that the computer readable storage medium comprises a stored computer program, wherein the computer program, when run, controls a device in which the computer readable storage medium is located to perform the data updating method according to any of claims 1 to 5.
CN202110189554.0A 2021-02-19 2021-02-19 Data updating method and device, electronic equipment and computer readable storage medium Active CN112905614B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110189554.0A CN112905614B (en) 2021-02-19 2021-02-19 Data updating method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110189554.0A CN112905614B (en) 2021-02-19 2021-02-19 Data updating method and device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112905614A CN112905614A (en) 2021-06-04
CN112905614B true CN112905614B (en) 2024-04-12

Family

ID=76123808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110189554.0A Active CN112905614B (en) 2021-02-19 2021-02-19 Data updating method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112905614B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020127806A1 (en) * 2018-12-20 2020-06-25 Amadeus S.A.S. Updating multiple data records in a database
CN111444199A (en) * 2019-01-17 2020-07-24 阿里巴巴集团控股有限公司 Data processing method and device, storage medium and processor
CN111694853A (en) * 2020-06-02 2020-09-22 北京北大软件工程股份有限公司 Lineage-based data increment acquisition method and device, storage medium and electronic equipment
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020127806A1 (en) * 2018-12-20 2020-06-25 Amadeus S.A.S. Updating multiple data records in a database
CN111444199A (en) * 2019-01-17 2020-07-24 阿里巴巴集团控股有限公司 Data processing method and device, storage medium and processor
CN111694853A (en) * 2020-06-02 2020-09-22 北京北大软件工程股份有限公司 Lineage-based data increment acquisition method and device, storage medium and electronic equipment
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium

Also Published As

Publication number Publication date
CN112905614A (en) 2021-06-04

Similar Documents

Publication Publication Date Title
KR101343212B1 (en) Online storage volume shrink
EP1669904B1 (en) Verifying dynamically generated operations on a data store
CN111104388B (en) Method, apparatus and computer readable medium for accessing files
US20080319997A1 (en) Combined pessimistic and optimistic concurrency control
CN112084161B (en) Database-based data processing method and device and readable storage medium
US10459804B2 (en) Database rollback using WAL
US6816984B1 (en) Method and system for verifying and storing documents during a program failure
CN108874912A (en) A kind of cancellation method and server
US20210157682A1 (en) System and method for database recovery for encrypted indexes
US20020116403A1 (en) Intelligent, optimistic concurrency database access scheme
CN117178265A (en) Snapshot-based data corruption detection
US20160275134A1 (en) Nosql database data validation
US7849110B2 (en) Database garbage collector
CN112905614B (en) Data updating method and device, electronic equipment and computer readable storage medium
CN113312259A (en) Interface testing method and device
US20130268503A1 (en) Database navigation of changes at commit time
US10146644B2 (en) Integrity of transactional memory of card computing devices in case of card tear events
CN106776052B (en) Shared resource access method and device
CN112035503B (en) Transaction data updating method and device
US7516144B2 (en) Method and system for re-population of data in a database
CN111881149A (en) Large-scale concurrency solution method and system based on Java
CN118210658B (en) Data backup method and system based on artificial intelligence
CN113836548B (en) Data consistency guarantee method, system and equipment of intelligent contract and storage medium
US20220253546A1 (en) System and method for representing and verifying a data set using a tree-based data structure
CN115248819A (en) Rich query protection 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
GR01 Patent grant
GR01 Patent grant