Shared data editing method and device, equipment and storage medium
By deploying two key spaces in the in-memory database and setting the page table entries of the child and parent processes to read and write for data that support idempotent operations during data persistence, the data loss and inconsistency caused by abnormal interrupts during data persistence is solved, improving server performance and ensuring data correctness.
Patent Information
- Application Number
- CN202411743990.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-03-11
AI Technical Summary
During the data persistence process, the parent process's modification of shared memory data will trigger system interruption exceptions, resulting in data loss or data inconsistency in the child process, and the abnormal interruption will interrupt the processor's normal execution process and affect performance.
Two key spaces are pre-deployed in the in-memory database, one for storing data that supports idempotent operations and the other for storing data that does not support idempotent operations. By determining whether the data stored in the target key space supports idempotent operations, triggering the fork operation to create a child process, and correcting the page table entry status of the parent and child processes to be readable and writeable, allowing direct modification of memory data to avoid page-missing exception interrupts.
Reduces data loss and inconsistency problems caused by abnormal interrupts, improves server performance, and ensures data accuracy, and does not change the results of editing operations even if it is operated multiple times.
Smart Images

Figure CN119597545A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and more specifically, to a shared data editing method, device, equipment and storage medium. Background Art
[0002] In order to avoid the loss of memory data due to server crashes and affect normal business operations, the data in the memory database needs to be persisted to the disk so that data can be recovered when the server fails. However, during the persistence process, there is inevitably a need to modify the data being persisted, but it usually triggers an abnormal interruption and cannot be modified directly.
[0003] Take Redis persistence as an example. When Redis needs to create a memory snapshot to persist data, a fork operation is triggered. The memory snapshot child process is created from the main thread through the fork operation. The child process persists data based on the shared memory data with the parent process. During the child process persistence process, the parent process and the child process share memory data. If the parent process modifies the shared memory data, a system interrupt exception will be triggered. In the interrupt exception program processing, the parent process and the child process have their own memory so that the parent process can modify the data. The child process is likely to lose data or have inconsistent data during the persistence process. Abnormal interrupts will interrupt the normal processor execution process. Especially under high-frequency abnormal interrupts, the processor needs to switch modes frequently, which may cause performance degradation. Summary of the invention
[0004] In view of the above problems, the present application provides a shared data editing method, device, equipment and storage medium to solve the problem of abnormal interruption when modifying data during data persistence. The specific solution is as follows:
[0005] In a first aspect, the present application provides a shared data editing method, which is applied to a memory database of a server, wherein the memory database is pre-deployed with two key spaces, one of which is used to store data that supports idempotent operations, and the other is used to store data that does not support idempotent operations;
[0006] The shared data editing method comprises:
[0007] In response to a memory snapshot instruction for a target key space, determining whether data stored in the target key space supports idempotent operations;
[0008] In the case where the data stored in the target key space supports idempotent operations, a fork operation is triggered to create a child process identical to the parent process, wherein the page table entries corresponding to the parent process and the child process are both in a readable and writable state, and the page table entries contain a mapping relationship between a virtual address and a physical address of the data in the target key space;
[0009] In response to an edit instruction from the parent process to modify data in the target key space, converting the edit instruction into a corresponding idempotent operation;
[0010] The data stored in the target key space is edited according to the idempotent operation, and the editing result is mapped to the page table entries corresponding to the child process and the parent process respectively.
[0011] In a possible implementation, triggering a fork operation to create a child process identical to a parent process includes:
[0012] Trigger the fork process and block the parent process;
[0013] Create a child process;
[0014] Unblocking the parent process, and controlling the child process to copy the page table entry of the parent process to obtain the page table entry of the child process;
[0015] The read / write status of the page table entries corresponding to the parent process and the child process respectively are modified to be in a readable and writable state.
[0016] In a possible implementation, the process of pre-deploying two key spaces in the memory database includes:
[0017] Identify whether each data in the memory database supports idempotent operations;
[0018] According to the identification result corresponding to each of the data, a first data set and a second data set are obtained, wherein the first data set includes all data supporting idempotent operations, and the second data set includes all data not supporting idempotent operations;
[0019] Deploy two key spaces in the memory database;
[0020] The first data set and the second data set are respectively migrated to the two key spaces to obtain a first key space and a second key space, wherein the first key space is used to store the first data set, and the second key space is used to store the second data set.
[0021] In a possible implementation, the method further includes:
[0022] A distinguishing mark is set for the first key space and the second key space respectively, and the distinguishing mark is a mark indicating whether the data in the key space supports idempotent operations.
[0023] In a possible implementation, determining whether the data stored in the key space supports idempotent operations includes:
[0024] Identify whether the distinguishing mark corresponding to the key space is a mark indicating whether the data in the key space supports idempotent operations.
[0025] In a possible implementation, the method further includes:
[0026] In the case where the data stored in the target key space does not support idempotent operations, a fork operation is triggered to create a child process identical to the parent process, wherein the page table entries corresponding to the parent process and the child process are both in a read-only state;
[0027] In response to an editing instruction of the parent process to modify data in the target key space, triggering an abnormal interruption, and acquiring a memory space independent of the target key space;
[0028] Copying the data stored in the target key space to the memory space;
[0029] Editing the data in the memory space according to the editing instruction to obtain editing result data;
[0030] The page table entry corresponding to the parent process is modified according to the address information of the memory space corresponding to the editing result data.
[0031] A second aspect of the present application provides a shared data editing device, which is applied to a memory database of a server, wherein the memory database is pre-deployed with two key spaces, one of which is used to store data that supports idempotent operations, and the other is used to store data that does not support idempotent operations;
[0032] The shared data editing device comprises:
[0033] A key space determination unit, configured to determine, in response to a memory snapshot instruction for a target key space, whether data stored in the target key space supports idempotent operations;
[0034] a fork trigger unit, configured to trigger a fork operation to create a child process identical to the parent process when the judgment result of the target key space judgment unit is yes, wherein the page table entries corresponding to the parent process and the child process are both in a readable and writable state, and the page table entries contain a mapping relationship between a virtual address and a physical address of data in the target key space;
[0035] an instruction conversion unit, configured to respond to an edit instruction of the parent process to modify data in the target key space and convert the edit instruction into a corresponding idempotent operation;
[0036] A data editing unit is used to edit the data stored in the target key space according to the idempotent operation, and map the editing results to the page table entries corresponding to the child process and the parent process respectively.
[0037] In a possible implementation, the fork trigger unit includes:
[0038] Block the parent process subunit to trigger the fork process and block the parent process;
[0039] The process creation subunit is used to create a subprocess;
[0040] A page table entry copying subunit, used to unblock the parent process and control the child process to copy the page table entry of the parent process to obtain the page table entry of the child process;
[0041] The page table entry state correction unit is used to correct the read-write state of the page table entry corresponding to the parent process and the child process respectively to a readable and writable state.
[0042] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0043] The memory is used to store computer programs;
[0044] The processor is used to execute the computer program so that the electronic device can implement any one of the shared data editing methods.
[0045] A fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any one of the shared data editing methods.
[0046] The shared data editing method provided in the embodiment of the present application pre-deploys two key spaces, and sets the type of data keys used to store for each key space, so that data keys supporting different types of editing operations are stored in different key spaces. For editing data with idempotent operations, in the process of triggering a fork operation for persistence, the page table entries of the child process and the parent process are set to a readable and writable state to provide permissions for the editing operation. When the data is subsequently edited, there is no need to trigger a page fault abnormal interruption, and the memory data can be directly modified, reducing data loss and inconsistency problems caused by abnormal interruptions, while improving the performance of the server.
[0047] Since there are two processes in the persistence process, the editing operation needs to be synchronized to the two processes. However, the two processes share memory data. If the editing operation is repeated twice, data tampering may occur and real data may be lost. Therefore, this application responds to the parent process's editing instructions for the data in the key space, converts the editing instructions into idempotent operations, and edits the data stored in the key space, so that even if the operation is performed multiple times, the result of the editing operation will not be changed, thereby ensuring the correctness of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0049] Figure 1 A schematic diagram of a process for implementing shared data editing provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the structure of a shared data editing device provided in an embodiment of the present application;
[0051] Figure 3 A structural schematic diagram of a shared data editing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0053] In order to solve the problem of abnormal interruption when modifying data during data persistence, reduce the possibility of data loss, and improve server performance, the embodiment of the present application proposes a shared data editing method applied to the server's memory database. The memory database is pre-deployed with two key spaces, one of which is used to store data that supports idempotent operations, and the other is used to store data that does not support idempotent operations.
[0054] It is understandable that in the prior art, all data in the in-memory database performs the same persistence operation, resulting in data with strong operability being backward compatible with data with low operability. For example, data that supports idempotent operations is backward compatible with data that cannot support idempotent operations, so that idempotent operations are not allowed for all data in the in-memory database. Based on this, data with strong operability cannot achieve higher-level and more convenient sustainable operations.
[0055] Based on the above considerations, the embodiment of the present application divides the memory database, that is, deploys two relatively independent key spaces, one of which stores data with higher operability, and the other stores data with lower operability. Each key space can independently manage the data in its own space. Therefore, the key spaces persist the data in their own spaces respectively.
[0056] In addition, the data stored in the two key spaces of the embodiment of the present application are distinguished based on whether they support idempotent operations. Optionally, the process of pre-deploying two key spaces in the memory database may include: identifying whether each data in the memory database supports idempotent operations; obtaining a first data set and a second data set based on the identification result corresponding to each data, the first data set containing all data that supports idempotent operations, and the second data set containing all data that does not support idempotent operations; deploying two key spaces in the memory database; migrating the first data set and the second data set to the two key spaces respectively, obtaining a first key space and a second key space, the first key space being used to store the first data set, and the second key space being used to store the second data set.
[0057] In the embodiment of the present application, it is considered that the data in the memory database is shared memory data for the child process and the parent process in the persistence process. Therefore, if the parent process modifies the memory data during the persistence process, if the child process synchronizes the operation of the parent process, the memory data will be modified for the second time, and the updated data will be tampered with instead. Therefore, the embodiment of the present application introduces idempotent operations. Idempotent operations refer to an operation that can be executed multiple times without changing the state of the result, that is, the execution result of an idempotent operation is independent of the number of executions, and the results of executing once and executing multiple times are the same.
[0058] Based on this, all data are divided into two categories according to whether the data in the memory database supports idempotent operations, and a first data set that supports idempotent operations and a second data set that does not support idempotent operations are obtained. Based on this, during the persistence of memory snapshots, even if the child process and the parent process repeatedly perform idempotent operations on the shared memory library data, the data results obtained are the same, and there will be no multiple modification superposition results, which improves the accuracy of the data.
[0059] Furthermore, the data belonging to the first data set is migrated to the first key space, and the data belonging to the second data set is migrated to the second key space. If the first key space allows idempotent operations, the data in the key space can be edited in the subsequent persistence process. If the second key space does not allow idempotent operations, the data in the key space cannot be edited in the subsequent persistence process to avoid inaccurate data caused by overlapping editing operations.
[0060] Based on the key space divided above, refer to Figure 1 , a flow chart of implementing shared data editing provided by an embodiment of the present application, and a specific flow of a method for editing shared data during persistence may include the following contents:
[0061] Step S110, in response to the memory snapshot instruction for the target key space, determining whether the data stored in the target key space supports idempotent operations. If yes, executing step S120.
[0062] The two key spaces in the memory database can perform memory snapshots independently. Therefore, during the persistence of the memory snapshot, although the data in the two key spaces in the memory database belong to the shared memory data of the child process and the parent process, the parent process and the child process can perform operations on the separate key spaces for editing and persisting the data.
[0063] Referring to the above, the embodiment of the present application uses whether or not idempotent operations are supported as a sign of whether data is allowed to be modified during the persistence process. Therefore, different memory snapshot configurations can be set in advance for each key space. The same memory snapshot configuration can also be configured for each key space. Each time the key space executes a memory snapshot instruction, by identifying whether the data stored in the key space supports idempotent operations, the corresponding memory snapshot method is selected in the memory snapshot configuration. Based on this, it can be avoided that the memory snapshot configuration of each key space must be rewritten every time the data changes due to changes in the key space data in the memory database, thereby improving the flexibility of each key space in the memory database.
[0064] The purpose of determining whether the data stored in the target key space supports idempotent operations is to determine whether the target key space is a pre-set key space that supports editing by the parent process. Therefore, in one possible implementation, a distinguishing mark is set for the first key space and the second key space respectively, and the distinguishing mark is a mark that characterizes whether the data in the key space supports idempotent operations.
[0065] A flag is added in advance to each key space in the memory database to indicate whether modification is allowed after memory sharing, or whether the data in the key space supports idempotent operations. For example, a flag of "modification allowed" or "idempotent operations supported" is added to the first key space storing the first data set, and a flag of "modification not allowed" or "idempotent operations not supported" is added to the second key space storing the second data set. Based on this, each time a memory snapshot instruction is responded to for the target key space, there is no need to re-determine whether the data in the target key space supports idempotent operations, and only the flag corresponding to the target key space needs to be identified.
[0066] If the judgment result is that the data stored in the target key space for executing the memory snapshot instruction supports idempotent operations, the process of the target key space responding to the editing operation during the memory snapshot process can refer to the following steps S120 to S140.
[0067] Step S120, triggering a fork operation to create a child process identical to the parent process.
[0068] The fork operation is an operation used by a parent process to create a child process that is identical to itself. The parent process can be understood as the main process that runs normally in the memory database. After triggering the fork, a child process that is completely identical to the parent process is obtained. Specifically, after the child process is created, the child process copies the page table entry of the parent process to obtain the page table entry corresponding to the child process. The page table entry contains the mapping relationship between the virtual address and the physical address of the shared memory data, that is, the page table content of the child process and the parent process is the same and points to the same physical address.
[0069] Based on this, after the child process obtains the memory data of the parent process during the fork operation, it starts to read the data at these addresses in the page table entries and writes the data to the memory snapshot file. When the child process completes the memory snapshot of all data, it will use the latest generated memory snapshot file to replace the last persisted file to complete the persistence of the data corresponding to this memory snapshot.
[0070] In a possible implementation, a fork operation is triggered to create a child process identical to a parent process, including: triggering a fork process and blocking the parent process; creating a child process; unblocking the parent process and controlling the child process to copy the page table entries of the parent process to obtain the page table entries of the child process; and correcting the read and write states of the page table entries corresponding to the parent process and the child process, respectively, to a read-write state.
[0071] When creating a child process for memory snapshot, the fork operation will instantly block the main thread (parent process) because it is necessary to copy the necessary data structures of the process, including the memory page table (the mapping index table between virtual memory and physical memory). This copy process consumes a lot of CPU resources, and the entire process will be blocked before the copy is completed. The blocking time depends on the memory size of the entire instance. The larger the instance, the larger the memory page table, and the longer the fork blocking time.
[0072] Therefore, after the child process is created, the embodiment of the present application releases the blockage of the parent process, allowing the child process to copy the page table entries of the parent process during the process of sharing memory data, thereby significantly shortening the blocking time of the parent process forking the child process and improving the efficiency of the memory snapshot.
[0073] In addition, in the embodiment of the present application, the read-write status of the page table items corresponding to the parent process and the child process are both in the read-write status. In the read-write status, the parent process and the child process can implement subsequent editing operations on the shared memory data. It can be understood that, without setting the default read-write status of the page table items of the parent process and the child process to the read-write status, but to avoid the situation where the read-write status is incorrectly modified when a large amount of data is operated in the memory database, the embodiment of the present application specifically modifies the read-write status of the page table items of the child process and the parent process. If the read-write status of the page table items of the parent process and the child process has not been modified and is in the read-write status, the correction operation can be ignored.
[0074] Optionally, if the persistence mode in the memory database is a mixed mode of RDB and ADF, a new AOF file can be created when the child process is created to record all new memory write commands thereafter.
[0075] If the target key space that is judged to execute the memory snapshot instruction does not support idempotent operations, the process of the target key space responding to the editing operation during the memory snapshot process can refer to the following steps: trigger a fork operation to create a child process that is the same as the parent process, wherein the page table entries corresponding to the parent process and the child process are both in read-only state; in response to the editing instruction of the parent process to modify the data in the target key space, trigger an abnormal interrupt and obtain a memory space independent of the target key space; copy the data stored in the target key space to the memory space; edit the data in the memory space according to the editing instruction to obtain the editing result data; and modify the page table entry corresponding to the parent process according to the address information of the memory space corresponding to the editing result data.
[0076] For key spaces that are not allowed to be modified, the memory snapshot process is similar to the existing technology. When the memory snapshot triggers a fork operation, the parent process is first blocked, the read and write permissions in the parent process's page table entries are set to read-only, and then the child process is created. After the child process completes the copying of the parent process's page table entries, the parent process is unblocked and the child process begins to persist the memory data.
[0077] When the child process persists the memory data of the target key space, when the parent process modifies the shared memory data, a page exception interrupt of the kernel will be triggered. It is necessary to apply to the server or system for a new memory that is independent of the target key space or independent of the two key spaces, and copy the memory data of the target key space to the new memory, and implement the modification operation of the parent process in the new memory. In addition, the page table entry corresponding to the modified data in the page table of the parent process is also modified synchronously, that is, the original memory address in the page table entry is changed to the new memory address, so as to realize the modification of the parent process data.
[0078] Step S130, in response to an edit instruction from the parent process to modify data in the target key space, convert the edit instruction into a corresponding idempotent operation.
[0079] Step S140, edit the data stored in the target key space according to the idempotent operation, and map the edited results to the page table entries corresponding to the child process and the parent process respectively.
[0080] In response to the parent process's editing instructions for shared memory data, that is, for data in the target key space, the editing instructions may optionally include: modification instructions, deletion instructions, insertion instructions, etc. The editing instructions are converted into idempotent operations, and the data in the target key space are edited based on the idempotent operations. Unlike the editing process of the parent process of the "key space that is not allowed to be modified", the "key space that is allowed to be modified" does not need to modify the address of the page table entry record in the page table, and since the read and write permissions in the page table entry are read and write, when executing the editing instructions based on the idempotent operation, there is no need to trigger a page fault exception interrupt, and the memory data can be directly modified.
[0081] In summary, the shared data editing method provided by the embodiment of the present application pre-deploys two key spaces, and sets the type of data keys used to store for each key space, so that data keys supporting different types of editing operations are stored in different key spaces. For supporting idempotent operations to edit data, in the process of triggering a fork operation for persistence, the child process and parent process page table entries are set to a readable and writable state to provide permissions for editing operations. When the data is subsequently edited, there is no need to trigger a page fault abnormal interrupt, and the memory data can be directly modified, reducing data loss and inconsistency problems caused by abnormal interrupts, while improving server performance.
[0082] Since there are two processes in the persistence process, the editing operation needs to be synchronized to the two processes. However, the two processes share memory data. If the editing operation is repeated twice, data tampering may occur and real data may be lost. Therefore, this application responds to the parent process's editing instructions for the data in the key space, converts the editing instructions into idempotent operations, and edits the data stored in the key space, so that even if the operation is performed multiple times, the result of the editing operation will not be changed, thereby ensuring the correctness of the data.
[0083] The shared data editing device provided in an embodiment of the present application is described below. The shared data editing device described below and the shared data editing method described above can be referenced to each other.
[0084] First, combine Figure 2 , a shared data editing device for a memory database applied to a server is introduced, wherein the memory database is pre-deployed with two key spaces, one of which is used to store data supporting idempotent operations, and the other is used to store data not supporting idempotent operations. Figure 2 As shown, the shared data editing device may include:
[0085] The key space determination unit 100 is used to determine whether the data stored in the target key space supports idempotent operations in response to a memory snapshot instruction for the target key space;
[0086] A fork trigger unit 200, configured to trigger a fork operation to create a child process identical to the parent process when the judgment result of the target key space judgment unit is yes, wherein the page table entries corresponding to the parent process and the child process are both in a readable and writable state, and the page table entries contain a mapping relationship between a virtual address and a physical address of data in the target key space;
[0087] An instruction conversion unit 300 is used to respond to an edit instruction of the parent process to modify data in the target key space, and convert the edit instruction into a corresponding idempotent operation;
[0088] The data editing unit 400 is used to edit the data stored in the target key space according to the idempotent operation, and map the editing results to the page tables corresponding to the child process and the parent process respectively.
[0089] In a possible implementation, the fork trigger unit includes:
[0090] Block the parent process subunit to trigger the fork process and block the parent process;
[0091] The process creation subunit is used to create a subprocess;
[0092] A page table entry copying subunit, used to unblock the parent process and control the child process to copy the page table entry of the parent process to obtain the page table entry of the child process;
[0093] The page table state correction unit is used to correct the read and write states of the page table entries corresponding to the parent process and the child process respectively to a readable and writable state.
[0094] In a possible implementation, the functional unit for pre-deploying two key spaces in the in-memory database includes:
[0095] A data identification unit, used to identify whether each data in the memory database supports idempotent operations;
[0096] A data partitioning unit, configured to obtain a first data set and a second data set according to the identification result corresponding to each of the data, wherein the first data set includes all data supporting idempotent operations, and the second data set includes all data not supporting idempotent operations;
[0097] A key space deployment unit, used to deploy two key spaces in the memory database;
[0098] The data migration unit is used to migrate the first data set and the second data set to the two key spaces respectively to obtain a first key space and a second key space, wherein the first key space is used to store the first data set and the second key space is used to store the second data set.
[0099] In a possible implementation, the functional unit for pre-deploying two key spaces in the memory database further includes:
[0100] A flag setting unit is used to set a distinguishing flag for the first key space and the second key space respectively, and the distinguishing flag is a flag indicating whether the data in the key space supports idempotent operations.
[0101] In a possible implementation, the key space determination unit 100 includes:
[0102] The flag identification subunit is used to identify whether the distinguishing flag corresponding to the key space is a flag representing whether the data in the key space supports idempotent operations.
[0103] In a possible implementation, the method further includes:
[0104] A read-only setting unit, used for triggering a fork operation to create a child process identical to the parent process when the data stored in the target key space does not support idempotent operations, wherein the page table entries corresponding to the parent process and the child process are both in a read-only state;
[0105] an interrupt triggering unit, configured to trigger an abnormal interrupt in response to an editing instruction of the parent process to modify data in the target key space, and to obtain a memory space independent of the target key space;
[0106] A data copying unit, used to copy the data stored in the target key space to the memory space;
[0107] A data editing unit, used to edit the data in the memory space according to the editing instruction to obtain editing result data;
[0108] The page table entry modification unit is used to modify the page table entry corresponding to the parent process according to the address information of the memory space corresponding to the editing result data.
[0109] In summary, the embodiment of the present application pre-deploys two key spaces, and sets the type of data keys for storage for each key space, so that data keys supporting different types of editing operations are stored in different key spaces. For editing data with support for idempotent operations, in the process of triggering a fork operation for persistence, the page table entries of the child process and the parent process are set to a readable and writable state to provide permissions for editing operations. When the data is subsequently edited, there is no need to trigger a page fault abnormal interruption, and the memory data can be directly modified, reducing data loss and inconsistency problems caused by abnormal interruptions, while improving server performance.
[0110] Since there are two processes in the persistence process, the editing operation needs to be synchronized to the two processes. However, the two processes share memory data. If the editing operation is repeated twice, data tampering may occur and real data may be lost. Therefore, this application responds to the parent process's editing instructions for the data in the key space, converts the editing instructions into idempotent operations, and edits the data stored in the key space, so that even if the operation is performed multiple times, the result of the editing operation will not be changed, thereby ensuring the correctness of the data.
[0111] The shared data editing apparatus provided in the embodiment of the present application can be applied to a shared data editing device.
[0112] Figure 3 A schematic diagram of the structure of a shared data editing device is shown, referring to Figure 3 The structure of the shared data editing device may include: at least one processor 10, at least one memory 20, at least one communication bus 30 and at least one communication interface 40.
[0113] In the embodiment of the present application, the number of the processor 10 , the memory 20 , the communication bus 30 , and the communication interface 40 is at least one, and the processor 10 , the memory 20 , and the communication interface 40 communicate with each other through the communication bus 30 .
[0114] The processor 10 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0115] The memory 20 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), etc., such as at least one disk memory.
[0116] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to implement each processing flow in the aforementioned shared data editing method.
[0117] An embodiment of the present application also provides a computer storage medium, which can store a program suitable for execution by a processor, and the program is used to implement each processing flow in the aforementioned shared data editing method.
[0118] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of personal information involved in the memory database of the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0119] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0120] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0121] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A shared data editing method, characterized in that: A memory database applied to a server, wherein the memory database is pre-deployed with two key spaces, one of which is used to store data supporting idempotent operations, and the other is used to store data not supporting idempotent operations; The shared data editing method comprises: In response to a memory snapshot instruction for a target key space, determining whether data stored in the target key space supports idempotent operations; In the case where the data stored in the target key space supports idempotent operations, a fork operation is triggered to create a child process identical to the parent process, wherein the page table entries corresponding to the parent process and the child process are both in a readable and writable state, and the page table entries contain a mapping relationship between a virtual address and a physical address of the data in the target key space; In response to an edit instruction from the parent process to modify data in the target key space, converting the edit instruction into a corresponding idempotent operation; The data stored in the target key space is edited according to the idempotent operation, and the editing result is mapped to the page table entries corresponding to the child process and the parent process respectively.
2. The shared data editing method according to claim 1, characterized in that: The triggering of the fork operation creates a child process identical to the parent process, including: Trigger the fork process and block the parent process; Create a child process; Unblocking the parent process, and controlling the child process to copy the page table entry of the parent process to obtain the page table entry of the child process; The read / write status of the page table entries corresponding to the parent process and the child process respectively are modified to be in a readable and writable state.
3. The shared data editing method according to claim 1, characterized in that: The process of pre-deploying two key spaces in the in-memory database includes: Identify whether each data in the memory database supports idempotent operations; According to the identification result corresponding to each of the data, a first data set and a second data set are obtained, wherein the first data set includes all data supporting idempotent operations, and the second data set includes all data not supporting idempotent operations; Deploy two key spaces in the memory database; The first data set and the second data set are respectively migrated to the two key spaces to obtain a first key space and a second key space, wherein the first key space is used to store the first data set, and the second key space is used to store the second data set.
4. The shared data editing method according to claim 3, characterized in that: Also includes: A distinguishing mark is set for the first key space and the second key space respectively, and the distinguishing mark is a mark indicating whether the data in the key space supports idempotent operation.
5. The shared data editing method according to claim 4, characterized in that: The determining whether the data stored in the key space supports idempotent operations includes: Identify whether the distinguishing mark corresponding to the key space is a mark indicating whether the data in the key space supports idempotent operations.
6. The shared data editing method according to claim 1, characterized in that: Also includes: In the case where the data stored in the target key space does not support idempotent operations, a fork operation is triggered to create a child process identical to the parent process, wherein the page tables corresponding to the parent process and the child process are both in a read-only state; In response to an editing instruction of the parent process to modify data in the target key space, triggering an abnormal interruption, and acquiring a memory space independent of the target key space; Copying the data stored in the target key space to the memory space; Editing the data in the memory space according to the editing instruction to obtain editing result data; The page table corresponding to the parent process is modified according to the address information of the memory space corresponding to the editing result data.
7. A shared data editing device, characterized in that: A memory database applied to a server, wherein the memory database is pre-deployed with two key spaces, one of which is used to store data supporting idempotent operations, and the other is used to store data not supporting idempotent operations; The shared data editing device comprises: A key space determination unit, configured to determine, in response to a memory snapshot instruction for a target key space, whether data stored in the target key space supports idempotent operations; a fork trigger unit, configured to trigger a fork operation to create a child process identical to the parent process if the judgment result of the key space judgment unit is yes, wherein the page table entries corresponding to the parent process and the child process are both in a readable and writable state, and the page table entries contain a mapping relationship between a virtual address and a physical address of data in the target key space; an instruction conversion unit, configured to respond to an edit instruction of the parent process to modify data in the target key space and convert the edit instruction into a corresponding idempotent operation; A data editing unit is used to edit the data stored in the target key space according to the idempotent operation, and map the editing results to the page table entries corresponding to the child process and the parent process respectively.
8. The shared data editing device according to claim 7, characterized in that: The fork trigger unit comprises: Block the parent process subunit to trigger the fork process and block the parent process; The process creation subunit is used to create a subprocess; A page table entry copying subunit, used to unblock the parent process and control the child process to copy the page table entry of the parent process to obtain the page table entry of the child process; The page table state correction unit is used to correct the read and write states of the page table entries corresponding to the parent process and the child process respectively to a readable and writable state.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the shared data editing method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that: The computer storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the shared data editing method as described in any one of claims 1 to 6.