Data processing methods, equipment, storage media and software products

CN118069665BActive Publication Date: 2026-08-14BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-22
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0004]若采用悲观锁的形式,其最大的缺点在于性能方面的影响,对于高并发场景下的海量数据库,会产生大量锁竞争和锁等待,严重劣化数据库的性能;若采用乐观锁,则依赖条件的严格设置,保证当前条件仅有一条请求成功,通常会采用时间戳作为条件进行判断,而在高并发场景的海量数据库中秒级精度的时间戳难以胜任,无法保证数据的一致性

Benefits of technology

[0019]The data processing method, device, storage medium, and program product provided in this disclosure respond to a user's data modification request by searching for the target data to be modified in the data fields of a database. The database includes data fields and a timestamp field. First data stored in the timestamp field corresponding to the target data is obtained and used as the current version number of the target data. Second data is determined based on the first data to serve as the new version number after the target data is updated, and an optimistic locking mechanism is used to update the target data. After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data. This disclosure allows the use of the timestamp field as a version number to implement an optimistic locking mechanism for updating data in massive databases without sacrificing the performance of the massive database. It also provides complete concurrency control for data updates and better stability, ensuring the consistency and stability of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069665B_ABST
    Figure CN118069665B_ABST
Patent Text Reader

Abstract

This disclosure provides a data processing method, device, storage medium, and program product. In response to a user's data modification request, it searches for the target data to be modified in a database, which includes data fields and a timestamp field. It obtains first data stored in the timestamp field corresponding to the target data and uses this first data as the current version number of the target data. Based on the first data, it determines second data as the new version number of the updated target data and uses an optimistic locking mechanism to update the target data. After the target data update is successful, it stores the second data in the timestamp field corresponding to the updated target data. For massive databases, the timestamp field can be used as the version number to implement an optimistic locking mechanism for data updates without sacrificing the performance of the massive database. It also enables complete concurrency control for data updates and provides better stability, ensuring the consistency and stability of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer and network communication technology, and in particular to a data processing method, apparatus, storage medium, and program product. Background Technology

[0002] As a data storage component, databases have extremely strict requirements for data correctness and consistency, ensuring that each write operation is atomic, independent, and unaffected by others. Under the pressure of high concurrency and high traffic scenarios, the concurrent processing of massive databases becomes particularly critical.

[0003] Currently, there are two main strategies for concurrent processing in the database field: one is pessimistic locking, which locks a row directly at the database level to ensure that only one request can modify the data in that row at any given time; the other is optimistic locking, which determines whether the data in that row meets the requirements based on conditions and only modifies it if the requirements are met.

[0004] If pessimistic locking is used, its biggest drawback is its performance impact. For massive databases in high-concurrency scenarios, it will generate a lot of lock contention and lock waiting, which will seriously degrade the performance of the database. If optimistic locking is used, it relies on strict setting of conditions to ensure that only one request succeeds under the current condition. Usually, timestamps are used as conditions for judgment. However, in massive databases in high-concurrency scenarios, second-level precision timestamps are not enough to guarantee data consistency. Summary of the Invention

[0005] This disclosure provides a data processing method, device, storage medium, and program product to ensure that massive databases can use optimistic locking for data updates in high-concurrency scenarios, thereby ensuring data consistency.

[0006] In a first aspect, embodiments of this disclosure provide a data processing method, including:

[0007] In response to a user's data modification request, the system retrieves the target data to be modified from the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields.

[0008] Obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data;

[0009] The second data is determined based on the first data, and used as the new version number after the target data is updated. The target data is then updated using an optimistic locking mechanism.

[0010] After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data.

[0011] In a second aspect, embodiments of this disclosure provide a data processing apparatus, including:

[0012] The query unit is used to respond to a user's data modification request, and to search for the target data to be modified from the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields; to obtain the first data stored in the timestamp field corresponding to the target data, and to use the first data as the current version number of the target data;

[0013] The update unit is used to determine the second data based on the first data, so as to serve as the new version number of the target data after the update, and to update the target data using an optimistic locking mechanism; after the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data.

[0014] Thirdly, embodiments of this disclosure provide an electronic device, including: at least one processor and a memory;

