Disclosure of Invention
In view of the above problems, the present application provides a data processing method, a data processing apparatus, a data processing terminal device, and a data processing system.
The technical scheme adopted by the application is as follows:
the application provides a data processing method, which comprises the following steps:
the client side initiates a service operation request to the server side;
monitoring whether the processing result of the service operation request is abnormal or not;
if the abnormal condition is monitored, the data of the client side is synchronized to the server side, and the data in the server side is changed to be consistent with the data in the client side.
Optionally, the exception includes that a data consistency state between the client and the server is unknown or data inconsistency.
Optionally, the monitoring whether the processing result of the service operation request is abnormal specifically includes:
judging whether a response message of the server to the service operation request is received, wherein when the response message is received, the processing result of the service operation request is normal, otherwise, the processing result is abnormal;
or monitoring whether the data of the client is rolled back or not, wherein when the data of the client is rolled back, the processing result of the service operation request is abnormal;
or monitoring whether an abnormal response message sent by the server is received, and when the abnormal response message is received, the processing result of the service operation request is abnormal.
Optionally, if the monitoring is abnormal, synchronizing the data of the client to the server, so that the data in the server is changed to be consistent with the data in the client, specifically including:
if the abnormal condition is monitored, the data of the client side is synchronized to the server side according to the transaction log, and the data in the server side is changed to be consistent with the data in the client side.
Optionally, the transaction log at least includes service operation request initiation time, data before initiation of the service operation request, and data after initiation of the service operation request.
Optionally, if the monitoring is abnormal, synchronizing the data of the client to the server, so that the data in the server is changed to be consistent with the data in the client, including: and if the abnormal condition is monitored, immediately synchronizing the data of the client to the server, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the data processing method further includes:
and inquiring the transaction log regularly, and if the processing result of the business operation request is abnormal and the data of the client is not synchronized to the server, synchronizing the data of the client to the server.
Optionally, the periodically querying the transaction log includes: the transaction log is queried at first time intervals.
Optionally, the querying the transaction log at every first time interval includes: and inquiring the transaction log before a second time interval at every first time interval, wherein the second time interval is smaller than the first time interval.
The present application also provides a data processing apparatus, comprising:
the service operation request unit is used for the client to initiate a service operation request to the server;
the exception monitoring unit is used for monitoring whether the processing result of the service operation request is abnormal or not;
and the data synchronization unit is used for synchronizing the data of the client to the server if the abnormality is monitored, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the abnormality monitoring unit includes at least one of the following sub-units:
a response message judging subunit, configured to judge whether a response message to the service operation request from the server is received, where when the response message is received, a processing result of the service operation request is normal, and otherwise, the processing result is abnormal;
the data rollback monitoring subunit is configured to monitor whether data of the client is rolled back, and when the data of the client is rolled back, a processing result of the service operation request is abnormal;
and the abnormal response monitoring subunit is used for monitoring whether an abnormal response message sent by the server is received, and when the abnormal response message is received, the processing result of the service operation request is abnormal.
Optionally, the data synchronization unit includes a first data synchronization subunit, configured to synchronize, if an exception is monitored, the data of the client to the server according to the transaction log, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the data synchronization unit includes a second data synchronization subunit, configured to, if an anomaly is monitored, immediately synchronize the data of the client to the server, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the data processing apparatus further includes: and the timing data synchronization unit is used for regularly inquiring the transaction log, and synchronizing the data of the client to the server if the processing result of the service operation request is abnormal and the data of the client is not synchronized to the server.
Optionally, the timing data synchronization unit includes a first timing data synchronization subunit, configured to query a transaction log at intervals of a first time interval, and synchronize the data of the client to the server if it is queried that a processing result of the service operation request is abnormal and the data of the client is not synchronized to the server.
Optionally, the first timing data synchronization subunit includes a second timing data synchronization subunit, configured to query, every first time interval, a transaction log before a second time interval, where the second time interval is smaller than the first time interval, and synchronize, if it is queried that a processing result of the service operation request is abnormal and data of the client is not synchronized to the server, the data of the client is synchronized to the server.
The present application also provides a data processing terminal device, including:
a central processing unit;
an input/output unit;
a memory;
the memory stores the data processing method provided by the application; and after start-up can be operated according to the method described above.
The application also provides a data processing system which comprises a client and a server, wherein the client adopts the database data consistency method based on the client.
Compared with the prior art, the method has the following advantages:
the data processing method provided by the application comprises the steps that firstly, a client side initiates a service operation request to a server side; then monitoring whether the processing result of the service operation request is abnormal or not; if the abnormal condition is monitored, the data of the client side is synchronized to the server side, and the data in the server side is changed to be consistent with the data in the client side. Compared with the traditional database data consistency method for sensing abnormality and compensating by the server, the data processing method provided by the application changes the main party into actively sensing abnormality and compensating by the client, solves the problem that the client account information cannot be recovered after being deleted when abnormality occurs because the server account information in the account management system is less than the client account information, and further influences the data consistency, and simultaneously does not need the server to call back the client for each data change, and reduces the system resource overhead.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The present application provides a data processing method, a data processing apparatus, a data processing terminal device, and a data processing system, and the following describes embodiments of the present application in detail with reference to the accompanying drawings in order.
Please refer to fig. 1, which is a flowchart illustrating an embodiment of a data processing method according to the present application, the method includes the following steps:
step S101: the client side initiates a service operation request to the server side. In the step, the client initiates a service operation request to the database server.
Part of data in the client is synchronously stored in the database server, and in the embodiment provided by the application, the data synchronously stored in the client and the database server are referred to as common data information.
The data management mode is a mode which is common in member management in the prior art, in an embodiment provided by the present application, the data storage mode is used for member management of a comprehensive multi-application website, for example, a group website has multiple application platforms such as mailboxes, games, forums, blogs, malls, and the like under flags, so that a user can freely log in other application platforms under the group website even after registering on a certain application platform. The group member center is a database server, and the member management center of each application platform is a client.
Because the number of the clients is large, the member information categories are numerous, the data size is large, and all the information cannot be synchronously stored in the server, only account information such as member ID, login password, user name, bound mobile phone number, bound mailbox number and the like can be synchronously stored in the server in the form of public data information. For a certain member, all member information is stored on the client, and only public data information (such as account information) is synchronously stored on the server. It is easy to understand that the member information includes account information, and in addition, includes other information of the member on the client, such as the name of the character in the game, the type of the character, the grade of the character, the resource information, etc., which is not described herein again.
The above embodiment is only an implementation manner provided by the present application, and as a modification of the above embodiment, the application platform only stores common data information, such as account information of a member, and the like, in this case, the application platform is a database server, and all member information of the member is stored in an operation end of the member, i.e., a client, and for example, a chat record is only stored in the client and not stored in the database server.
It should be noted that, in the above two implementations, the application platform is a client in one embodiment, and is a server in another embodiment, depending on the application scenario. It is further stated that, in the present application, as long as in the corresponding application scenario, the party that only stores the public data information is the server, and the party that contains other related data information in addition to the public data information is the client.
The business operation comprises the operations of data addition, deletion, modification and the like. In an embodiment provided by the present application, the business operation includes operations such as adding, modifying, and deleting all or part of data of the member account information.
In a preferred embodiment provided by the present application, the client is a member center of a payer, the database server is a member center of a group, and the business operations include registering a new member, modifying transactions such as account and password, and synchronizing the modified member information. The public data information comprises a member ID, a login password, a bound mobile phone number and the like. The member information comprises the public data information, identity information, a balance treasure account, a money bringing account and the like.
Step S102: and monitoring whether the processing result of the service operation request is abnormal or not.
Through step S101, a service operation request has been initiated to the server, and then, it is necessary to monitor whether a processing result of the service operation request is abnormal.
The data consistency between the client and the server is guaranteed, so that the data consistency state between the client and the server is unknown or inconsistent, and the client and the server are regarded as abnormal. For the situation that a client initiates a service operation request to a server, data consistency requires that both the client and the server complete corresponding service operations, and the situation that the data operation cannot be completed due to an abnormality of any party affects the data consistency.
The exception includes data rollback of the client, that is, in the process of a service operation, the data of the client is not changed at last because the service operation is not completed due to equipment failure, abnormal power failure, error in client operation, operation overflow, error in an application program, violation of integrity limit, deadlock in a parallel transaction, and the like in the local area of the client, and at this time, the service operation corresponding to the server may have been completed, and the data of the corresponding server may have been changed, so that the data of the client and the data of the server are inconsistent.
In this case, an exception capture function, such as try-catch-final in JAVA language, may be used to monitor the processing result of the service operation request by the client and the server, and if it is monitored that the service operation is rolled back locally at the client and the server returns information that the processing of the service operation request is completed, it is indicated that the data of the client and the server are inconsistent and the data consistency is damaged.
It should be noted that, when the service operation is rolled back locally, if the service operation corresponding to the server is not completed because of an exception, the service operation of the server may have been executed partially, so that data therein may have changed, the data state has uncertainty, and the data of the client and the data of the server may not be consistent, and therefore, the data also belongs to an exception affecting data consistency. At this time, according to the type of the fault occurring at the server, the obtained monitoring results of the service operation condition of the server are also different, for example, when the service operation is not completed due to sudden power failure of the server, the server does not return the processing result of the service operation request, and the processing result of the service operation request by the server cannot be monitored at this time; when the service end does not complete the service operation due to the exceptions such as operation overflow, application program error and the like, corresponding exception response messages such as 'system exception' and the like are returned, and the exception response messages returned from the service end can be monitored.
In addition to the above situation of local business operation rollback, the exception also includes that the business operation is completed locally, but after the service end is not completed, that is, after the business operation request is initiated, the data operation of the business operation at the client is completed, and the data of the client has changed, whereas at the service end, the data operation is not completed due to equipment failure, abnormal power failure, operation overflow, application program error, violation of integrity limit, deadlock of parallel transaction, and the like, and the data of the service end is not changed or partially changed, resulting in inconsistency of the data of the client and the service end. At this time, according to the type of the fault occurring at the server, the obtained monitoring results of the service operation condition of the server are also different, for example, when the data operation is not completed due to sudden power failure of the server, the server does not return the processing result of the service operation request, and at this time, the processing result of the service operation request by the server cannot be monitored; and when the data operation is not completed due to the exceptions such as operation overflow, application program error and the like, the server side returns a corresponding exception response message, and at the moment, the pre-agreed exception response message returned from the server side can be monitored.
It should be noted that, in the foregoing embodiment, a try-catch-find exception capture function in the JAVA language is used as a monitoring means, and besides, various alternative implementation methods are still available in the prior art, which are not described herein again and are all within the protection scope of the present application.
Step S103: if the abnormal condition is monitored, the data of the client side is synchronized to the server side, and the data in the server side is changed to be consistent with the data in the client side.
Through step S102, whether the processing result of the service operation request is abnormal or not is monitored, and if the processing result of the service operation request is monitored to be abnormal, the data of the client is synchronized to the server, so that the data in the server is changed to be consistent with the data in the client.
In a traditional database system, a server is used as a main body for data recovery, a transaction log is recorded by the server, and when data is abnormal, the server recovers the data according to the transaction log. In the member management system, the database server only stores the public data information synchronously, only the public data information can be recovered during data recovery, and other member information on the client cannot be recovered, so that data errors or data loss are caused, which is a main problem to be solved by the data processing method provided by the application.
In an embodiment provided by the present application, the transaction log is recorded by the client, and data recovery is performed by taking the client as a main body. The transaction log at least comprises service operation initiation time, data before service operation initiation and data after service operation initiation, the client actively identifies scenes needing to be recovered, and synchronizes the data of the client to the server according to corresponding transaction records in the transaction log for scenes which really possibly cause data inconsistency. The service end provides a forward operation interface (such as an execute interface) and a reverse operation interface (such as a compensation interface) for each scene, the forward operation interface is used for providing service call of business operation, and the reverse operation interface is used for providing service call of the service end for data synchronization of the client end. All information of the members is stored in the client, so when the business operation is abnormal, the client can synchronize the data of the client to the server according to the transaction log, and the data in the server for transaction processing is changed into a state consistent with the data in the client by taking the client as a main body, wherein the data generally refers to common data information synchronously stored in the server and the client.
For example, in an initial state, the client and the server store first data synchronously, and the business operation is to change the first data into second data. If the client side rolls back the business operation due to the abnormality, the data of the client side is still the first data, the business operation of the server side is completed, and the first data of the server side is changed into the second data, the first data of the client side is synchronized to the server side, so that the second data in the server side is changed into the first data; and if the first data is changed into the second data after the transaction of the client is submitted and the first data is still the first data because the server is not changed due to the exception, the second data of the client is synchronized to the server, and the first data in the server is changed into the second data.
In order to reduce the data loss caused by the abnormality, the data of the client needs to be synchronized to the server in real time, so as to ensure that the data of the client and the data of the server are consistent as much as possible, that is, if the abnormality is monitored, the data of the client is immediately synchronized to the server, so that the data in the server is changed to be consistent with the data in the client.
In order to avoid that synchronization cannot be completed due to the fact that an exception occurs again in the process of synchronizing the data of the client to the server, in an embodiment provided by the present application, the method further includes a timing synchronization step of querying a transaction log at a timing, checking the transaction log, and synchronizing the data of the client to the server if the processing result of the service operation request is queried to be abnormal and the data of the client is not synchronized to the server. The timing query of the transaction log may be a query of the transaction log at a first time interval, so as to periodically synchronize the data of the client to the server, thereby reducing a loss caused by an abnormal operation of synchronizing the data of the client to the server in real time, for example, a transaction log is queried every 20 seconds. In order to ensure that the transaction log is not repeatedly queried for processing, generally, the transaction log before a second time interval is queried at a first time interval, where the second time interval is smaller than the first time interval, for example, 15 seconds before querying every 20 seconds.
By this, the data processing flow provided by the present application is completed through steps S101 to S103.
In a preferred embodiment provided by the present application, the client is a member center of a payer, the database server is a member center of a group, and the business operations include registering a new member, modifying an account password, synchronizing member information after modification, and the like. The public data information comprises a member ID, a login password, a bound mobile phone number and the like. The member information comprises the public data information, identity information, a balance treasure account, a money bringing account and the like. The table structure of the transaction log is as shown in table 1:
taking the service operation as an example of modifying a login password:
for the member ID20880001, the original password is password 123, and the password is modified to 456. At this time, the transaction log recorded by the client at least comprises: CHANGE _ PASSWORD, genekey 20880001 (userId stored), initial PASSWORD 123, and new PASSWORD 456.
If after a service operation request is initiated, a local exception occurs to cause service operation rollback, the password rollback on the client is 123, the password of the server may be 123 or may have been modified to 456, and data consistency cannot be guaranteed due to uncertainty, so that data of the client needs to be synchronized to the server, initial password of a corresponding member ID20880001 in a transaction log is queried to be 123, the data of the client is synchronized to the server, and the password on the server is covered by 123, so that it is ensured that the passwords of the client and the server are both 123.
If the local service operation is completed after the service operation request is initiated, the password on the client is modified to 456, and the server does not return the processing result of the service operation request when the service operation request is abnormal, it is not known whether the password on the server is modified at this time, and in order to ensure data consistency, the data of the client needs to be synchronized to the server, the new password of the corresponding member ID20880001 in the transaction log is inquired to 456 and synchronized to the server, the password on the server is covered by 456, and it is ensured that the passwords of the client and the server are both 456. If the exception of the server is not eliminated yet and the synchronization is unsuccessful, entering a timing synchronization step, and executing the operation again every 20 seconds until the data synchronization is completed.
Taking the service operation as a mobile phone number registration example:
for the member ID20880001, the bound mobile phone number 13800001111 becomes a sleeping account number because the member is not logged in for a long time. When the mobile phone number 13800001111 is easy to master, the new user uses the mobile phone number to register a new member ID 20880002, and in order to ensure the uniqueness of the member corresponding to the mobile phone number 13800001111, the new member 20880002 and the seller 20880001 need to be registered at the same time in the transaction.
If a service operation request is initiated, due to rolling back of abnormal local service operation, the client side sells a newly registered 20880002 account and recovers an old account number 20880001, the account number corresponding to the mobile phone number 13800001111 is 20880001, the server side logs off the old account number 20880001 and registers a new account number 20880002, and the account number corresponding to the mobile phone number 13800001111 is 20880002. Therefore, the data of the client needs to be synchronized to the server, and the service recovers members 20880001 by querying a sceneKey in a transaction log 13800001111|20880001 and synchronizing to the server, so that it is ensured that the members corresponding to the mobile phone numbers 13800001111 on the client and the server are 20880001.
If a service operation request is initiated, a local service operation is completed, an old account 20880001 is logged out and a new account 20880002 is registered successfully on a client, an account corresponding to a mobile phone number 13800001111 is 20880002, the server is abnormal and does not register the new account 20880002 successfully, the old account 20880001 is deleted or is not deleted, a mobile phone number 13800001111 may correspond to the old account 20880001 or may not be corresponding to the account, the server returns a pre-agreed abnormal response message "system abnormal", at this time, after the client monitors the abnormal response message, the data of the client needs to be synchronized to the server, a newid 13800001111|20880002 in a transaction log is queried and synchronized to the server, and the new account 20880002 is registered on the server and the old account 20880001 is deleted, so that members corresponding to the mobile phone numbers 13800001111 on the client and the server are 20880002.
These embodiments are intended to cover modifications of the embodiments described above, which do not depart from the spirit of the present application and which are intended to be within the scope of the present application.
In the foregoing embodiment, a data processing method is provided, and correspondingly, the present application further provides a data processing apparatus. Please refer to fig. 2, which is a schematic diagram of an embodiment of a data processing apparatus according to the present application. Since the apparatus embodiments are substantially similar to the method embodiments, they are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for relevant points. The device embodiments described below are merely illustrative.
A data processing apparatus of the present embodiment includes: a service operation request unit 101, configured to initiate a service operation request to a server by a client; an exception monitoring unit 102, configured to monitor whether a processing result of the service operation request is abnormal; and the data synchronization unit 103 is configured to synchronize the data of the client to the server if the abnormality is monitored, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the anomaly monitoring unit 102 includes at least one of the following sub-units:
a response message judging subunit, configured to judge whether a response message to the service operation request from the server is received, where when the response message is received, a processing result of the service operation request is normal, and otherwise, the processing result is abnormal;
the data rollback monitoring subunit is configured to monitor whether data of the client is rolled back, and when the data of the client is rolled back, a processing result of the service operation request is abnormal;
and the abnormal response monitoring subunit is used for monitoring whether an abnormal response message sent by the server is received, and when the abnormal response message is received, the processing result of the service operation request is abnormal.
Optionally, the data synchronization unit 103 includes a first data synchronization subunit, configured to synchronize, if an exception is monitored, the data of the client to the server according to the transaction log, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the data synchronization unit 103 includes a second data synchronization subunit, configured to, if an anomaly is monitored, immediately synchronize the data of the client to the server, so that the data in the server is changed to be consistent with the data in the client.
Optionally, the data processing apparatus further includes: and the timing data synchronization unit is used for regularly inquiring the transaction log, and synchronizing the data of the client to the server if the processing result of the service operation request is abnormal and the data of the client is not synchronized to the server.
Optionally, the timing data synchronization unit includes a first timing data synchronization subunit, configured to query a transaction log at intervals of a first time interval, and synchronize the data of the client to the server if it is queried that a processing result of the service operation request is abnormal and the data of the client is not synchronized to the server.
Optionally, the first timing data synchronization subunit includes a second timing data synchronization subunit, configured to query, every first time interval, a transaction log before a second time interval, where the second time interval is smaller than the first time interval, and synchronize, if it is queried that a processing result of the service operation request is abnormal and data of the client is not synchronized to the server, the data of the client is synchronized to the server.
The foregoing is an embodiment of a data processing apparatus provided in the present application.
The present application also provides a data processing terminal device, including:
a central processing unit;
an input/output unit;
a memory;
the memory stores the data processing method provided by the application; and after start-up can be operated according to the method described above.
For example, the terminal device is a computer, the computer and a remote server synchronously store common data information, the computer initiates a service operation request to the remote server, and monitors whether processing results of the computer and the remote server for the service operation request are abnormal; if the abnormality is monitored, synchronizing the data in the computer to the remote server, and changing the data in the remote server to be consistent with the data in the computer. Since the data processing terminal device uses the data processing method, the related points refer to the description of the embodiment of the data processing method, and are not described herein again.
The invention further provides a data processing system which comprises a client and a server, wherein the client adopts the data processing method provided by the application.
For example, the client is a computer, public data information is synchronously stored in the computer and the server, the computer initiates an transaction to the server, and monitors whether the processing results of the computer and the server to the service operation request are abnormal or not; if the abnormality is monitored, synchronizing the data in the computer to the remote server, and changing the data in the remote server to be consistent with the data in the computer.
Since the data processing system uses the data processing method, please refer to the description of the embodiment of the data processing method for related parts, which is not described herein again.
Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application, and those skilled in the art can make variations and modifications without departing from the spirit and scope of the present application, therefore, the scope of the present application should be determined by the claims that follow.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
1. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
2. As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.