A data writing method, device, apparatus and storage medium
By determining the current state of abnormal data when a write failure occurs and employing retry and automatic write schemes, the problem of abnormal inventory quantities in the cache set is solved, achieving efficient and accurate data writing and ensuring business stability.
Patent Information
- Application Number
- CN202110655495.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-11
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-06-11
AI Technical Summary
In existing technologies, there is a lack of effective solutions when anomalies or failures occur during the writing of inventory quantities to the cache collection, which affects business operations.
When a write operation fails, the current data write status of the abnormal data is determined, and based on this status and the abnormal data, an immediate retry scheme and an automatic write scheme are adopted to accurately write the abnormal data to the target storage area.
It enables efficient and accurate automatic writing of abnormal data when write failures occur, improving the accuracy and efficiency of writing and ensuring the normal operation of business.
Smart Images

Figure CN113392098B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology, and in particular to a data writing method, apparatus, device and storage medium. Background Technology
[0002] In systems involving inventory operations, the inventory quantities involved in the business are typically allocated to corresponding cache sets for caching. Related technologies usually focus on how to prevent over-issuance of inventory, but there are few solutions for abnormal phenomena that occur when the inventory quantity is written to the cache set. Summary of the Invention
[0003] To address the aforementioned technical problems, embodiments of this application provide a data writing method, apparatus, device, and storage medium. By determining the target data to be written to the target storage area based on the abnormal data and its current data writing status when rewriting abnormal data to the target storage area fails, the method enables efficient and accurate automatic writing of the failed abnormal data based on an immediate retry scheme and an automatic writing scheme.
[0004] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0005] This application provides a data writing method, the method comprising:
[0006] In response to a received write failure instruction, identify abnormal data in the set of data to be written that matches the write failure instruction;
[0007] Determine the target storage area where writing the abnormal data failed;
[0008] If it fails to rewrite the abnormal data to the target storage area, determine the current data writing status of the abnormal data;
[0009] Based on the current data writing status and the abnormal data, the target data to be written to the target storage area is determined.
[0010] This application provides a data writing device, the device comprising:
[0011] The first determining module is used to determine, in response to a received write failure instruction, abnormal data that matches the write failure instruction in the set of data to be written;
[0012] The second determining module is used to determine the target storage area where writing the abnormal data failed;
[0013] The third determining module is used to determine the current data writing status of the abnormal data when it fails to rewrite the abnormal data into the target storage area.
[0014] The write module is used to determine the target data to be written to the target storage area based on the current data write status and the abnormal data.
[0015] This application provides a data writing device, the device including: a processor, a memory, and a communication bus;
[0016] The communication bus is used to realize the communication connection between the processor and the memory;
[0017] The processor is used to execute the program in the memory to implement the data writing method described above.
[0018] Correspondingly, embodiments of this application also provide a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the above-described data writing method.
[0019] The data writing method, apparatus, device, and storage medium provided in this application firstly, in response to a received write failure instruction, determine abnormal data matching the write failure instruction in the data set to be written; determine the target storage area where writing the abnormal data failed; secondly, if rewriting the abnormal data to the target storage area fails, determine the current data writing status of the abnormal data; and finally, based on the current data writing status and the abnormal data, determine the target data to be written to the target storage area. Thus, by determining the target data to be written to the target storage area based on the abnormal data and its current data writing status when rewriting the abnormal data to the target storage area fails, efficient and accurate automatic writing of the failed abnormal data can be achieved based on an immediate retry scheme and an automatic writing scheme. Attached Figure Description
[0020] Figure 1 A flowchart illustrating a data writing method provided in an embodiment of this application;
[0021] Figure 2 A flowchart illustrating another data writing method provided in an embodiment of this application;
[0022] Figure 3A A flowchart illustrating yet another data writing method provided in an embodiment of this application;
[0023] Figure 3B A flowchart illustrating yet another data writing method provided in an embodiment of this application;
[0024] Figure 4 This is a flowchart illustrating a data writing method provided in an embodiment of this application.
[0025] Figure 5 A schematic diagram of a unified viewing interface for intelligent automatic inventory replenishment;
[0026] Figure 6 This is a schematic diagram of the structure of a data writing device provided in an embodiment of this application;
[0027] Figure 7 This is a schematic diagram of the structure of a data writing device provided in an embodiment of this application. Detailed Implementation
[0028] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0029] It should be understood that the phrases "embodiments of this application" or "foreign embodiments" throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "embodiments of this application" or "in the foreign embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0030] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit this application.
[0031] In systems involving inventory operations, the inventory quantities required for business operations are typically allocated and written to a corresponding cache region set. This cache region can be a remote dictionary server (Redis); Redis is an open-source, high-performance key-value store database. The system typically leverages Redis's ability to handle high concurrency by atomically deducting the inventory quantity stored in the cache region, thus ensuring that the business-related inventory is not over-issued. Related technologies often focus on preventing over-issuance of business-related inventory as a key research topic. However, there are few effective solutions for situations where exceptions or failures occur during the process of writing inventory quantities to the corresponding cache region set, for two reasons:
[0032] 1. The probability of an anomaly occurring during the process of writing inventory quantities to the cache area set is relatively small, resulting in insufficient attention from those skilled in the art, and consequently, very few corresponding solutions.
[0033] 2. In related technologies, alarm monitoring points are set up when inventory quantities are written to the cache area set to solve the write failure problem. However, in practical applications, the amount of data corresponding to the inventory quantities written to the cache area set is usually on the order of tens of thousands. If a large number of inventory quantity write failures occur, relying solely on monitoring points cannot handle the situation uniformly, thus affecting the normal operation of the business.
[0034] Based on the above problems, this application provides a data writing method applied to a data writing device, as shown in the following embodiments. Figure 1 As shown, the method includes the following steps:
[0035] Step 101: In response to the received write failure command, determine the abnormal data that matches the write failure command in the data set to be written.
[0036] In the embodiments of this application, the data writing device can be any electronic device with data processing capabilities.
[0037] In this embodiment, a write failure instruction can refer to an instruction generated when an exception or failure occurs during the writing of any data from the set of data to be written to the corresponding cache area. Specifically, the write failure instruction can be generated when the written data is abnormal, the corresponding write area is abnormal, both the written data and the corresponding write area are abnormal, or a network exception occurs when writing data to the corresponding write area.
[0038] It should be noted that an anomaly in the written data can refer to the loss or alteration of the written data, while an anomaly in the corresponding write area can refer to the internal storage space of the write area being full.
[0039] The data set to be written can include one, two, or more pieces of data, and the data to be written can be any information such as numbers, letters, or text. Abnormal data can be one or more pieces of data in the data set to be written.
[0040] In this embodiment of the application, in response to a received write failure instruction, the data writing device may determine at least two storage areas for storing the data set to be written before determining the abnormal data that matches the write failure instruction in the data set to be written, thereby obtaining a storage area set; and write each piece of data to be written in the data set to be written into each storage area in the storage area set according to a preset strategy.
[0041] In one feasible implementation, the set of data to be written is obtained by splitting the total inventory quantity involved in the business into a set of inventory quantities; where the total inventory quantity is 1000, the corresponding set of data to be written can be: data to be written 1: 200; data to be written 2: 200; data to be written 3: 100; data to be written 4: 300; data to be written 5: 200.
[0042] Step 102: Determine the target storage area where writing abnormal data failed.
[0043] In this embodiment, the data writing device may parse the write failure command to determine the target storage area where the abnormal data writing failed; or it may use data tracking analysis to determine the corresponding abnormal data and the target storage area.
[0044] The target storage area can be one, two, or more; and the number of target storage areas is the same as the number of abnormal data. The target storage area can be a region for caching abnormal data or a region for offline storage of abnormal data. Furthermore, the storage space within the target storage area and the storage method for the relevant data are not limited in this embodiment.
[0045] It should be noted that when there are two or more target storage areas, the storage attributes of each two target storage areas can be the same or different.
[0046] In one feasible implementation, the data writing device divides a preset data set of 1000 data values into four sets of data to be written: 200, 300, 280, and 220. Simultaneously, it acquires a set of cache regions corresponding to these sets of data to be written. These cache regions include: cache region 1, cache region 2, cache region 3, and cache region 4. The data writing device then sequentially writes the four data values (200, 300, 280, and 220) from the sets of data to be written to cache region 1, cache region 2, cache region 3, and cache region 4. Simultaneously, in response to a received write failure command, the data writing device identifies the exception data (200) matching the write failure command within the sets of data to be written, and determines cache region 2 as the target storage region where writing the exception data 200 failed.
[0047] In this embodiment of the application, the data writing device embeds and analyzes the storage area where each piece of data to be written is written in the data set to be written, so as to obtain the corresponding write success instruction and write failure instruction in a timely manner.
[0048] Step 103: If it fails to rewrite the abnormal data to the target storage area, determine the current data writing status of the abnormal data.
[0049] In this embodiment of the application, the data writing device acquires and determines the current data writing status of the abnormal data during the process of rewriting the abnormal data to the target storage area, or when it discovers that the abnormal data has failed to be written again after being written to the target storage area.
[0050] The current data writing status of abnormal data includes, but is not limited to, "pending write" and "written". The "pending write" status can refer to rewriting the abnormal data or rewriting it after adjustments. Similarly, the "written" status can indicate that the abnormal data has been written to the target storage area or to a different storage area than the target storage area.
[0051] It should be noted that when there are two or more abnormal data, the current data writing status includes two or more data writing statuses. Each data writing status can be a pending writing status or a written status. This application embodiment does not impose any limitations on this.
[0052] Step 104: Based on the current data writing status and abnormal data, determine the target data to be written to the target storage area.
[0053] In this embodiment of the application, the data writing device determines the target data to be written to the target storage area based on the current data writing status and the abnormal data; wherein, the target data may be the same as or different from the abnormal data.
[0054] In one feasible implementation, when the data writing device is in a current data writing state that the data has been written to a storage area different from the target storage area, that is, the abnormal data has been rewritten to the other storage area, the target storage area does not need to write any data, that is, the target data is empty.
[0055] In another feasible implementation, when the current data writing state is pending writing, that is, the abnormal data has not yet been written to any storage area, the data writing device needs to determine the abnormal data based on a preset writing strategy and write the determined abnormal data to the target storage area.
[0056] It should be noted that, in this embodiment, in response to a received write failure instruction, the abnormal data that failed to write and the target storage area corresponding to the abnormal data are determined. First, a retry scheme is executed, that is, the abnormal data is rewritten to the target storage area. If the rewriting still fails, an automatic write scheme is executed, that is, the current data write status of the abnormal data is determined, and the target data to be written to the target storage area is determined based on the current data write status and the abnormal data. In this way, the abnormal data that failed to write can be written efficiently and accurately in a timely manner, thereby improving the overall write efficiency of the data set to be written.
[0057] The data writing method provided in this application firstly, in response to a received write failure command, identifies abnormal data matching the write failure command in the data set to be written; and determines the target storage area where writing the abnormal data failed. Secondly, if rewriting the abnormal data to the target storage area fails, the current data writing status of the abnormal data is determined. Finally, based on the current data writing status and the abnormal data, the target data to be written to the target storage area is determined. Thus, by determining the target data to be written to the target storage area based on the abnormal data and its current data writing status when rewriting the abnormal data to the target storage area fails, efficient and accurate automatic writing of the failed abnormal data can be achieved based on an immediate retry scheme and an automatic writing scheme.
[0058] Based on the foregoing embodiments, this application provides a data writing method applied to a data writing device, with reference to... Figure 1 and Figure 2 The steps shown are explained below:
[0059] In this embodiment of the application, before the data writing device determines the abnormal data matching the write failure instruction in the set of data to be written in response to the received write failure instruction, that is, before the data writing device executes step 101, it may also execute the following steps 201 and 202:
[0060] Step 201: Determine at least two storage areas for storing the data set to be written, thus obtaining a set of storage areas.
[0061] In this embodiment, the data writing device can determine at least two storage areas for storing the data set to be written based on a preset allocation strategy, thus obtaining a storage area set. The number of storage areas within the storage area set can be the same as or different from the number of data sets to be written. In other embodiments of this application, it is generally agreed that the number of data sets to be written is the same as the number of storage areas in the storage area set.
[0062] The attribute information of each storage region, such as storage space and storage method, can be the same or different. In the embodiments of this application, different storage regions are generally deployed on different network terminals.
[0063] Step 202: According to the preset strategy, write each piece of data to be written in the set of data to be written to each storage area in the set of storage areas.
[0064] In this embodiment of the application, the data writing device writes each piece of data to be written from the set of data to be written to each storage area in the set of storage areas according to a preset strategy.
[0065] In one feasible implementation, the data writing device can write the data to be written into the corresponding storage area in sequence according to the attribute information of the data to be written in the data set to be written: name, amount of data to be written, etc.
[0066] In another feasible implementation, the data writing device can write each piece of data to be written in the set of data to be written to each storage area in the set of storage areas in parallel.
[0067] In one feasible implementation, the data writing device sequentially writes data 1, data 2, data 3 and data 4 from the data set to be written to storage area 1, storage area 2, storage area 3 and storage area 4.
[0068] The preset strategy can be determined and generated by the data writing device based on the set of data to be written and / or the set of storage areas.
[0069] It should be noted that, in this embodiment of the application, the data writing device writes each piece of data to be written in the data set to be written to each storage area in the storage area set according to a preset strategy; thus, by distributing the data in the data set to be written, the storage security of the data set to be written can be improved, and the accuracy of data changes to the data set to be written can be improved.
[0070] Accordingly, after the data writing device determines the abnormal data matching the write failure command in the set of data to be written, and determines the target storage area where the write of the abnormal data failed, in response to the received write failure command, that is, after executing steps 101 and 102, it may also execute the following steps 203 and 204:
[0071] Step 203: Generate a rewrite instruction based on the abnormal data and the target storage area.
[0072] In this embodiment, the data writing device generates a rewrite instruction based on the determined abnormal data and the target storage area. The rewrite instruction refers to a retry instruction that rewrites the abnormal data to the target storage area.
[0073] In one feasible implementation, the data writing device obtains business information corresponding to the abnormal data and storage information matching the target storage area based on the determined abnormal data and target storage area; and reassembles the business information, storage information, abnormal data and target storage area to generate a retry message, and pushes the retry message to the retry message queue, thereby generating a rewrite instruction corresponding to the retry message.
[0074] Step 204: In response to the rewrite instruction, rewrite the abnormal data to the target storage area.
[0075] In this embodiment of the application, the data writing device responds to the rewrite instruction by retrieving the retry message corresponding to the rewrite instruction from the retry message queue, and performs operations on the retry message based on the rewrite instruction, that is, rewrites the abnormal data into the target storage area.
[0076] It should be noted that, in this embodiment of the application, the data writing device rewrites the abnormal data into the target storage area; thus, by using a retry scheme, the success rate of writing abnormal data can be improved, thereby efficiently improving the overall writing efficiency of the data set to be written.
[0077] The data writing method provided in this application embodiment, during the distributed storage of a data set to be written, after receiving a write failure instruction, determines the target data to be written to the target storage area based on the abnormal data and its current data writing status, regardless of whether the write failure rewrites the abnormal data to the target storage area or not. In this way, based on a more secure storage method, namely distributed storage of data, by executing an immediate retry scheme and an automatic write scheme for the abnormal data that failed to write, it is possible to efficiently and accurately achieve automatic writing of abnormal data, thereby improving the accuracy and efficiency of writing the data set to be written.
[0078] Based on the foregoing embodiments, this application provides a data writing method applied to a data writing device, with reference to... Figure 1 The steps shown in Figure 3 are explained below:
[0079] When the current data writing status includes both the pending write status and the written status, the data writing device determines the target data to be written to the target storage area based on the current data writing status and abnormal data, including the following two methods:
[0080] Method 1, refer to Figure 1 and Figure 2 ,as well as Figure 3A The steps shown are explained below:
[0081] Step 301: When the current data writing status is pending writing status, obtain the preset writing information and current writing information of the data set to be written.
[0082] In this embodiment of the application, when the current data writing state is a pending writing state, that is, when it is determined that the abnormal data has not been written at the current moment, the preset writing information and current writing information of the data set to be written are obtained.
[0083] The preset write information of the data set to be written represents the preset write information corresponding to each piece of data to be written in the data set to be written. That is, the data writing device needs to match the original strategy of writing storage area information corresponding to each piece of data to be written with the preset strategy in step 202 of the above embodiment. At the same time, the current write information of the data set to be written represents the data writing status of each piece of data to be written at the current time.
[0084] It should be noted that the preset write information and the current write information of the data set to be written can be the same, different, or partially the same. Additionally, the current write information of the data set to be written includes, but is not limited to, the data write status of abnormal data, such as the storage area information where the abnormal data needs to be written.
[0085] In one feasible implementation, the preset write information of the data set to be written can be: data to be written 1 corresponds to cache area 1, data to be written 2 corresponds to cache area 2, data to be written 3 corresponds to cache area 3, etc.; and when the abnormal data is data to be written 3, the current write information of the data set to be written can be: data to be written 1 corresponds to cache area 1, data to be written 2 corresponds to cache area 2, data to be written 3, that is, the abnormal data needs to be written to cache area 3, etc.
[0086] In another feasible implementation, the preset write information of the data set to be written can be: data to be written 1 corresponds to cache area 1, data to be written 2 corresponds to cache area 2, data to be written 3 corresponds to cache area 3, etc.; and when the abnormal data is data to be written 3, the current write information of the data set to be written can be: data to be written 1 corresponds to cache area 1, data to be written 2 corresponds to cache area 2, data to be written 4 needs to be written to cache area 3, etc.; where data to be written 4 is different from data to be written 3, and data to be written 4 is obtained after modifying data to be written 3.
[0087] Step 302: Compare the preset write information and the current write information to obtain the comparison results.
[0088] In this embodiment of the application, the data writing device performs a similarity comparison between the preset writing information and the current writing information to obtain a comparison result; wherein, the comparison result may refer to the comparison result between the preset writing area and the current writing area corresponding to each piece of data to be written in the data set to be written.
[0089] In one feasible implementation, the data writing device performs a similarity comparison between the storage area corresponding to each piece of data to be written in the preset writing information and the storage area corresponding to each piece of data to be written in the current writing information, and obtains the comparison result.
[0090] The comparison results can be expressed as completely identical, partially identical, or completely different, or as a matching degree of 100%, 90%, etc.
[0091] Step 303: Based on the comparison results and outlier data, determine the target data.
[0092] In this embodiment of the application, the data writing device can adjust abnormal data based on the comparison results to obtain the target data to be written to the target storage area.
[0093] It should be noted that, in the embodiments of this application, when the current data writing state is the pending writing state, the data writing device adjusts the abnormal data by comparing the preset writing information of the data set to be written with the current writing information, so as to determine the target data to be written to the target storage area; in this way, the abnormal data can be automatically written based on the historical writing strategy and the current writing strategy of the data set to be written, thereby improving the automatic writing efficiency of abnormal data while ensuring the writing accuracy of the data set to be written.
[0094] In one feasible implementation, the data writing device determines the target data based on the comparison result and the abnormal data. That is, the data writing device executes step 303, which can be based on the different comparison results and execute the following two schemes:
[0095] Option 1:
[0096] Step 303a: If the comparison result indicates that the preset write information and the current write information are the same, determine the abnormal data as the target data.
[0097] In this embodiment, the data writing device determines whether the target data currently being written to the target storage area is the same as the abnormal data if the comparison result indicates that the preset write information and the current write information are identical, that is, if the storage area corresponding to each piece of data to be written in the preset write information is exactly the same as the storage area corresponding to each piece of data to be written in the current write information. In other words, if the write area of the abnormal data and the attribute information corresponding to the abnormal data have not changed, the data writing device determines whether the target data currently being written to the target storage area is the abnormal data.
[0098] It should be noted that, in the embodiments of this application, if the historical writing strategy of the data set to be written has not changed, the data writing device determines that the abnormal data still needs to be rewritten to the target storage area, that is, the abnormal data is the target data; in this way, the automatic writing of abnormal data can be achieved efficiently and accurately, thereby improving the accuracy and efficiency of writing the data set to be written.
[0099] Option 2:
[0100] Step 303b: If the comparison result indicates that the preset write information and the current write information are different, determine the difference parameter between the current write information and the preset write information.
[0101] In this embodiment of the application, when the comparison result indicates that the preset write information and the current write information are different, that is, when the storage area corresponding to each piece of data to be written in the preset write information is different from the storage area corresponding to each piece of data to be written in the current write information, the data writing device obtains the difference parameters between the current write information and the preset write information, that is, the changed data to be written and / or storage area, etc.
[0102] In one feasible implementation, the preset write information for the data set to be written can be: cache region 1 corresponding to data to be written 1, cache region 2 corresponding to data to be written 2, cache region 3 corresponding to data to be written 3, etc.; and when the abnormal data is data to be written 3, the current write information for the data set to be written can be: cache region 1 corresponding to data to be written 1, cache region 2 corresponding to data to be written 2, cache region 3 to be written for data to be written 4, etc.; wherein, data to be written 4 is different from data to be written 3, and data to be written 4 is obtained after modifying data to be written 3. Therefore, the difference parameter is data to be written 3 and data to be written 4.
[0103] In another feasible implementation, the preset write information for the data set to be written can be: data to be written 1 corresponds to cache region 1, data to be written 2 corresponds to cache region 2, data to be written 3 corresponds to cache region 3, etc.; and when the abnormal data is data to be written 3, the current write information for the data set to be written can be: data to be written 1 corresponds to cache region 1, data to be written 2 corresponds to cache region 2, data to be written 3 corresponds to cache region 4, etc. Therefore, the difference parameter is cache region 3 and cache region 4.
[0104] Step 303c: Adjust the abnormal data based on the difference parameters to obtain the adjusted abnormal data.
[0105] In this embodiment, the data writing device adjusts the abnormal data based on the difference parameters to obtain the adjusted abnormal data.
[0106] The difference parameter can refer to the difference information generated when the amount of abnormal data and / or the corresponding target storage area changes, and / or when the amount of data and / or the corresponding storage area of any number of data to be written in the data set other than abnormal data changes.
[0107] Step 303d: Determine the adjusted abnormal data as the target data.
[0108] In this embodiment of the application, the data writing device writes the adjusted abnormal data to the target storage area, that is, the adjusted abnormal data is the target data.
[0109] It should be noted that, based on the above description, there are three possible scenarios: Scenario 1: If the target storage area corresponding to the abnormal data remains unchanged, but the data volume changes, the data volume of the abnormal data is modified to obtain the abnormal data with adjusted data volume, and this is written as the target data to the target storage area. Scenario 2: If the target storage area corresponding to the abnormal data changes, but the data volume remains unchanged, the abnormal data is adjusted to be empty, resulting in abnormal data with an empty data volume, which is then written to the target storage area. Simultaneously, the abnormal data is written to other storage areas corresponding to the abnormal data in the current write information. Scenario 3: If both the target storage area corresponding to the abnormal data changes and the data volume changes, the data that needs to be written to the target storage area in the current write information is determined as the adjusted abnormal data, i.e., the target data is written to the target storage area.
[0110] It should be noted that, in the embodiments of this application, when the historical writing strategy of the data set to be written changes, the data writing device determines the target data to be written to the target storage area based on the changed difference parameters, and then determines the writing information of each data to be written in the data set to be written; in this way, automatic writing of abnormal data can be achieved efficiently and accurately, thereby improving the accuracy and efficiency of writing the data set to be written.
[0111] Method 2, refer to Figure 1 and Figure 2 ,as well as Figure 3B The steps shown are explained below:
[0112] Step 304: If the current data write status is that abnormal data has been written to the identification storage area, determine that the target data is empty.
[0113] The identifier storage area is different from the target storage area.
[0114] In this embodiment of the application, when the current data writing status is that it has been written to an identifier storage area different from the target storage area, that is, when it is determined that the abnormal data has been written at the current moment, the target data to be written to the target storage area is determined to be empty.
[0115] The attribute information corresponding to the target storage area and the identifier storage area can be completely the same, completely different, or partially the same. This application embodiment does not impose any limitations on this.
[0116] The data writing method provided in this application embodiment, during the process of distributing storage of a data set to be written, after receiving a write failure instruction, determines the target data to be written to the target storage area based on whether the failed write error data is rewritten to the target storage area or not, based on the error data and whether the data has already been written. In this way, based on a more secure storage method, namely distributed storage of data, by executing an immediate retry scheme and an automatic write scheme for the failed write error data, it is possible to efficiently and accurately achieve automatic writing of error data, thereby improving the accuracy and efficiency of writing the data set to be written.
[0117] Based on the above embodiments, when the data writing device fails to rewrite the abnormal data to the target storage area, determining the current data writing status, i.e., the data writing device executes step 103, can also be achieved through the following steps A1 to A3:
[0118] Step A1: If it fails to rewrite the abnormal data to the target storage area, push the abnormal data and the target storage area to the message queue to be completed, and obtain the adjusted message queue to be completed.
[0119] In this embodiment of the application, if it fails to rewrite the abnormal data into the target storage area, the abnormal data and the message corresponding to the target storage area are packaged and integrated to obtain the information to be processed, and the information to be processed is pushed to the message queue to be completed to obtain the adjusted message queue to be completed.
[0120] The message queue to be completed can consist of all exception data corresponding to write failure instructions in the data set to be written, and the associated target storage area; or it can consist of all exception data corresponding to write failure instructions in multiple data sets to be written, and the associated target storage area. In this embodiment, the message queue to be completed includes at least one piece of information to be processed.
[0121] It should be noted that the message queue to be completed is the same as the message queue to be written. Each message in the message queue to be completed represents an exception data that failed to be written even after a retry mechanism, along with its corresponding storage area. "Completion" refers to successfully writing the exception data to the corresponding cache area to achieve complete allocation and writing of the data set to be written.
[0122] Step A2: Generate the instruction to be completed based on the adjusted message queue to be completed.
[0123] In this embodiment of the application, the data writing device generates a completion instruction based on the generated adjusted message queue to be completed; wherein, the completion instruction refers to the acquisition instruction generated when the message queue to be completed changes.
[0124] Step A3: In response to the pending completion instruction, determine the current data writing status of the abnormal data.
[0125] In this embodiment of the application, the data writing device responds to the completion instruction and obtains the current data writing status of the abnormal data; wherein, the data attributes and data storage attributes of the abnormal data in the current data writing status may be different from the preset writing information corresponding to the abnormal data in the data set to be written.
[0126] In this embodiment of the application, the data writing device can obtain the current data writing status of abnormal data at the current moment from the current write operation of the data set to be written based on the automatic completion strategy.
[0127] It should be noted that, in this embodiment of the application, by pushing the abnormal data and the corresponding target storage area to the message queue to be completed, and obtaining the current data writing status of the abnormal data based on the update of the message queue to be completed, it is possible to achieve unified management and analysis of the abnormal data and storage area that failed to write. That is, it is possible to perform unified automatic writing operations on all abnormal data and their corresponding storage areas, thereby improving the automatic writing efficiency of abnormal data that failed to write, and improving the accuracy and efficiency of writing the data set to be written.
[0128] Based on this, such as Figure 4 The diagram illustrates a data completion flowchart for a data writing method provided in this application embodiment. This data completion scheme can be applied to scenarios where the inventory quantity corresponding to a business is written to multiple cache areas on demand, corresponding to the scheme provided in this application embodiment for writing the data set to be written to a storage area set. Step 401 involves evenly distributing and writing data with an inventory quantity of 1000 to a cache area cluster with 10 Redis instances. This evenly distributes the inventory quantity of 1000, ensuring that each Redis instance writes 100 inventory items. Step 402 determines whether the overall allocation and writing were successful. If successful, step 403 returns the result, indicating successful allocation to the user. If unsuccessful, step 404 identifies the write failure information, namely the inventory quantity that failed to write and its corresponding cache area. The write failure information, cache area, and related business information, such as the business corresponding to the inventory quantity, are then assembled to generate retry information and pushed into a retry message queue (MQ). The data is then redistributed and written, i.e., step 405. At the same time, it determines whether the rewrite was successful, that is, whether the retry allocation was successful, and executes 406. If yes, it executes 403 and returns the result, prompting the user that the allocation was successful; if no, it executes 407 and pushes the message to the failure MQ, that is, it enters the intelligent auto-completion system to perform intelligent auto-completion operation.
[0129] Simultaneously, upon receiving the message (i.e., when there is a new message in the failed message queue), the intelligent auto-completion system obtains the new information regarding the failed inventory write (execute 408). Then, based on this failed message, it automatically extracts the list of failed rewrites (execute 409) and performs automatic inventory quantity verification (execute 410) to automatically and uniformly verify all failed inventory writes, obtaining the current data write status corresponding to the current failed inventory write (411): can be completed, questionable, or completion prohibited. Based on these three statuses, it performs the corresponding operation (412): complete, query business logic, or cannot operate. Finally, the operation result is displayed on the intelligent auto-completion system's operation interface (413).
[0130] It should be noted that, Figure 4 Errors 401 to 405 refer to the operation of reallocating and rewriting failed inventory quantities, i.e., resuming the write operation. Specifically, the failed inventory quantity and its corresponding cache area are assembled and pushed to the retry MQ pipeline for rewriting. Conversely, errors 406 to 407 refer to the case where the write operation failed again, and the message is pushed to the failure MQ. Specifically, if the write operation fails again, the data writing device or system will consider that the inventory quantity write and rewriting operation should be automatically handled by the rewriting task, and retrying is not allowed. The reason for not frequently retrying is that, under certain network conditions, multiple retries are very likely to cause idempotent operations to fail, resulting in multiple accumulations of inventory, which will cause inventory allocation to exceed the limit, meaning there is a risk of over-issuance.
[0131] Meanwhile, the 410 automatic verification process involves the data writing device, based on the intelligent automatic completion system, collecting the failed retry messages (i.e., tasks) whenever a write failure message is pushed to the failure message queue (MQ). This information is then pushed to the automatic compensation task. Upon receiving the task message, the automatic compensation task intelligently determines the current inventory level requiring compensation and performs the automatic compensation operation. The completion results can be displayed to the user later via a "view results" button. Once completion is complete, the process ends.
[0132] like Figure 5 The diagram illustrates a unified viewing interface for intelligent automatic inventory replenishment. 501 displays a prompt message: "The following are batches with missing inventory; please operate with caution." 502 shows the quantity of inventory that failed to write within multiple sets of data to be written, along with their corresponding storage areas, i.e., the missing clusters. 503 presents the verification result, indicating the current data writing status corresponding to the abnormal data that failed to write as provided in this embodiment. 504 displays the viewing result, showing the specific reason for the current data writing status.
[0133] It should be noted that when the viewing interface displays a "Suggested Completion" message, it indicates that the inventory quantity can be rewritten to its corresponding cache area, meaning it can be completed, and thus automatic completion can be performed. When the viewing interface displays a "Questionable" message, it means that the intelligent automatic completion system is unsure whether this result needs completion. In this case, the system can invoke the user-preset inventory verification logic to perform a consistency check on whether the inventory quantity exceeds or decreases. This consistency check will verify not only the inventory in the cache but also the inventory already in stock, ensuring consistency in the inventory quantity before and after. Once the overall system is error-free, automatic completion will proceed. When the viewing interface displays a "Completion Prohibited" message, it indicates that the inventory quantity has already been completed from other channels, meaning it has been written to other cache areas, etc. Repeating this operation is unnecessary and would cause inventory allocation to exceed limits. In this state, the complete button is grayed out, and the system is not performing automatic completion.
[0134] Based on this, in this embodiment, firstly, a retry operation is performed on the business of inventory quantity allocation failure, i.e., a retry allocation operation is executed. Through this retry, the missing, i.e., the failed inventory quantity, can be replenished in a timely and efficient manner. Secondly, for inventory quantities that still fail to replenish after the retry, they will be considered as replenishment failures and pushed to a unified failure message queue (MQ). The messages in this MQ will be consumed by the user interface, and then an intelligent replenishment operation will be automatically performed based on the current inventory status, and then uniformly displayed to the user. After seeing the list of failed replenishment inventory quantities, the user can click the replenishment button on the interface to view the results of the intelligent replenishment operation. At the same time, this application can also provide an operation result interface, which will provide some suggested operations, such as whether the machine intelligently completes the replenishment or whether the machine intelligently identifies and prohibits replenishment, etc., with prompts, greatly reducing the probability of erroneous intervention caused by human intervention. At the same time, the viewing interface can be configured with voice alarms, etc., to provide notifications to stakeholders during the automatic replenishment process, thereby improving the user experience.
[0135] Based on the foregoing embodiments, this application also provides a data writing device 6, which can be applied to... Figure 1 In the data writing method provided in the embodiment corresponding to Figure 3, refer to Figure 6 As shown, the data writing device 6 includes: a first determining module 61, a second determining module 62, a third determining module 63, and a writing module 64, wherein:
[0136] The first determining module 61 is used to determine, in response to the received write failure command, abnormal data that matches the write failure command in the data set to be written;
[0137] The second determining module 62 is used to determine the target storage area where writing abnormal data failed;
[0138] The third determination module 63 is used to determine the current data writing status of the abnormal data in the event that the abnormal data fails to be rewritten to the target storage area.
[0139] The write module 64 is used to determine the target data to be written to the target storage area based on the current data write status and abnormal data.
[0140] In this embodiment of the application, the data writing device 6 further includes:
[0141] The fourth determining module is used to determine at least two storage areas for storing the data set to be written, thereby obtaining a set of storage areas;
[0142] The write module 64 is also used to write each piece of data to be written in the set of data to be written to each storage area in the set of storage areas according to a preset strategy.
[0143] In this embodiment of the application, the data writing device 6 further includes:
[0144] The generation module is used to generate rewrite instructions based on the abnormal data and the target storage area;
[0145] The write module 64 is also used to rewrite the abnormal data to the target storage area in response to a rewrite command.
[0146] In this embodiment of the application, the third determining module 63 is further configured to push the abnormal data and the target storage area to the message queue to be completed in the event that the abnormal data fails to be rewritten to the target storage area, thereby obtaining an adjusted message queue to be completed; generate a completion instruction based on the adjusted message queue to be completed; and determine the current data writing status in response to the completion instruction.
[0147] In this embodiment of the application, the writing module 64 is further configured to, when the current data writing state is a pending writing state, obtain the preset writing information and the current writing information of the data set to be written; perform a similarity comparison between the preset writing information and the current writing information to obtain a comparison result; and determine the target data based on the comparison result and abnormal data.
[0148] In this embodiment of the application, the writing module 64 is further configured to determine the abnormal data as the target data when the comparison result indicates that the preset writing information and the current writing information are the same.
[0149] In this embodiment of the application, the writing module 64 is further configured to determine the difference parameter between the current writing information and the preset writing information when the comparison result indicates that the preset writing information and the current writing information are different; adjust the abnormal data based on the difference parameter to obtain the adjusted abnormal data; and determine the adjusted abnormal data as the target data.
[0150] In this embodiment of the application, the writing module 64 is further configured to determine that the target data is empty when the current data writing status is that abnormal data has been written to the identification storage area; wherein the identification storage area is different from the target storage area.
[0151] It should be noted that the specific implementation process of the steps performed by each module in this embodiment can be referred to Figure 1 The implementation process of the data writing method provided in the embodiments corresponding to 3 will not be described again here.
[0152] The data writing device provided in this application embodiment, during the distributed storage of a data set to be written, after receiving a write failure instruction, determines the target data to be written to the target storage area based on whether the failed write error data is rewritten to the target storage area or not, according to the error data and whether the data has already been written. In this way, based on a more secure storage method, namely distributed storage of data, the device can improve the automatic writing efficiency of the failed write error data and the accuracy and efficiency of writing the data set to be written by implementing an immediate retry scheme and a unified automatic writing scheme for the failed write error data, thereby achieving a more secure storage method.
[0153] Based on the foregoing embodiments, this application also provides a data writing device 7, which can be applied to... Figure 1 In the data writing method provided in the embodiments corresponding to 3, refer to Figure 7 As shown, the data writing device 7 includes: a processor 71, a memory 72, and a communication bus 73, wherein:
[0154] The communication bus 73 is used to realize the communication connection between the processor 71 and the memory 72.
[0155] Processor 71 is used to execute a program for writing data stored in memory 72, in order to implement the reference... Figure 1 The data writing method provided in the embodiment corresponding to Figure 3.
[0156] The data writing device provided in this application embodiment, during the distributed storage of a data set to be written, after receiving a write failure instruction, determines the target data to be written to the target storage area based on whether the failed write error data is rewritten to the target storage area or not, according to the error data and whether the data has already been written. In this way, based on a more secure storage method, namely distributed storage of data, the device can improve the automatic writing efficiency of the failed write error data and the accuracy and efficiency of writing the data set to be written by implementing an immediate retry scheme and a unified automatic writing scheme for the failed write error data, thereby achieving a more secure storage method.
[0157] Based on the foregoing embodiments, this application also provides a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to achieve the following: Figure 1 The data writing method provided in the embodiments corresponding to 3.
[0158] It should be noted that the aforementioned computer-readable storage media can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various electronic devices that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0159] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0160] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0161] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0162] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0163] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0164] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0165] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A data writing method, characterized in that, The method includes: In response to a received write failure instruction, identify abnormal data in the set of data to be written that matches the write failure instruction; Determine the target storage area where writing the abnormal data failed; If it fails to rewrite the abnormal data to the target storage area, determine the current data writing status of the abnormal data; Based on the current data writing status and the abnormal data, determine the target data to be written to the target storage area; Write the target data into the target storage area; The step of determining the target data to be written to the target storage area based on the current data write status and the abnormal data includes: When the current data writing state is a pending write state, obtain the preset writing information and current writing information of the data set to be written; A similarity comparison is performed between the preset write information and the current write information to obtain a comparison result; Based on the comparison results and the abnormal data, the target data is determined.
2. The method according to claim 1, characterized in that, Before determining the abnormal data matching the write failure instruction in the set of data to be written in response to the received write failure instruction, the method further includes: Determine at least two storage regions for storing the set of data to be written, thus obtaining a set of storage regions; According to a preset strategy, each piece of data to be written in the set of data to be written is written to each storage area in the set of storage areas.
3. The method according to claim 1, characterized in that, Before determining the current data writing status of the abnormal data in the event that rewriting the abnormal data to the target storage area fails, the method further includes: Based on the abnormal data and the target storage area, a rewrite instruction is generated; In response to the rewrite instruction, the abnormal data is rewritten to the target storage area.
4. The method according to claim 1 or 3, characterized in that, In the event that rewriting the abnormal data to the target storage area fails, determining the current data writing status of the abnormal data includes: If it fails to rewrite the abnormal data into the target storage area, the abnormal data and the target storage area are pushed to the message queue to be completed, resulting in an adjusted message queue to be completed. Based on the adjusted message queue to be completed, generate instructions to be completed; In response to the pending completion instruction, the current data writing status is determined.
5. The method according to claim 1, characterized in that, The step of determining the target data based on the comparison results and the abnormal data includes: If the comparison result indicates that the preset write information and the current write information are the same, the abnormal data is determined to be the target data.
6. The method according to claim 1, characterized in that, The step of determining the target data based on the comparison result and the abnormal data further includes: If the comparison result indicates that the preset write information and the current write information are different, a difference parameter between the current write information and the preset write information is determined; The abnormal data is adjusted based on the difference parameters to obtain the adjusted abnormal data; The adjusted abnormal data is identified as the target data.
7. The method according to claim 1, characterized in that, The step of determining the target data to be written to the storage area based on the current data write status and the abnormal data further includes: If the current data writing status indicates that the abnormal data has been written to the identification storage area, then the target data is determined to be empty; The identifier storage area is different from the target storage area.
8. A data writing device, characterized in that, The device includes: The first determining module is used to determine, in response to a received write failure instruction, abnormal data that matches the write failure instruction in the set of data to be written; The second determining module is used to determine the target storage area where writing the abnormal data failed; The third determining module is used to determine the current data writing status of the abnormal data when it fails to rewrite the abnormal data into the target storage area. The writing module is used to determine the target data to be written to the target storage area based on the current data writing status and the abnormal data; and to write the target data to the target storage area. The writing module is configured to, when the current data writing state is a pending writing state, acquire preset writing information and current writing information of the data set to be written; perform a similarity comparison between the preset writing information and the current writing information to obtain a comparison result; and determine the target data based on the comparison result and the abnormal data.
9. A data writing device, characterized in that, The device includes: a processor, a memory, and a communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute a program in the memory to implement the data writing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the data writing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data writing method, data reading method and device
CN106126374A
Data writing exception processing method, device, equipment and storage medium
CN112035292A