[0015] The memory stores computer-executed instructions;

[0016] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data processing method as described in the first aspect and various possible designs of the first aspect.

[0017] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the data processing method described in the first aspect and various possible designs of the first aspect.

[0018] Fifthly, embodiments of this disclosure provide a computer program product including computer execution instructions, which, when executed by a processor, implement the data processing method described in the first aspect and various possible designs of the first aspect.

[0019] The data processing method, device, storage medium, and program product provided in this disclosure respond to a user's data modification request by searching for the target data to be modified in the data fields of a database. The database includes data fields and a timestamp field. First data stored in the timestamp field corresponding to the target data is obtained and used as the current version number of the target data. Second data is determined based on the first data to serve as the new version number after the target data is updated, and an optimistic locking mechanism is used to update the target data. After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data. This disclosure allows the use of the timestamp field as a version number to implement an optimistic locking mechanism for updating data in massive databases without sacrificing the performance of the massive database. It also provides complete concurrency control for data updates and better stability, ensuring the consistency and stability of the database. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is an example diagram of a data processing technique in the prior art;

[0022] Figure 2 This is a schematic flowchart of a data processing method provided in an embodiment of the present disclosure;

[0023] Figure 3 This is a schematic flowchart of a data processing method provided in another embodiment of the present disclosure;

[0024] Figure 4 This is a structural block diagram of a data processing device provided in an embodiment of the present disclosure;

[0025] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0027] Currently, there are two main strategies for concurrent processing in the database field: one is pessimistic locking, which locks a row directly at the database level to ensure that only one request can modify the data in that row at any given time; the other is optimistic locking, which determines whether the data in that row meets the requirements based on conditions and only modifies it if the requirements are met.

[0028] If pessimistic locking is used, its biggest drawback lies in its performance impact. For massive databases in high-concurrency scenarios, it generates a large amount of lock contention and lock waiting, severely degrading database performance. Optimistic locking, on the other hand, relies on strict condition settings to ensure that only one request succeeds under the current condition. This typically uses timestamps as the condition for judgment; for example, massive databases might use the timestamp of the last update as the condition. However, timestamps are usually on the order of seconds. If a massive database has multiple modification requests for the same row of data within one second, a write-overwrite problem occurs, meaning that data written previously is overwritten by data written later, resulting in the loss of some updated data. Figure 1 As shown, after successfully requesting the distributed lock, Update 1 reads data V1 from the database and updates it to data V2. However, within the same second, Update 2, using a timestamp-based optimistic lock, also updates data V1. Since the timestamp is second-level precise, the optimistic lock condition is still met, and Update 2 updates data V1 to data V3. Although Update 1 updated data V1 to data V2, data V2 is overwritten by Update 2's data V3, resulting in data V2 being lost. Therefore, in high-concurrency scenarios with massive databases, second-level precision timestamps are insufficient and cannot guarantee data consistency. Moreover, in distributed scenarios, if there is a strong dependency on the distributed lock—that is, data cannot be modified without acquiring the distributed lock—it introduces a potential single point of failure. Over-reliance on the stability of the distributed lock, coupled with the instability of second-level precision optimistic locks, leads to unstable data updates in distributed scenarios.

[0029] To address the aforementioned technical issues, this disclosure provides a data processing method. In response to a user's data modification request, the method retrieves the target data to be modified from the data fields of a database. The database includes data fields and a timestamp field. The method obtains the first data stored in the timestamp field corresponding to the target data and uses this first data as the current version number of the target data. Based on the first data, a second data is determined as the new version number of the updated target data, and an optimistic locking mechanism is used to update the target data. After the target data update is successful, the second data is stored in the timestamp field corresponding to the updated target data. For massive databases, the timestamp field can be used as the version number to implement an optimistic locking mechanism for data updates without sacrificing the performance of the massive database. This provides comprehensive concurrency control for data updates, better stability, and ensures database consistency and stability. In distributed scenarios, it avoids strong dependence on distributed locks, efficiently controlling concurrency while preventing single points of failure.

