Data processing method and device, electronic equipment, storage medium and program product
By serializing and persisting data when the server's memory data changes, and using the second server for data deserialization and recovery, the problem of data loss when the server crashes is solved, and the stability and user experience of the disaster recovery solution are improved.
Patent Information
- Application Number
- CN202310305869.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2024-09-24
AI Technical Summary
Existing server disaster recovery solutions cannot effectively restore memory data when the server crashes, resulting in user data loss and excessive resource consumption, affecting user experience.
By serializing the data and updating it to the database when the memory data changes on the first server, the entire memory data is saved in a timely manner, and the data is deserialized and restored on the second server to ensure that the data is persisted in the memory.
It reduces the impact of server crash on user experience, improves the success rate of data recovery, and enhances the robustness of the server architecture.
Smart Images

Figure CN118689702A
Abstract
Description
Technical Field
[0001] The present application relates to database technology, and in particular to a data processing method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] For IT, a disaster recovery system is an environment that can cope with various disasters for computer information systems. When a computer system is hit by irresistible natural disasters such as fire, flood, earthquake, war, or man-made disasters such as computer crime, computer virus, power failure, network / communication failure, hardware / software error, and human operation error, the disaster recovery system will ensure the security of user data (data disaster recovery).
[0003] The server disaster recovery solution of the related technology attempts to restart the service process on the original machine and rebind it to the original shared memory when the server process crashes, so as to achieve the effect of recovering the memory data. In a worse case, if the machine crashes and is unavailable, the service process can only be started on other machines. Since all memory data is lost, only earlier data can be loaded into the memory. Summary of the invention
[0004] The embodiments of the present application provide a data processing method, device, electronic device, computer-readable storage medium, and computer program product, which can improve the security of data backup and the success rate of data reconstruction.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The embodiment of the present application provides a data processing method, which is applied to a disaster recovery system. The disaster recovery system includes a first server, a second server, and a database, including:
[0007] When a memory data change event occurs on the first server, the database receives a database update operation of the first server to synchronize the memory data change event;
[0008] The database stores full serialized data corresponding to the full memory data of the first server, and the database update operation is used to update at least part of the serialized data stored in the database;
[0009] When the memory data of the first server is in an unavailable state, the database synchronizes the full serialized data corresponding to the first server to the second server, so that the second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
[0010] An embodiment of the present application provides a data processing device, which is applied to a disaster recovery system. The disaster recovery system includes a first server, a second server, and a database, including:
[0011] A maintaining module, configured to cause the database to receive a database update operation of the first server to synchronize the memory data change event when the memory data change event occurs on the first server;
[0012] The database stores full serialized data corresponding to the full memory data of the first server, and the database update operation is used to update at least part of the serialized data stored in the database;
[0013] The first recovery module is used to synchronize the full serialized data corresponding to the first server to the second server by the database when the memory data of the first server is in an unavailable state, so that the second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
[0014] An embodiment of the present application provides an electronic device, including:
[0015] A memory for storing computer executable instructions;
[0016] The processor is used to implement the data processing method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.
[0017] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for causing a processor to execute the instructions to implement the data processing method provided in the embodiment of the present application.
[0018] An embodiment of the present application provides a computer program product, including computer executable instructions, which, when executed by a processor, implement the data processing method provided in the embodiment of the present application.
[0019] The embodiments of the present application have the following beneficial effects:
[0020] By serializing the data in the memory of the first server and updating the database in a timely manner for persistent storage, when the memory of the first server is unavailable, the lost memory data can be deserialized from the database and restored to the memory through the second server to continue providing services, reducing the impact of accidents such as server crashes and unavailability on user experience and making the server architecture more robust. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1A is a structural diagram of a data processing system provided in an embodiment of the present application;
[0022] Figure 1B is a structural diagram of a data processing system provided in an embodiment of the present application;
[0023] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0024] Figure 3A-3C It is a flowchart of a data processing method provided in an embodiment of the present application;
[0025] Figure 4 This is a schematic diagram of server memory data disaster recovery provided by related technologies;
[0026] Figure 5 It is a schematic diagram of server memory data disaster recovery of the data processing method provided in an embodiment of the present application;
[0027] Figure 6 It is a schematic diagram of bucket mapping of the data processing method provided in an embodiment of the present application;
[0028] Figure 7 It is a serialized schematic diagram of a memory pool of a data processing method provided in an embodiment of the present application;
[0029] Figure 8 It is a schematic diagram of deserialization of a memory pool of a data processing method provided in an embodiment of the present application;
[0030] Fig. 9 It is a flowchart of bucket data persistence of the data processing method provided in an embodiment of the present application;
[0031] Fig.10 It is a flow chart of restoring memory data of the data processing method provided in the embodiment of the present application;
[0032] Fig.11 It is a schematic diagram of server disaster recovery management deployment of the data processing method provided in the embodiment of the present application;
[0033] Fig.12 This is a normal server start and stop timing diagram of the data processing method provided in the embodiment of the present application;
[0034] Fig.13 It is a timing diagram of automatic lossless disaster recovery of memory data in the data processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0036] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0037] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0039] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0040] 1) Serialization: The conversion of structured data into a byte stream is called serialization, and the reverse is deserialization. In addition to transmitting data over the network, another important use of serialization is to save structured data in files, because the data stored in the file is also in binary format, which is essentially the same as the data in the network transmission process.
[0041] 2) TcaplusDB: A distributed NoSQL database designed specifically for games
[0042] 3) TSF4G Data Representation: A cross-platform data representation language that combines the advantages of XML, binary, and object-relational mapping and is widely used in game data serialization scenarios
[0043] See also Figure 4 Most of the server disaster recovery solutions in related technologies cache user data in shared memory, serialize the memory data periodically, and write it back to the database for persistent storage. When the server process crashes, try to restart the service process on the original machine and rebind it to the original shared memory to achieve the effect of restoring the memory data; if the machine crashes and is unavailable, the service process can only be started on other machines, and all users' memory data and login status will be lost. After the user logs in again, the earlier data is loaded from the database into the memory.
[0044] The server disaster recovery solution of the related technology cannot eliminate machine-level failures, and cannot even eliminate shared memory data loss failures that occur inside the machine. When the server memory data is loaded back from another machine, since the database saves the data saved in the previous cycle, the interval is generally long, which is equivalent to the user data being rolled back to an earlier time point, resulting in the loss of the user's recent time data, and the periodic writing back of data consumes a lot of resources such as network bandwidth and CPU usage.
[0045] The embodiments of the present application provide a data processing method, device, electronic device, computer-readable storage medium, and computer program product, which can trigger persistent storage of a database only when memory data changes, thereby reducing resource consumption. To facilitate easier understanding of the data processing method provided by the embodiments of the present application, an exemplary implementation scenario of the data processing method provided by the embodiments of the present application is first described.
[0046] In one implementation scenario, see Figure 1A , Figure 1A It is an architectural diagram of the data processing system provided in an embodiment of the present application. The data processing system is a disaster recovery system. In response to the modification operation of the account nickname received by the terminal 400, the terminal 400 sends the modified account nickname to the first server 200-1, and the first server 200-1 saves the modified nickname in the server's memory. When a memory data change event occurs in the first server 200-1, the first server 200-1 serializes the changed memory data to obtain serialized data, and writes the serialized data to the database 500 (the database update operation of the first server synchronizing the memory data change event). When the memory data of the first server 200-1 is in an unavailable state, the second server 200-2 pulls the serialized data of the first server from the database 500, and deserializes the pulled serialized data to obtain the memory data of the first server 200-1.
[0047] In one implementation scenario, see Figure 1B , Figure 1BIt is a schematic diagram of the architecture of the data processing system provided in the embodiment of the present application. The data processing system is a disaster recovery system. When the first server 200-1 is started, it sends a heartbeat message to the management server 200-3. The management server 200-3 returns an identifier A to the first server 200-1. In response to the modification operation of the account nickname by the terminal 400 receiving the object, the terminal 400 sends the modified account nickname to the first server 200-1. The first server 200-1 saves the modified nickname in the memory of the server. When a memory data change event occurs in the first server 200-1, the first server 200-1 serializes the changed memory data. Processing, obtain serialized data, and write the serialized data into the database 500 (the database update operation of the first server synchronizing the memory data change event). When the management server does not receive the heartbeat information of the first server within the set time length (indicating that the memory data of the first server 200-1 is in an unavailable state), and receives the heartbeat information of the second server, the management server 200-3 assigns and returns the identifier A to the second server. The second server 200-2 pulls the serialized data of the first server from the database 500, and deserializes the pulled serialized data to obtain the memory data of the first server 200-1.
[0048] In some embodiments, the terminal 400 can implement the data processing method provided in the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, APPlication), that is, a program that needs to be installed in the operating system to run, such as a dress-up game APP; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a game small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0049] Taking the computer program as an application program as an example, in actual implementation, the terminal 400 installs and runs an application program that supports virtual scenes. The application program can be any one of a first-person shooting game (FPS), a third-person shooting game, a virtual reality application program, a three-dimensional map program, or a multiplayer gunfight survival game.
[0050] In some embodiments, the embodiments of the present application can also be implemented with the aid of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or a local area network to achieve data calculation, storage, processing, and sharing.
[0051] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources.
[0052] For example, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present invention.
[0053] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device for data processing provided in an embodiment of the present application, Figure 2 The server with a database deployed as shown includes: at least one processor 210, a memory 250, at least one network interface 220 and a user interface 230. The various components in the terminal 400 are coupled together through a bus system 240. It can be understood that the bus system 240 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 240 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Figure 2 Various buses are labeled as bus system 240 .
[0054] The processor 210 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0055] The user interface 230 includes one or more output devices 231 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 230 also includes one or more input devices 232, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0056] The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 250 may optionally include one or more storage devices that are physically remote from the processor 210.
[0057] The memory 250 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 250 described in the embodiments of the present application is intended to include any suitable type of memory.
[0058] In some embodiments, memory 250 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0059] Operating system 251, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0060] A network communication module 252, used to reach other electronic devices via one or more (wired or wireless) network interfaces 220, exemplary network interfaces 220 include: Bluetooth, Wireless Compatibility Authentication (WiFi), and Universal Serial Bus (USB), etc.;
[0061] a presentation module 253 for enabling presentation of information via one or more output devices 231 (e.g., display screen, speaker, etc.) associated with the user interface 230 (e.g., a user interface for operating peripherals and displaying content and information);
[0062] The input processing module 254 is used to detect one or more user inputs or interactions from one of the one or more input devices 232 and translate the detected inputs or interactions.
[0063] In some embodiments, the data processing device provided in the embodiments of the present application can be implemented in software. Figure 2 The data processing device 255 stored in the memory 250 is shown, which can be software in the form of a program and a plug-in, etc., and includes the following software modules: a receiving module 2551 and a first recovery module 2552. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0064] The data processing method provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the terminal provided in the embodiment of the present application.
[0065] See also Figure 3A , Figure 3A is a flow chart of a data processing method provided in an embodiment of the present application. The data processing method is applied to a disaster recovery system. The disaster recovery system includes a first server, a second server and a database. Figure 3A The steps shown are explained.
[0066] In step 101, when a memory data change event occurs in a first server, the database receives a database update operation of the first server to synchronize the memory data change event.
[0067] As an example, the first server is a server for supporting a certain business, for example, the first server is a server for supporting a game business, and a shared memory is deployed in the first server for storing the business service data of the user, for example, the dressing of the virtual object set by the user, etc.
[0068] As an example, the database stores full serialized data corresponding to the full memory data of the first server, the serialized data is obtained by serializing the memory data, and the database update operation is used to update at least part of the serialized data stored in the database.
[0069] As an example, the memory data change event includes any one of the following: new memory data is added to the memory data pool of the first server; original memory data in the memory data pool of the first server is modified; original memory data in the memory data pool of the first server is deleted.
[0070] In step 102, when the memory data of the first server is in an unavailable state, the database synchronizes the full serialized data corresponding to the first server to the second server, so that the second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
[0071] As an example, when the first server is restarted, the first server cleans up the shared memory, or the first server crashes and becomes unavailable, the memory data of the first server is in an unavailable state. Since the memory data of the first server is in an unavailable state, in order to shield the machine failure from the user, the service will be migrated from the first server to the second server, so the database will synchronize the full serialized data corresponding to the first server to the second server. The full serialized data corresponding to the first server here is the serialized data obtained by serializing the full memory data of the first server. The second server will restore the full serialized data to memory data and bind the service process to the memory data for use.
[0072] Through the embodiment of the present application, the data in the shared memory of the first server is serialized and written to the database in a timely manner for persistent storage. When the server is restarted, the shared memory is cleared, or the server crashes and becomes unavailable, the service process can be restarted on other machines (the second server), and the lost memory data can be deserialized from the database and restored to the shared memory, thereby reducing the impact of accidents such as server crashes and unavailability on the game player experience and making the server architecture more robust.
[0073] In some embodiments, see Figure 3B , the database update operation is performed by the first server Figure 3B The steps 201 to 204 shown are determined.
[0074] In step 201, target memory data is obtained.
[0075] In step 202, when the target memory data satisfies the update mechanism, the target memory data is determined as the changed memory data involved in the memory data change event, and a serialization key corresponding to the changed memory data is obtained.
[0076] As an example, before executing step 101, it is necessary to execute step 201, and based on the target memory data obtained in step 201, determine whether the update mechanism is satisfied. When it is determined that the update mechanism is satisfied, the target memory data is determined as the changed memory data involved in the memory data change event, so that it can be determined that a memory data change event has indeed occurred on the first server, and continue to perform subsequent processing, that is, obtain the serialization key corresponding to the changed memory data, and execute steps 203 and 204.
[0077] In some embodiments, a bucket mapping process is performed on the data key of the changed memory data to obtain a first identifier of the data bucket; the current version number of the data bucket and the current version number of the database are obtained; wherein the current version number is obtained by calling a function interface to perform a version number update process when a memory data change event is triggered; when the current version number of the data bucket is inconsistent with the current version number of the database, it is determined that the target memory data satisfies the update mechanism. The embodiments of the present application can accurately detect memory data change events, thereby saving processing resources consumed by data backup.
[0078] As an example, after the memory data is modified, the following method can be used to trigger the persistence of the database. After the memory data is modified, only the dirty data is marked. That is, each time the business layer modifies the memory data, the business logic increments the data version number of the corresponding data bucket. When it is found that the current data version number of the bucket data is inconsistent with the data version number recorded in the database table, the automatic save mechanism is triggered. Therefore, it is necessary to propose usage specifications for the development of the business layer. When the key fields of the memory data are modified at the business layer, the function interface provided by the embodiment of the present application is actively called to increment the data version number.
[0079] In some embodiments, the above-mentioned acquisition of the serialization key corresponding to the changing memory data can be achieved through the following technical solution: bucket mapping processing is performed on the data key of the changing memory data to obtain the first identifier of the data bucket; the second identifier of the service instance of the first server, the third identifier of the memory pool corresponding to the changing memory data, and the first identifier are combined to form the serialization key of the changing memory data.
[0080] As an example, the structure of the database table is shown in Table 1. As shown in Table 1, the primary key Busid+Pool+BucketSeq needs to be specified as the unique identifier in the memory data landing database. Figure 6 , the data items in the memory pool are mapped to a data bucket through Hash, and then all the data items in the data bucket are packaged and saved as a record in the database. In this way, the number of records in the database can be converged, the modification operations can be merged, and the number of database operations can be reduced.
[0081]
[0082] Table 1 Key storage structure in database table
[0083] In step 203, when the memory data change event is deletion of memory data, and the serialized data corresponding to the deleted memory data is the only serialized data corresponding to the serialization key, the record corresponding to the serialization key is removed from the database as a database update operation.
[0084] As an example, the modification of data items in the memory pool can be converted into bucket modifications through bucket mapping, and then converted into modifications to database records: when a data item in the memory pool is deleted, the data bucket corresponding to the deleted data item (changed memory data) is found. If the data bucket is empty, the delete operation is recorded in the database table, otherwise the replace operation is recorded. The delete operation is to remove the record of the corresponding serialization key from the database, that is, the delete operation is used as a database update operation.
[0085] In step 204, when the memory data change event is not the deletion of memory data, or the serialized data corresponding to the deleted memory data is not the only serialized data of the corresponding serialization key, the target serialized data of the corresponding serialization key is obtained, and the serialized data of the corresponding serialization key in the database is replaced with the target serialized data to determine it as a database update operation.
[0086] As an example, when the memory pool has a new data item, find the data bucket corresponding to the new data item, and then record the replace operation in the database table; when a data item in the memory pool is modified, find the data bucket corresponding to the modified data item, and then record the replace operation in the database table; when a data item in the memory pool is deleted, find the corresponding data bucket, and if the data bucket is not empty, record the replace operation in the database table. The replace operation here is to replace the serialized data of the corresponding serialization key in the database with the target serialized data. Here, the case of deleting data items is further explained. Multiple data items can be stored in a data bucket. If a data item A among multiple data items is deleted, it should be considered that the data bucket is replaced, that is, replaced with a data bucket that does not have the data item A. Therefore, when mapped to the database table, the serialized data of the corresponding data bucket (data bucket corresponds to the serialization key one by one) is replaced as a whole.
[0087] In some embodiments, the above-mentioned acquisition of the target serialization data corresponding to the serialization key can be implemented by the following technical solutions: querying the full serialization data corresponding to the serialization key from the database based on the serialization key; performing mapping processing based on the data value of the changed memory data to obtain the serialization data of the changed memory data; updating the full serialization data corresponding to the serialization key based on the serialization data of the changed memory data to obtain the target serialization data of the corresponding serialization key. Through the embodiments of the present application, the full serialization data can be replaced as a whole, thereby improving the editing efficiency of the database.
[0088] As an example, data storage in a database is implemented based on key-value pairs. Values can be queried in the database through keys (i.e., serialized data can be queried through serialization keys). In an embodiment of the present application, each serialization key in the database has a one-to-one corresponding record, i.e., one serialization key corresponds to one record, and the record includes the full serialized data of the corresponding serialization key. When a replace operation is performed on the database, the target serialized data (new record) is used to replace the full serialized data (original record) of the serialization key.
[0089] In some embodiments, the above-mentioned mapping processing based on the data value of the changing memory data to obtain the serialized data of the changing memory data can be achieved through the following technical solution: mapping processing is performed on the data value of the changing memory data based on the data representation language to obtain the memory binary data corresponding to the changing memory data; the version number of the data representation language, the length of each memory binary data, and the memory binary data are combined to form the serialized data corresponding to the changing memory data.
[0090] As an example, see Table 2. The TdrVer field specifies the TDR table version number (data representation language version number) used when serializing memory data. The corresponding DataLen part is the length of the byte array, that is, the length of each memory binary data. The serialized binary data is stored in a char array with a maximum storage space of 250KB. The corresponding field Data part (memory binary data) is obtained by mapping the data value of the changed memory data based on the TDR table.
[0091] Fields type name illustrate TdV int TDR version number DataLen int Byte array length Data char array Byte array, 250KB Binary Data
[0092] Table 2 Value storage structure in database table
[0093] In some embodiments, the above-mentioned bucket mapping processing of the data key of the changing memory data to obtain the first identifier of the data bucket can be implemented by the following technical scheme: when the data key of the changing memory data has historical bucket mapping data, the historical data bucket is obtained from the historical bucket mapping data, and the identifier of the historical data bucket is used as the first identifier of the data bucket; when the data key of the changing memory data does not have historical bucket mapping data, any candidate data bucket is obtained from the available candidate data buckets, and the identifier of any candidate data bucket is used as the first identifier of the data bucket. The embodiments of the present application can avoid data bucket conflicts, keep the data bucket of the data item unchanged during the life cycle, and improve the stability of the mapping mechanism.
[0094] As an example, see Figure 6, limited by the size of database records, the capacity of each data bucket is limited. If a data bucket cannot hold the data during the hashing process, it can be handled based on bucket conflicts, and the next bucket can be found in sequence until an available data bucket is found. The number of data in the data bucket will also change due to the addition and deletion of data items, thus affecting the hash results of the data item twice before and after. To avoid this situation, the last data bucket can be used directly so that the data bucket of the data item does not change during its life cycle.
[0095] In some embodiments, after the database receives the database update operation of the first server to synchronize the memory data change event, the current version number of the database is set to the database version number of the data bucket; when the database version number of the data bucket is the same as the current version number of the data bucket, it is determined that the update of the database update operation is completed. This application can ensure that the data is successfully saved, so as to avoid memory data that is not saved and cannot be restored.
[0096] As an example, two fields are defined in the bucket: bucket data version number and database data version number. When a data item in the memory pool is modified, the data version number of the data bucket (bucket data version number) will be increased to trigger database saving; the database data version number (current database version number) will be attached to the communication network message callback between the database and the first server; when the database is saved successfully, the database data version number in the callback is set to the database version number of the data bucket. Therefore, the database version number of the data bucket is equal to the current version number of the data bucket (bucket data version number), indicating that the data has been saved successfully. If the two version numbers are inconsistent, it means that the data has failed to be saved and needs to be saved again.
[0097] In some embodiments, see Figure 3C , the second server is executed by Figure 3C Steps 301 to 303 are shown to determine the full amount of serialized data corresponding to the first server.
[0098] In step 301, a second identifier of a service instance of a first server and a fourth identifier of each memory pool are obtained.
[0099] In step 302, the second identifier of the service instance of the first server and the fourth identifier of each memory pool are combined to form a query key corresponding to each memory pool.
[0100] In step 303, the full amount of serialized data corresponding to each query key is queried from the database.
[0101] As an example, under normal circumstances, the database is only responsible for saving data, and the business logic does not need to read from the database. Only when the entire shared memory needs to be restored, it is necessary to read records from the database. Fig.10 In step 1001, pull the database record based on the partial primary key, decompress it into bucket data in step 1002, take a data record and deserialize it into the memory pool in step 1003, and judge whether the data record traversal is completed in step 1004. When the judgment result is yes, execute step 1005. In step 1005, judge whether all database records have been returned, otherwise execute step 1002. When the judgment result of step 1004 is no, execute step 1003. Pull all database records related to the memory pool through the partial primary key (busid+memory pool), and use these records to restore the memory data. Unpack each pulled record through tdr unpack to obtain the specific bucket data content, then traverse the bucket data and set it to the memory pool through the deserialization function.
[0102] In some embodiments, the disaster recovery system also includes a disaster recovery management module, and the disaster recovery management module and the database are both deployed on a disaster recovery management server, or the disaster recovery management module is deployed on a disaster recovery management server independent of the database; the second server is determined by the disaster recovery management module performing the following processing: when the first server is started for the first time, the disaster recovery management module receives the heartbeat message reported by the first server and returns the server identifier to the first server; when the second server is started for the first time, the disaster recovery management module receives the heartbeat message reported by the second server, the disaster recovery association module determines that the second server is a machine used to replace the first server, and returns the server identifier to the second server; wherein, the server identifier is used to trigger the second server to synchronize the full serialized data of the first server from the database.
[0103] As an example, see Fig.13 In step 1301, server A starts. In step 1302, server A reports the heartbeat to StatusMgr for the first time. In step 1303, StatusMgr returns a unique identifier (VirtualSeq=1) to server A. In step 1304, server A generates memory data. In step 1305, server A serializes the memory data and puts it into the database. In step 1306, server A becomes unavailable and cannot continue to report the heartbeat. In step 1307, server B starts. In step In step 1308, server B reports the heartbeat to StatusMgr for the first time. In step 1309, StatusMgr determines that server B will replace server A. In step 1310, StatusMgr returns a unique identifier (VirtualSeq=1) to server B. In step 1311, server B pulls the memory data record of server A. In step 1312, the database returns the information that server A has stopped service abnormally and the record is not empty. In step 1313, server B performs shared memory initialization and restores memory data.
[0104] In some embodiments, a data processing method is applied to a disaster recovery system, which includes a first server, a second server, and a database. The database stores full serialized data corresponding to the full memory data of the first server. When a memory data change event occurs in the first server, the first server performs a database update operation on the database, so that the second server obtains the full serialized data of the first server from the database when the memory data of the first server is unavailable, and deserializes the full serialized data to obtain the full memory data corresponding to the first server; wherein the database update operation is used to update at least part of the serialized data stored in the database.
[0105] In some embodiments, target memory data is obtained; when the target memory data satisfies the update mechanism, the target memory data is determined as the changed memory data involved in the memory data change event, and it is determined that a memory data change event occurs on the first server. Before the first server performs a database update operation on the database, the serialization key corresponding to the changed memory data is obtained; when the memory data change event is the deletion of memory data, and the serialization data corresponding to the deleted memory data is the only serialization data corresponding to the serialization key, the record corresponding to the serialization key is removed from the database as a database update operation; when the memory data change event is not the deletion of memory data, or the serialization data corresponding to the deleted memory data is not the only serialization data corresponding to the serialization key, the target serialization data corresponding to the serialization key is obtained, and the serialization data corresponding to the serialization key in the database is replaced with the target serialization data to determine it as a database update operation.
[0106] In some embodiments, when a memory data change event occurs on the first server, the first server performs a database update operation on the database, so that when the memory data of the first server is in an unavailable state, the second server performs the following processing: obtain the second identifier of the service instance of the first server and the fourth identifier of each memory pool; combine the second identifier of the service instance of the first server and the fourth identifier of each memory pool to form a query key corresponding to each memory pool; query the database for the full serialized data corresponding to each query key; and obtain the full serialized data of the first server from the database.
[0107] The specific implementation of the above embodiment is the same as the specific implementation of the data processing method described in step 101 to step 103, and will not be repeated here.
[0108] By serializing the data in the memory of the first server and updating the database in a timely manner for persistent storage, when the memory of the first server is unavailable, the lost memory data can be deserialized from the database and restored to the memory through the second server to continue providing services, reducing the impact of accidents such as server crashes and unavailability on user experience and making the server architecture more robust.
[0109] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.
[0110] In one implementation scenario, when the first server starts, it sends a heartbeat message to the management server, and the management server returns an identifier A to the first server. In response to the terminal receiving the object's modification operation on the account nickname, the terminal sends the modified account nickname to the first server, and the first server saves the modified nickname in the server's memory. When a memory data change event occurs on the first server, the first server serializes the changed memory data to obtain serialized data, and writes the serialized data into the database (the first server's database update operation of synchronizing the memory data change event). When the management server does not receive the heartbeat information of the first server within a set time length (indicating that the memory data of the first server is in an unavailable state), and receives the heartbeat information of the second server, the management server assigns and returns the identifier A to the second server, and the second server pulls the serialized data of the first server from the database, and deserializes the pulled serialized data to obtain the memory data of the first server.
[0111] When a machine crashes and becomes unavailable, the data processing method provided by the embodiment of the present application can achieve disaster recovery, that is, switching the service from one machine to another. When the service process starts, it will deserialize and load the shared memory data from the database Tcaplus DB. Figure 5 When the service process is started for the first time or the service process is shut down normally, the memory data to be loaded is empty. The service process is bound to the shared memory and used. During the service process, new data will be generated in the shared memory or existing data will be modified. At this time, the memory data will be serialized and written back to the database for persistence, ensuring that the latest data of the object can be saved in time. Figure 5 When server A is unavailable, the disaster recovery switching mechanism is triggered, and the service process is started on another machine (server B) and the above steps are completed. Since server A has saved the relevant memory data in time, it can restore the object data from the database to the shared memory as much as possible.
[0112] Through the embodiment of the present application, the data in the memory is serialized into a database for storage, and the memory data can be restored with the storage data in the database, so that the server can be considered to be stateless, and therefore can be migrated and changed at will. Next, it can be applied on the server to make an automatic disaster recovery solution that can achieve lossless disaster recovery. Therefore, the embodiment of the present application mainly involves the following two parts, one of which is to serialize the memory data storage database (if the server can write back the memory data to the database in real time, and the memory data can be restored based on the database records, then the server can be considered to be stateless), and the second is to realize automatic lossless disaster recovery (the memory data of the server can be restored from the database, so even if it is arbitrarily switched to other servers, the lossless replacement service can continue).
[0113] The following first introduces the solution of serializing memory data and storing it in the database.
[0114] In some embodiments, the structure of the database table is shown in Table 3. The database selected in the embodiment of the present application is TcaplusDB, the storage structure is in Key-Value form, and the maximum storage space for a single record is 256KB. As shown in Table 3, the primary key Busid+Pool+BucketSeq needs to be specified as the unique identifier in the memory data landing database. When restoring the memory data, all memory data of a certain business is fully restored through the Busid+Pool partial primary key. In addition, the TdrVer field specifies the TDR table version number used when the memory data is serialized. The serialized binary data is stored in a char array, and the maximum storage space is 250KB. The cross-platform data representation language TDR mentioned in the embodiment of the present application is not the only choice, and other similar technologies can be selected, such as Protobuf, Jce, etc.
[0115]
[0116] Table 3 Database table storage structure
[0117] In some embodiments, in a server with pre-allocated memory, the memory space size generally reaches several GB, which is managed in the form of a memory pool. The data types in the same memory pool are the same, and the data items are scattered in the memory pool. Limited by the maximum space of a single record in the database is 256KB and the maximum limit of 480KB for communication messages between servers, it is difficult to save the entire block of memory data to the database at one time. In addition, there are many invalid empty data in the memory, and there are very few real valid data items. Only a small number of data items need to be saved. Therefore, the valid data in the memory can be mapped to the Key-Value record in the database through the bucket mapping algorithm.
[0118] In some embodiments, see Figure 6, the data items in the memory pool are mapped to a bucket through Hash, and then all the data items in the bucket are packaged and saved as a record in the database. In this way, the number of records in the database can be converged, the modification operations can be merged, and the number of database operations can be reduced. Bucket data is mapped to records in the database through the joint primary key (Busid + memory pool + bucket sequence number), that is, the TDR serialized data of one or more data items. Limited by the size of the database record, the capacity of each bucket is limited. If a bucket cannot hold the data during the Hash process, it can be handled based on the bucket conflict method, and the next bucket can be found in sequence until an available bucket is found. The number of data in the bucket will also change due to the addition and deletion of data items, thereby affecting the Hash results of the data items before and after. In order to avoid this situation, the last Hash bucket can be used directly to keep the Hash bucket of the data item unchanged during its life cycle. Bucket mapping can be used to convert modifications to memory pool data items into bucket modifications, and then into modifications to database records: when a memory pool data item is added, the corresponding bucket is found, and the replace operation is recorded in the database table; when a memory pool data item is modified, the corresponding bucket is found, and the replace operation is recorded in the database table; when a memory pool data item is deleted, the corresponding bucket is found, and if the bucket is empty, the delete operation is recorded in the database table, otherwise the replace operation is recorded.
[0119] In some embodiments, in order to support data version pruning, that is, metadata of a higher version can parse serialized database records of a lower version, it is required to define a data record of a TDR definition that needs to be implemented for each data item in the memory pool. Figure 7 , memory pool data items are added with serialization and deserialization functions for conversion between memory pool data items and database table records. The serialization function pfnSeariaFunc is responsible for converting a memory pool data item into a data record defined by TDR, and finally combining the bucket data into a record of the database table. See Figure 8 The deserialization function pfnDeseariaFunc is responsible for converting a data record defined by TDR into a data item in the memory pool and inserting it into the memory pool. Serialization and deserialization are not necessarily function interfaces that come with TDR, but can be function interfaces that come with Protobuf, Jce, etc.
[0120] In some embodiments, after the memory pool data is modified, the following methods can be used to trigger persistent storage of the database. After modifying the memory data, simply mark the dirty data and save it later. That is, each time the business layer modifies the memory data, the business logic increments the data version number of the corresponding bucket to indicate that the data has been modified; when a timer scan finds that the current version number of the bucket data is inconsistent with the data version number recorded in the database table, the automatic save mechanism is triggered. Therefore, it is necessary to propose usage specifications for the development of the business layer. When the business layer modifies the key fields of the memory data, it actively calls the function interface provided in the embodiment of the present application to increment the data version number. When the bucket data is saved in the database table, the data version number and retry mechanism can be used to define two fields in the bucket: bucket data version number + database data version number. See. Fig. 9 In step 901, the bucket data modification process and the data version number increment process are executed. In step 902, it is determined whether the data version number is not equal to the data version number recorded in the database. If it is determined to be yes, step 903 is executed. In step 903, the database saving process is executed. In step 904, the database returns the callback information, and the callback information carries the database version number. In step 905, it is determined whether the saving is successful. If the saving is successful, step 906 is executed. In step 906, the database version number carried by the callback information is set as the bucket data version number. Otherwise, step 902 is executed. Specifically, the modification of the memory pool data item will simultaneously cause the bucket data version number to increase, and then trigger the database saving; the data version number is added to the communication network message callback between the database and the server; when the database is saved successfully, the data version number in the callback is set to the DB data version number of the bucket. Therefore, the bucket data version number is equal to the database data version number, indicating that the data has been saved successfully. If the two version numbers are inconsistent, it means that the data saving has failed and needs to be saved again.
[0121] In some embodiments, the database is only responsible for saving data under normal circumstances, and the business logic does not need to read from the database. Only when the entire shared memory needs to be restored, it is necessary to read records from the database. Fig.10In step 1001, pull the database record based on the partial primary key, decompress it into bucket data in step 1002, take a data record and deserialize it into the memory pool in step 1003, and judge whether the data record traversal is completed in step 1004. When the judgment result is yes, execute step 1005. In step 1005, judge whether all database records have been returned, otherwise execute step 1002. When the judgment result of step 1004 is no, execute step 1003. Pull all database records related to the memory pool through the partial primary key (busid+memory pool), and use these records to restore the memory data. Unpack each pulled record through tdr unpack to obtain the specific bucket data content, then traverse the bucket data and set it to the memory pool through the deserialization function.
[0122] The mapping of memory data items to database records through buckets mentioned in the embodiments of the present application can also be saved in other ways. For example, for a smaller memory pool, the entire block of memory data can be serialized and saved directly to the database; or a direct mapping method can be adopted to directly store each data item in the memory pool into the database through a primary key composed of busid, memory pool and data key.
[0123] In some embodiments, under certain abnormal circumstances, it is not desirable to use database records to restore memory data, and it is desirable to clear all of them, which can be distinguished by configuration. For normal service restart, the default configuration is to simply initialize or bind shared memory; for normal service startup, if the database record is configured to be read, it will be read and loaded into memory; for normal service startup, if the database record is configured to be cleared, the DB data will be cleared first, and then the shared memory will be initialized or bound.
[0124] Next, we will introduce the automated lossless disaster recovery solution.
[0125] In some embodiments, when a server fails and cannot be restored, the problem can be discovered through the heartbeat mechanism, and the execution can be switched to the disaster recovery server. Since the disaster recovery service does not know the status on the old server and is executed completely from scratch, the data of the original server is lost, which may affect the user experience, such as the loss of the team formed in the game, the match timeout, etc. In order to reduce this experience, lossless disaster recovery will be performed. Lossless disaster recovery is based on the memory data serialization storage database technology described above, so that the disaster recovery server can read the database records of the crashed server, restore to the previous memory state to continue execution so that the user is not aware. To achieve lossless disaster recovery, the disaster recovery server must know which old server it is replacing and which data needs to be restored. Therefore, it is necessary to introduce a global disaster recovery management module so that when a server is unavailable, a disaster recovery server can be selected and the corresponding recovery data can be informed.
[0126] In some embodiments, see Fig.11 All servers report heartbeats to the disaster recovery management server StatusMgr, thereby sensing the status of all running services.
[0127] In some embodiments, see Fig.12 In step 1201, server A starts. In step 1202, server A reports its heartbeat to StatusMgr for the first time. In step 1203, StatusMgr returns a unique identifier (VirtualSeq=1) to server A. In step 1204, server A generates memory data. In step 1205, server A serializes the memory data and puts it into the database. In step 1206, server A stops service. In step 1207, server A waits for the transaction to end and the memory data to be automatically released. In step 1208, server A deletes invalid data items from the database. In step 1209, server B starts. In step 1210, server B reports its heartbeat to StatusMgr for the first time. In step 1211, StatusMgr determines that server B will take over server A. In step 1212, StatMgr usMgr returns a unique identifier (VirtualSeq=1) to server B. In step 1213, server B pulls the memory data record of server A. In step 1214, the database returns information that the record is empty. In step 1215, server B performs initialization of the shared memory.
[0128] Specifically, after server A is started, it reports its heartbeat to the disaster recovery management service StatusMgr for the first time. The service will assign a unique identifier to server A, such as VirtualSeq=1. After that, server A initializes shared memory and generates memory data, and serializes the memory data and saves it persistently to the database. When server A stops service, it needs to wait for the business transaction to end, and the memory data is automatically released. The released invalid memory data items need to be deleted from the database accordingly. All memory data items will be deleted from the database before the service is stopped. When the server is updated and upgraded, server B is started and reports its heartbeat to StatusMgr, which determines to replace server A, so it will also assign a unique identifier of VirtualSeq=1. Server B pulls the memory data record of server A from the database, but since server A is shut down normally and the record is empty, server B only needs to initialize the shared memory data and does not need to restore the memory data.
[0129] In some embodiments, see Fig.13 In step 1301, server A starts. In step 1302, server A reports a heartbeat to StatusMgr for the first time. In step 1303, StatusMgr returns a unique identifier (VirtualSeq=1) to server A. In step 1304, server A generates memory data. In step 1305, server A serializes the memory data and lands it in the database. In step 1306, server A becomes unavailable and cannot continue to report heartbeats. In step 1307, server B starts. In step 1308, server B reports a heartbeat to StatusMgr for the first time. In step 1309, StatusMgr determines that server B will replace server A. In step 1310, StatusMgr r returns a unique identifier (VirtualSeq=1) to server B. In step 1311, server B pulls the memory data record of server A. In step 1312, the database returns the information that server A has stopped service abnormally and the record is not empty. In step 1313, server B performs shared memory initialization and restores memory data.
[0130] Specifically, Server A is also started normally and saved in memory, and periodically reports heartbeats to StatugMgr, indicating that Server A is still running normally. At a certain moment, Server A crashes and becomes unavailable, reporting heartbeat interruptions, and StatusMgr senses that the service has been interrupted. At this point, Server B will be pulled up on another machine or container to replace Server A. After pulling the memory data records of Server A from the database, it will be deserialized and all memory data in the memory pool will be restored. At this point, the disaster recovery switch of Server A is completed.
[0131] In some embodiments, in some cases, the memory data records saved by the database may not be able to be deserialized and parsed through the higher version of the TDR definition, which means that these records cannot be restored to the shared memory. Or the interval is too long, and the memory data has expired and can be directly abandoned. However, such a situation cannot block the startup of the server. If the business permits, such records should be discarded as soon as possible. Therefore, it is necessary to provide corresponding solutions, such as configuring clear records. Then, after the server is started, the first thing to do is to clear all database records corresponding to some primary keys consisting of the service Busid and the memory pool, and then initialize the shared memory to allow the server to operate normally.
[0132] The embodiment of the present application timely and persistently saves the memory data of the team formation, hero ban / selection and other processes in the game. Therefore, during the game, if the server machine crashes and becomes unavailable or an abnormal situation causes the memory data to be cleaned and lost, it can be restored from the database, and most of the game information can be basically restored to continue the game, thereby improving the gaming experience and having higher fault tolerance for machine failures. The embodiment of the present application triggers the persistent storage of the database only when the memory data changes, greatly reducing the consumption of resources, and at the same time can shorten the time for the database to be saved, that is, reducing the time for user data to be rolled back. When a machine fails, it can automatically switch to other machines and restore the memory data from the database.
[0133] The following further describes an exemplary structure of the data processing device 255 provided in the embodiment of the present application implemented as a software module. In some embodiments, the data processing device is applied to a disaster recovery system, and the disaster recovery system includes a first server, a second server, and a database, such as Figure 2 As shown, the software modules stored in the data processing device 255 of the memory 250 may include: a first saving module 2551, which is used for the database to receive the database update operation of the first server to synchronize the memory data change event when a memory data change event occurs on the first server; wherein the database stores the full serialized data corresponding to the full memory data of the first server, and the database update operation is used to update at least part of the serialized data stored in the database; a first recovery module 2552, which is used for when the memory data of the first server is in an unavailable state, the database synchronizes the full serialized data corresponding to the first server to the second server, so that the second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
[0134] In some embodiments, the memory data change event includes any one of the following: new memory data is added to the memory data pool of the first server; original memory data in the memory data pool of the first server is modified; original memory data in the memory data pool of the first server is deleted.
[0135] In some embodiments, a database update operation is determined by the first server performing the following processing: obtaining target memory data; when the target memory data satisfies the update mechanism, determining the target memory data as the changed memory data involved in the memory data change event and performing the following processing: obtaining the serialization key of the corresponding changed memory data; when the memory data change event is deletion of memory data, and the serialized data corresponding to the deleted memory data is the only serialized data of the corresponding serialization key, removing the record of the corresponding serialization key from the database as a database update operation; when the memory data change event is not deletion of memory data, or the serialized data corresponding to the deleted memory data is not the only serialized data of the corresponding serialization key, obtaining the target serialized data of the corresponding serialization key, and replacing the serialized data of the corresponding serialization key in the database with the target serialized data to determine it as a database update operation.
[0136] In some embodiments, obtaining target serialization data corresponding to a serialization key includes: querying the full serialization data corresponding to the serialization key from a database based on the serialization key; performing mapping processing based on the data value of the changing memory data to obtain the serialization data of the changing memory data; updating the full serialization data corresponding to the serialization key based on the serialization data of the changing memory data to obtain the target serialization data corresponding to the serialization key.
[0137] In some embodiments, mapping processing is performed based on the data values of the changing memory data to obtain serialized data of the changing memory data, including: mapping processing is performed on the data values of the changing memory data based on the data representation language to obtain memory binary data corresponding to the changing memory data; the version number of the data representation language, the length of each memory binary data, and the memory binary data are combined to form serialized data corresponding to the changing memory data.
[0138] In some embodiments, obtaining a serialization key corresponding to the changing memory data includes: performing bucket mapping processing on the data key of the changing memory data to obtain a first identifier of the data bucket; and combining the second identifier of the service instance of the first server, the third identifier of the memory pool corresponding to the changing memory data, and the first identifier to form a serialization key for the changing memory data.
[0139] In some embodiments, bucket mapping processing is performed on the data key of the changing memory data to obtain a first identifier of the data bucket, including: when the data key of the changing memory data has historical bucket mapping data, obtaining the historical data bucket from the historical bucket mapping data, and using the identifier of the historical data bucket as the first identifier of the data bucket; when the data key of the changing memory data does not have historical bucket mapping data, obtaining any candidate data bucket from available candidate data buckets, and using the identifier of any candidate data bucket as the first identifier of the data bucket.
[0140] In some embodiments, bucket mapping is performed on the data key of the changed memory data to obtain a first identifier of the data bucket; the current version number of the data bucket and the current version number of the database are obtained; wherein the current version number is obtained by calling a function interface to perform version number update processing when a memory data change event is triggered; when the current version number of the data bucket is inconsistent with the current version number of the database, it is determined that the target memory data satisfies the update mechanism.
[0141] In some embodiments, after the database receives the database update operation of the first server to synchronize the memory data change event, the first saving module is also used to set the current version number of the database to the database version number of the data bucket; when the database version number of the data bucket is the same as the current version number of the data bucket, it is determined that the update of the database update operation is completed.
[0142] In some embodiments, the second server determines the full serialized data corresponding to the first server by performing the following processing: obtaining the second identifier of the service instance of the first server and the fourth identifier of each memory pool; combining the second identifier of the service instance of the first server and the fourth identifier of each memory pool to form a query key corresponding to each memory pool; and querying the full serialized data corresponding to each query key from the database.
[0143] In some embodiments, the disaster recovery system also includes a disaster recovery management module, and the disaster recovery management module and the database are both deployed on a disaster recovery management server, or the disaster recovery management module is deployed on a disaster recovery management server independent of the database; the second server is determined by the disaster recovery management module performing the following processing: when the first server is started for the first time, the disaster recovery management module receives the heartbeat message reported by the first server and returns the server identifier to the first server; when the second server is started for the first time, the disaster recovery management module receives the heartbeat message reported by the second server, the disaster recovery association module determines that the second server is a machine used to replace the first server, and returns the server identifier to the second server; wherein, the server identifier is used to trigger the second server to synchronize the full serialized data of the first server from the database.
[0144] The embodiment of the present application provides a computer program product, which includes computer executable instructions, and the computer executable instructions are stored in a computer readable storage medium. The processor of the electronic device reads the computer executable instructions from the computer readable storage medium, and the processor executes the computer executable instructions, so that the electronic device executes the data processing method described above in the embodiment of the present application.
[0145] The embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the processor will be caused to execute the data processing method provided by the embodiment of the present application, for example, Figure 3A The data processing method is shown.
[0146] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0147] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0148] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0149] As an example, the executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0150] To summarize, by serializing the data in the memory of the first server and updating the database in a timely manner for persistent storage, when the memory of the first server is unavailable, the lost memory data can be deserialized from the database and restored to the memory through the second server to continue providing services, reducing the impact of accidents such as server crashes and unavailability on user experience, making the server architecture more robust.
[0151] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A data processing method, characterized in that: The data processing method is applied to a disaster recovery system, the disaster recovery system includes a first server, a second server and a database, the database stores full serialized data corresponding to full memory data of the first server, and the method includes: When a memory data change event occurs on the first server, the database receives a database update operation of the first server to synchronize the memory data change event; The database update operation is used to update at least part of the serialized data stored in the database; When the memory data of the first server is unavailable, the database synchronizes the full serialized data corresponding to the first server to the second server so that The second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
2. The method according to claim 1, characterized in that The memory data change event includes any of the following: The memory data pool of the first server has newly added memory data; The original memory data in the memory data pool of the first server is modified; The original memory data in the memory data pool of the first server is deleted.
3. The method according to claim 1, characterized in that The database update operation is determined by the first server performing the following processing: Get the target memory data; When the target memory data satisfies the update mechanism, the target memory data is determined as the changed memory data involved in the memory data change event, and the following processing is performed: Obtain a serialization key corresponding to the changed memory data; When the memory data change event is deletion of memory data, and the serialized data corresponding to the deleted memory data is the only serialized data corresponding to the serialization key, removing the record corresponding to the serialization key from the database as the database update operation; When the memory data change event is not deletion of memory data, or the serialized data corresponding to the deleted memory data is not the only serialized data corresponding to the serialization key, the target serialized data corresponding to the serialization key is obtained, and the serialized data corresponding to the serialization key in the database is replaced with the target serialized data to determine the database update operation.
4. The method according to claim 3, characterized in that Obtain the target serialized data corresponding to the serialization key, including: Based on the serialization key, query the database for the full amount of serialized data corresponding to the serialization key; Perform mapping processing based on the data value of the changed memory data to obtain serialized data of the changed memory data; Based on the serialized data of the changed memory data, the full serialized data corresponding to the serialization key is updated to obtain the target serialized data corresponding to the serialization key.
5. The method according to claim 4, characterized in that The mapping process is performed based on the data value of the changed memory data to obtain serialized data of the changed memory data, including: Performing mapping processing based on a data representation language on the data value of the changed memory data to obtain memory binary data corresponding to the changed memory data; The version number of the data representation language, the length of each of the memory binary data, and the memory binary data are combined to form serialized data corresponding to the changed memory data.
6. The method according to claim 3, characterized in that The obtaining of a serialization key corresponding to the changed memory data includes: Performing bucket mapping processing on the data key of the changed memory data to obtain a first identifier of the data bucket; The second identifier of the service instance of the first server, the third identifier of the memory pool corresponding to the changed memory data, and the first identifier are combined to form a serialization key of the changed memory data.
7. The method according to claim 6, characterized in that The step of performing bucket mapping processing on the data key of the changed memory data to obtain a first identifier of the data bucket includes: When the data key of the changed memory data has historical bucket mapping data, obtaining the historical data bucket from the historical bucket mapping data, and using the identifier of the historical data bucket as the first identifier of the data bucket; When the data key of the changed memory data does not have historical bucket mapping data, any candidate data bucket is obtained from the available candidate data buckets, and the identifier of the any candidate data bucket is used as the first identifier of the data bucket.
8. The method according to claim 3, characterized in that The method further comprises: Performing bucket mapping processing on the data key of the changed memory data to obtain a first identifier of the data bucket; Obtaining the current version number of the data bucket and the current version number of the database; The current version number is obtained by calling a function interface to perform version number update processing when the memory data change event is triggered; When the current version number of the data bucket is inconsistent with the current version number of the database, it is determined that the changed memory data satisfies the update mechanism.
9. The method according to claim 8, characterized in that After the database receives the database update operation of synchronizing the memory data change event from the first server, the method further includes: Setting the current version number of the database to the database version number of the data bucket; When the database version number of the data bucket is the same as the current version number of the data bucket, it is determined that the update of the database update operation is completed.
10. The method according to claim 1, characterized in that The second server determines the full serialized data corresponding to the first server by performing the following processing: Obtaining a second identifier of the service instance of the first server and a fourth identifier of each of the memory pools; The second identifier of the service instance of the first server and the fourth identifier of each of the memory pools form a query key corresponding to each of the memory pools; The database is queried for the full amount of serialized data corresponding to each of the query keys.
11. The method according to claim 1, characterized in that: The disaster recovery system further includes a disaster recovery management module, wherein the disaster recovery management module and the database are both deployed on a disaster recovery management server, or the disaster recovery management module is deployed on a disaster recovery management server independent of the database; The second server is determined by the disaster recovery management module executing the following processing: When the first server is started for the first time, the disaster recovery management module receives the heartbeat message reported by the first server and returns the server identifier to the first server; When the second server is started for the first time, the disaster recovery management module receives a heartbeat message reported by the second server, the disaster recovery association module determines that the second server is a machine used to replace the first server, and returns the server identifier to the second server; The server identifier is used to trigger the second server to synchronize the full serialized data of the first server from the database.
12. A data processing method, characterized in that: The data processing method is applied to a disaster recovery system, the disaster recovery system includes a first server, a second server and a database, the database stores full serialized data corresponding to full memory data of the first server, and the method includes: When a memory data change event occurs on the first server, the first server performs a database update operation on the database so that When the memory data of the first server is in an unavailable state, the second server obtains the full serialized data of the first server from the database, and deserializes the full serialized data to obtain the full memory data corresponding to the first server; The database update operation is used to update at least part of the serialized data stored in the database.
13. A data processing device, characterized in that: The data processing device is applied to a disaster recovery system, the disaster recovery system includes a first server, a second server and a database, and the device includes: A first saving module, configured to cause the database to receive a database update operation of the first server to synchronize the memory data change event when a memory data change event occurs on the first server; The database stores full serialized data corresponding to the full memory data of the first server, and the database update operation is used to update at least part of the serialized data stored in the database; The first recovery module is used to synchronize the full serialized data corresponding to the first server to the second server by the database when the memory data of the first server is in an unavailable state, so that the second server deserializes the full serialized data to obtain the full memory data corresponding to the first server.
14. A data processing device, characterized in that: The data processing device is applied to a disaster recovery system, the disaster recovery system includes a first server, a second server and a database, the database stores full serialized data corresponding to the full memory data of the first server, and the device includes: The second storage module is used for, when a memory data change event occurs on the first server, the first server performs a database update operation on the database, so that When the memory data of the first server is in an unavailable state, the second server obtains the full serialized data of the first server from the database, and deserializes the full serialized data to obtain the full memory data corresponding to the first server; The database update operation is used to update at least part of the serialized data stored in the database.
15. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; A processor, configured to implement the data processing method of any one of claims 1 to 11 or claim 12 when executing the computer executable instructions stored in the memory.
16. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed by a processor, the data processing method according to any one of claims 1 to 11 or claim 12 is implemented.
17. A computer program product comprising computer executable instructions, characterized in that: When the computer executable instructions are executed by a processor, the data processing method according to any one of claims 1 to 11 or claim 12 is implemented.