[0030] The data processing method disclosed herein can be applied to scenarios involving database modifications, especially to massive databases in high-concurrency scenarios. The database can be a centralized database or a distributed database, and different users can modify the same row of data in the database.

[0031] The data processing method of this disclosure will be described in detail below with reference to specific embodiments.

[0032] refer to Figure 2 , Figure 2 This is a schematic flowchart of a data processing method provided in an embodiment of the present disclosure. The method of this embodiment can be applied to a terminal device or a server, and the data processing method includes:

[0033] S201. In response to a user's data modification request, the target data to be modified is retrieved from the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields.

[0034] In this embodiment, in a distributed scenario, any user who needs to modify target data in the database can send a data modification request. This request may carry relevant information about the target data to be modified, as well as some or all of the modified data. Furthermore, the target data to be modified can be queried from the database based on the data modification request. In this embodiment, the database includes at least two columns: one data field and one timestamp field. Therefore, when querying the target data to be modified from the database based on the data modification request, the target data can be found in the database's data field.

[0035] Optionally, the target data to be modified can be found through the primary key in the MySQL database. Taking ID as an example, the data modification request carries the ID of the target data to be modified, and the data that matches the ID condition can be found through the WHERE lookup condition as the target data.

[0036] S202. Obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data.

[0037] In this embodiment, the database includes at least two columns: a data field and a timestamp field. The timestamp field typically stores the timestamp information when the corresponding data field is written or updated. Since optimistic locking usually requires a versioning mechanism, this is generally achieved by adding a version number field to the database. However, adding a version number field to a massive database is very costly. Therefore, this embodiment considers using the database's timestamp field as the data version number. This changes the semantics of the database's timestamp field; the content stored in the timestamp field is no longer used as "ModifyTime" but as a "version number." It should be noted that the data stored in the timestamp field still needs to conform to the timestamp format. Optionally, although the timestamp field serves as the data version number, it does not need to start from 0 or 1. The initial version number can be the timestamp already stored in the timestamp field, and then monotonically incremented from there.

[0038] Furthermore, after querying the target data from the data field in S201, the first data stored in the timestamp field corresponding to the target data is obtained. At this time, the first data no longer represents the last update time of the target data, but is used as the current version number of the target data.

[0039] S203. Determine the second data based on the first data to serve as the new version number of the updated target data, and update the target data using an optimistic locking mechanism.

[0040] In this embodiment, since the first data serves as the current version number of the target data, and the optimistic locking mechanism requires the version number to monotonically increase, the version number for this data modification is determined based on the first data. That is, the second data is determined based on the first data, for example, by adding 1 to the first data to obtain the new version number of the updated target data. The optimistic locking mechanism is then further used to update the target data, and the process can be as follows: Figure 3 As shown, it specifically includes:

[0041] S301. When performing a data update operation on the target data, determine whether the timestamp field still stores the first data.

[0042] In this embodiment, after the target data has been read and its version number has been determined to be the first data V1.ModifyTime in S201 and S202, when performing a data update operation based on the target data with the version number of the first data V1.ModifyTime, that is, when writing a new version of the target data to the database, it is determined whether the version number of the target data has changed, that is, whether the timestamp field corresponding to the target data still stores the first data V1.ModifyTime.

[0043] S302. If the timestamp field still stores the first data, then update the target data according to the data modification request.

[0044] In this embodiment, if it is determined that the timestamp field corresponding to the target data still stores the first data V1.ModifyTime, it means that the target data has not been updated during the period after the target data has been read and before the new version of the target data is written to the database, that is, no other user has modified the target data. At this time, the optimistic lock is successfully acquired, and the new version of the target data is continued to be written to the database to realize the update of the target data according to the data modification request.

[0045] S303. If the timestamp field does not store the first data, the update is determined to have failed, and the data modification request is retried.

[0046] In this embodiment, if it is determined that the timestamp field corresponding to the target data does not store the first data V1.ModifyTime, and assuming that the third data V2.ModifyTime is stored at this time, it means that the target data has been updated during the period between reading the target data and writing the new version of the target data to the database. That is, other users have modified the target data. At this time, the optimistic lock acquisition fails, it is determined that the update of the target data has failed, and the data modification request is responded to again for retry. That is, the third data stored in the timestamp field corresponding to the target data is queried again as the current version number of the target data. The fourth data is determined based on the third data as the new version number of the target data after the update, and the optimistic locking mechanism is used to update the target data.

[0047] S204. After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data.

[0048] In this embodiment, after successfully updating the target data based on the optimistic locking mechanism, the second data is stored in the timestamp field corresponding to the updated target data, serving as the version number of the updated target data and the basis for subsequent modifications and updates. In this embodiment, data updates based on optimistic locking are more stable, avoiding strong dependence on distributed locks in distributed scenarios, efficiently controlling concurrency while avoiding single points of failure.

[0049] The data processing method provided in this embodiment responds to a user's data modification request by searching for the target data to be modified in the data fields of the database. The database includes data fields and a timestamp field. First data stored in the timestamp field corresponding to the target data is obtained and used as the current version number of the target data. Second data is determined based on the first data to serve as the new version number after the target data is updated, and an optimistic locking mechanism is used to update the target data. After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data. This embodiment can use the timestamp field as the version number to implement an optimistic locking mechanism for updating data in massive databases without sacrificing the performance of the massive database. It also provides complete concurrency control for data updates and better stability, ensuring the consistency and stability of the database.

[0050] In one alternative embodiment, when determining the second data based on the first data, since the first data is the current version number of the target data, and the version number is usually incremented by 1 each time, the first data can be incremented by 1 to obtain the second data, which is used as the new version number of the target data after the update.

[0051] In another optional embodiment, since the first data is stored in a timestamp field, although the semantics have changed from update time to version number, it can still reflect the update time to a certain extent. Especially in the scenario of second-level optimistic locking (using second-level timestamps as an optimistic locking method, that is, more than one write operation occurs within the same second), the result of adding 1 to the first data and the maximum value of the timestamp corresponding to the current time can be taken as the second data. That is, second data = max(first data + 1, time.Now()). Here, taking the result of adding 1 to the first data and the maximum value of the timestamp corresponding to the current time is to make the second data as close as possible to the current time. The second data is taken as the timestamp of the target data update, thus getting closer to the timestamp of the target data update. For example, suppose the first data is close to the timestamp of the last update of the target data, but the current update of the target data is a long time ago (e.g., much more than 1 second). If the second data is simply the first data plus 1, then the second data is too far from the timestamp of the current update and cannot be close to the current update. However, if the second data is the maximum value of the result of the first data plus 1 and the timestamp corresponding to the current time, then the second data is equal to the timestamp of the current update. This allows the second data to reflect the update time of the target data to a certain extent, while also satisfying the requirement of monotonically increasing version numbers, which meets the requirements of the optimistic locking mechanism.

[0052] When updating the target data using an optimistic locking mechanism, assuming the target data has been read and its version number determined to be the first data V1.ModifyTime in S201 and S202, an optimistic lock of ModifyTime is used when updating the target data, and V2.ModifyTime = max(V1.ModifyTime + 1, Now().Sec()) is determined. When performing the data update operation on the target data, it is determined whether the timestamp field corresponding to the target data still stores the first data V1.ModifyTime. If so, the optimistic lock is successfully acquired, and the new version of the target data is written to the database, realizing the update of the target data according to the data modification request, and writing V2.ModifyTime into the timestamp field. Assuming that another user also requests to modify the target data at the same time, an optimistic lock of ModifyTime is used when updating the target data, and V3.ModifyTime = max(V1.ModifyTime + 1, Now().Sec()) is determined. When performing a data update operation on the target data, it is determined whether the timestamp field corresponding to the target data still stores the first data V1.ModifyTime. If it is found that the timestamp field has changed to V2.ModifyTime, it means that other users have modified the target data. At this time, the optimistic lock acquisition fails, and the update of the target data is determined to have failed. The target data is read and queried, and the V2.ModifyTime stored in the corresponding timestamp field is obtained as the current version number of the target data. V3.ModifyTime = max(V2.ModifyTime + 1, Now().Sec()) is determined as the new version number of the target data after the update. When performing a data update operation on the target data, it is determined whether the timestamp field corresponding to the target data still stores the first data V2.ModifyTime. If so, the optimistic lock acquisition is successful, and the new version of the target data is written to the database. This realizes the update of the target data according to the data modification request and writes V3.ModifyTime into the timestamp field.

[0053] Building upon the above embodiments, since the second data is stored in the timestamp field corresponding to the updated target data after the target data is successfully updated, and the second data no longer has the semantic meaning of update time, it can store the actual timestamp of the target data update moment separately. However, for massive databases, it is inconvenient to add another data column. Therefore, the database's data field can be used. That is, after obtaining the timestamp of the target data update moment, the timestamp of the target data update moment is stored in the data field where the target data is located. For example, the data field structure is in JSON format. The timestamp of the target data update moment can be stored in the data field through serialization. Furthermore, the specific time granularity can be selected according to the traffic volume and concurrency, such as millimeter level or micrometer level, not limited to second level, so as to more accurately reflect the update time of the target data.

[0054] Furthermore, since the timestamp of the target data update time is stored in the data field where the target data is located, when it is necessary to determine the actual update time of the target data, it is no longer read from the timestamp field, but rather from the data field.

[0055] For example, when sending a response message to a user that the target data has been successfully updated, the timestamp of the target data update time can be obtained from the data field, and the timestamp of the target data update time can be carried in the response message that the target data has been successfully updated and sent to the user. This restores the semantics of the update time, ensures semantic compatibility, and also ensures that the changes are transparent to the upper layer.

[0056] Based on the above embodiments, the second data is taken as the result of the first data plus 1 and the maximum value of the timestamp corresponding to the current time, so that the second data can also reflect the update time of the target data to a certain extent. That is, the timestamp field can reflect the update time of the target data to a certain extent. Based on this, the update time of the corresponding data field can be roughly determined according to the timestamp field.

[0057] In one application scenario, when a user needs to query data updated at a specific time, they can send a data query request, which includes the update time of the data to be queried. Further, based on the update time, the database's timestamp field is queried, and one or more timestamps closest to the update time are found (timestamps near the update time indicate that the actual update time may also be close to the update time). The data in the corresponding data field of this one or more timestamps is used as candidate data for the data to be queried. The data to be queried is then queried from the candidate data, thereby narrowing the query range and improving query speed. Specifically, the timestamp of the actual update time can be read from the data field of the candidate data and matched with the update time of the data to be queried to determine the data to be queried.

[0058] Corresponding to the data processing method in the above embodiments, Figure 4 This is a structural block diagram of a data processing apparatus provided in an embodiment of the present disclosure. For ease of explanation, only the parts relevant to the embodiments of the present disclosure are shown. (Refer to...) Figure 4 The data processing device 400 includes a query unit 401 and an update unit 402.

[0059] The query unit 401 is configured to respond to a user's data modification request by searching for the target data to be modified in the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields; obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data;

[0060] Update unit 402 is configured to determine second data based on the first data, to serve as the new version number of the updated target data, and to update the target data using an optimistic locking mechanism; after the target data update is successful, the second data is stored in the timestamp field corresponding to the updated target data.

[0061] In one or more embodiments of this disclosure, when the updating unit 402 determines the second data based on the first data, it is configured to:

[0062] Add 1 to the first data to get the second data; or

[0063] The result of adding 1 to the first data and the maximum value in the timestamp corresponding to the current time are used to determine the second data.

[0064] In one or more embodiments of this disclosure, when updating the target data using an optimistic locking mechanism, the updating unit 402 is used to:

[0065] When performing a data update operation on the target data, it is determined whether the timestamp field still stores the first data;

[0066] If the timestamp field still stores the first data, then update the target data according to the data modification request.

[0067] In one or more embodiments of this disclosure, when updating the target data using an optimistic locking mechanism, the updating unit 402 is further configured to:

[0068] If the timestamp field does not store the first data, the update is determined to have failed, and the data modification request is retried.

[0069] In one or more embodiments of this disclosure, after the target data is successfully updated, the updating unit 402 is further configured to:

[0070] Obtain the timestamp of the target data update time and store the timestamp of the target data update time in the data field where the target data is located.

[0071] In one or more embodiments of this disclosure, the updating unit 402 is further configured to:

[0072] Obtain the timestamp of the target data update time from the data field;

[0073] A response message indicating that the target data update was successful is sent to the user, and the response message carries a timestamp of the target data update time.

[0074] In one or more embodiments of this disclosure, the query unit 401 is further configured to:

[0075] Receive a user’s data query request, wherein the data query request includes the update time of the data to be queried;

[0076] The data in the data field corresponding to one or more timestamp fields in the database that are closest to the update time are used as candidate data for the data to be queried.

[0077] The data to be queried is retrieved from the candidate data.

[0078] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.

[0079] refer to Figure 5The diagram illustrates a structural schematic of an electronic device 500 suitable for implementing embodiments of the present disclosure. The electronic device 500 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0080] like Figure 5 As shown, the electronic device 500 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0081] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 An electronic device 500 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0082] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.

[0083] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0084] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0085] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.

[0086] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0088] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".

[0089] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0090] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0091] In a first aspect, according to one or more embodiments of the present disclosure, a data processing method is provided, comprising:

[0092] In response to a user's data modification request, the system retrieves the target data to be modified from the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields.

[0093] Obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data;

[0094] The second data is determined based on the first data, and used as the new version number after the target data is updated. The target data is then updated using an optimistic locking mechanism.

[0095] After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data.

[0096] According to one or more embodiments of this disclosure, determining the second data based on the first data includes:

[0097] Add 1 to the first data to get the second data; or

[0098] The result of adding 1 to the first data and the maximum value in the timestamp corresponding to the current time are used to determine the second data.

[0099] According to one or more embodiments of this disclosure, updating the target data using an optimistic locking mechanism includes:

[0100] When performing a data update operation on the target data, it is determined whether the timestamp field still stores the first data;

[0101] If the timestamp field still stores the first data, then update the target data according to the data modification request.

[0102] According to one or more embodiments of this disclosure, updating the target data using an optimistic locking mechanism further includes:

[0103] If the timestamp field does not store the first data, the update is determined to have failed, and the data modification request is retried.

[0104] According to one or more embodiments of this disclosure, after the target data is successfully updated, the method further includes:

[0105] Obtain the timestamp of the target data update time and store the timestamp of the target data update time in the data field where the target data is located.

[0106] According to one or more embodiments of this disclosure, the method further includes:

[0107] Obtain the timestamp of the target data update time from the data field;

[0108] A response message indicating that the target data update was successful is sent to the user, and the response message carries a timestamp of the target data update time.

[0109] According to one or more embodiments of this disclosure, the method further includes:

[0110] Receive a user’s data query request, wherein the data query request includes the update time of the data to be queried;

[0111] The data in the data field corresponding to one or more timestamp fields in the database that are closest to the update time are used as candidate data for the data to be queried.

[0112] The data to be queried is retrieved from the candidate data.

[0113] Secondly, according to one or more embodiments of this disclosure, a data processing apparatus is provided, comprising:

[0114] The query unit is used to respond to a user's data modification request, and to search for the target data to be modified from the data fields of the database according to the data modification request; wherein the database includes data fields and timestamp fields; to obtain the first data stored in the timestamp field corresponding to the target data, and to use the first data as the current version number of the target data;

[0115] The update unit is used to determine the second data based on the first data, which serves as the new version number of the updated target data, and to update the target data using an optimistic locking mechanism; after the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data.

[0116] According to one or more embodiments of this disclosure, when the updating unit determines the second data based on the first data, it is configured to:

[0117] Add 1 to the first data to get the second data; or

[0118] The result of adding 1 to the first data and the maximum value in the timestamp corresponding to the current time are used to determine the second data.

[0119] According to one or more embodiments of this disclosure, when the update unit updates the target data using an optimistic locking mechanism, it is used to:

[0120] When performing a data update operation on the target data, it is determined whether the timestamp field still stores the first data;

[0121] If the timestamp field still stores the first data, then update the target data according to the data modification request.

[0122] According to one or more embodiments of this disclosure, when the updating unit updates the target data using an optimistic locking mechanism, it is further configured to:

[0123] If the timestamp field does not store the first data, the update is determined to have failed, and the data modification request is retried.

[0124] According to one or more embodiments of this disclosure, after the target data is successfully updated, the updating unit is further configured to:

[0125] Obtain the timestamp of the target data update time and store the timestamp of the target data update time in the data field where the target data is located.

[0126] According to one or more embodiments of this disclosure, the updating unit is further configured to:

[0127] Obtain the timestamp of the target data update time from the data field;

[0128] A response message indicating that the target data update was successful is sent to the user, and the response message carries a timestamp of the target data update time.

[0129] According to one or more embodiments of this disclosure, the query unit is further configured to:

[0130] Receive a user’s data query request, wherein the data query request includes the update time of the data to be queried;

[0131] The data in the data field corresponding to one or more timestamp fields in the database that are closest to the update time are used as candidate data for the data to be queried.

[0132] The data to be queried is retrieved from the candidate data.

[0133] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;

[0134] The memory stores computer-executed instructions;

[0135] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data processing method as described in the first aspect and various possible designs of the first aspect.

[0136] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, the data processing method described in the first aspect and various possible designs of the first aspect is implemented.

[0137] Fifthly, according to one or more embodiments of the present disclosure, a computer program product is provided, including computer execution instructions that, when executed by a processor, implement the data processing method described in the first aspect and various possible designs of the first aspect.

[0138] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0139] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0140] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A data processing method, characterized in that, include: In response to a user's data modification request, the target data to be modified is retrieved from the data fields of the database according to the data modification request; The database mentioned above includes data fields and timestamp fields; Obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data; The second data is determined based on the first data, and used as the new version number after the target data is updated. The target data is then updated using an optimistic locking mechanism. After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data. Determining the second data based on the first data includes: Add 1 to the first data to obtain the second data; or The result of adding 1 to the first data and the maximum value in the timestamp corresponding to the current time are used to determine the second data.

2. The method according to claim 1, characterized in that, The step of updating the target data using an optimistic locking mechanism includes: When performing a data update operation on the target data, it is determined whether the timestamp field still stores the first data; If the timestamp field still stores the first data, then update the target data according to the data modification request.

3. The method according to claim 2, characterized in that, The method of updating the target data using an optimistic locking mechanism further includes: If the timestamp field does not store the first data, the update is determined to have failed, and the data modification request is retried.

4. The method according to claim 1, characterized in that, After the target data is successfully updated, the method further includes: Obtain the timestamp of the target data update time and store the timestamp of the target data update time in the data field where the target data is located.

5. The method according to claim 4, characterized in that, The method further includes: Obtain the timestamp of the target data update time from the data field; A response message indicating that the target data update was successful is sent to the user, and the response message carries a timestamp of the target data update time.

6. The method according to claim 1, characterized in that, When the second data is determined by taking the maximum value of the first data plus 1 and the timestamp corresponding to the current time, the method further includes: Receive a user’s data query request, wherein the data query request includes the update time of the data to be queried; The data in the data field corresponding to one or more timestamp fields in the database that are closest to the update time are used as candidate data for the data to be queried. The data to be queried is retrieved from the candidate data.

7. A data processing device, characterized in that, include: The query unit is used to respond to a user's data modification request and search for the target data to be modified from the data fields of the database according to the data modification request; The database mentioned above includes data fields and timestamp fields; Obtain the first data stored in the timestamp field corresponding to the target data, and use the first data as the current version number of the target data; An update unit is used to determine second data based on the first data, so as to use the new version number of the target data after the update, and to update the target data using an optimistic locking mechanism; After the target data is successfully updated, the second data is stored in the timestamp field corresponding to the updated target data. When the update unit determines the second data based on the first data, it is used to: Add 1 to the first data to get the second data; or The result of adding 1 to the first data and the maximum value in the timestamp corresponding to the current time are used to determine the second data.

8. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the method as described in any one of claims 1-6.

10. A computer program product, characterized in that, Includes computer execution instructions, which, when executed by a processor, implement the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Distributed transaction processing method and device, medium and database system

    CN114003644A

  • Shared resource updating

    US20150242247A1