Movatterモバイル変換


[0]ホーム

URL:


CN111367995B - Data synchronization method and device, electronic equipment and storage medium based on service lock - Google Patents

Data synchronization method and device, electronic equipment and storage medium based on service lock
Download PDF

Info

Publication number
CN111367995B
CN111367995BCN202010085248.8ACN202010085248ACN111367995BCN 111367995 BCN111367995 BCN 111367995BCN 202010085248 ACN202010085248 ACN 202010085248ACN 111367995 BCN111367995 BCN 111367995B
Authority
CN
China
Prior art keywords
task
data
synchronization
service lock
lock
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010085248.8A
Other languages
Chinese (zh)
Other versions
CN111367995A (en
Inventor
魏志军
张萌萌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co LtdfiledCriticalBeijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010085248.8ApriorityCriticalpatent/CN111367995B/en
Publication of CN111367995ApublicationCriticalpatent/CN111367995A/en
Application grantedgrantedCritical
Publication of CN111367995BpublicationCriticalpatent/CN111367995B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本申请公开了基于服务锁的数据同步方法及装置、电子设备与存储介质,涉及数据存储技术领域。具体实现方案为:基于服务锁的数据同步方法,其特征在于,方法适用于处理多写入源多数据库的数据存储系统中的数据同步,包括:基于写入源的数据写入请求,为写入源配置数据表的服务锁;数据写入请求中携带写入源的标识和数据表的标识;解析数据写入请求对应的同步任务;执行同步任务,使得各数据库中存储的数据表的数据一致。本申请能够提供一套适用于多写入源多数据库的数据存储系统中的完整的数据同步机制,能够在数据写入时配置的服务锁的保护下,执行数据同步操作,保证数据同步操作的安全性和数据的准确性,以及数据的一致性。

The application discloses a data synchronization method and device based on a service lock, electronic equipment and a storage medium, and relates to the technical field of data storage. The specific implementation scheme is: a data synchronization method based on a service lock, which is characterized in that the method is suitable for processing data synchronization in a data storage system with multiple write sources and multiple databases, including: based on a write source data write request, configuring a service lock for a data table for the write source; the data write request carries the identifier of the write source and the identifier of the data table; parsing the synchronization task corresponding to the data write request; executing the synchronization task, so that the data in the data tables stored in each database is consistent. This application can provide a set of complete data synchronization mechanism applicable to data storage systems with multiple writing sources and multiple databases. Under the protection of the service lock configured when data is written, data synchronization operations can be performed to ensure the security of data synchronization operations, data accuracy, and data consistency.

Description

Data synchronization method and device based on service lock, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a data synchronization method and apparatus based on service locks, an electronic device, and a storage medium.
Background
At present, the data synchronization scenes are usually data synchronization among database clusters, data synchronization among databases and caches, and the like, and the data format is usually fixed under the scenes, so that the data synchronization scheme is simpler to realize. For databases with different formats, such as a scheme of data synchronization between a relational database and a NoSQL database, in the prior art, data can be specifically derived from the relational database in a manual mode, and converted into a storage format of the NoSQL database by using a tool, a new index is created in the NoSQL database, and the converted data is imported into the new index.
In a multi-write source multi-database application scenario, for example, in some data storage system, there are at least two types of databases, such as relational databases and NoSQL databases. The NoSQL database is used as a data query engine to provide data query service. Under the scene, as a plurality of writing sources exist, a plurality of databases and the data synchronization process is realized by adopting the existing manual mode, the automation degree is low, and the labor cost is high; the accuracy of the data is completely dependent on manual operation, and the reliability is low; moreover, the synchronization process analysis is too independent and does not consider the limitation of multiple write sources, so it is highly desirable to provide a data synchronization scheme in a data storage system with multiple write sources and multiple databases.
Disclosure of Invention
In order to solve the technical problems, the application provides a service lock-based data synchronization method and device, electronic equipment and storage medium, which are used for providing a data synchronization scheme in a data storage system with multiple write sources and multiple databases.
In one aspect, the present application provides a service lock-based data synchronization method, the method being suitable for processing data synchronization in a data storage system of a multi-write source multi-database, comprising:
configuring a service lock of a data table for a writing source based on a data writing request of the writing source; the data writing request carries the identification of the writing source and the identification of the data table;
analyzing the synchronous task corresponding to the data writing request;
and executing the synchronization task to make the data of the data tables stored in the databases consistent.
Further alternatively, in the method as described above, configuring a service lock of a data table for the write source includes: and configuring the information of the service lock, wherein the information of the service lock comprises the identification of the writing source, the identification of the data table and the state of the service lock, and the state of the service lock is set to be occupied.
Further optionally, in the method as described above, analyzing the synchronization task corresponding to the data writing request includes: analyzing the synchronous task corresponding to the data writing request, and arranging and generating a task chain, wherein the task chain at least sequentially comprises: creating a synchronous task, executing the synchronous task and deleting the synchronous task;
or after the creation of the synchronization task in the task chain and before the execution of the synchronization task, a data writing task is further included.
Further optionally, in the method as described above, after configuring a service lock of the data table for the write source, before parsing a synchronization task corresponding to the data write request, the method further includes:
creating a task corresponding to the data writing request, and storing a task identifier and a corresponding task state in a task management database; the task state is unexecuted;
correspondingly, before analyzing the synchronous task corresponding to the data writing request, the method further comprises the following steps:
and acquiring the unexecuted task from the task management database.
Further optionally, in the method as described above, performing the synchronization task includes:
scheduling a plurality of task executors on a main node server to execute each task in the task chain respectively;
Modifying the state of the corresponding task in the task management database into execution;
before the task executors on the dispatching master node server execute the tasks in the task chain respectively, the method further comprises the following steps:
each of the plurality of servers controlling the deployment detects whether itself is a master node server.
Further alternatively, in the method as described above, controlling each of the plurality of deployed servers to detect whether itself is a master node server includes:
controlling each server to send a main selection request carrying a node identifier of the server and the task identifier to a main selection module; and detecting whether other servers execute the tasks corresponding to the task identifiers by the main selection module, if not, setting the servers as main node servers, and feeding back detection results to the servers.
Further optionally, in the method as described above, after performing the synchronization task, the method further includes:
modifying the state of the corresponding task in the task management database to be finished;
and modifying the state of the service lock in the configured information of the service lock to be released.
In another aspect, the present application further provides a service lock-based data synchronization apparatus, the apparatus being adapted to process data synchronization in a data storage system of a multi-write source multi-database, including:
the lock service component is used for configuring a service lock of a data table for a writing source based on a data writing request of the writing source; the data writing request carries the identification of the writing source and the identification of the data table;
the task scheduler is used for analyzing the synchronous task corresponding to the data writing request;
and the task executor is used for executing the synchronous task so that the data of the data tables stored in the databases are consistent.
In yet another aspect, the present application further provides an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the preceding claims.
In yet another aspect, the present application also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of any one of the above.
One embodiment of the above application has the following advantages or benefits: configuring a service lock of a data table for a write source by a data write request based on the write source; the data writing request carries the identification of a writing source and the identification of a data table; analyzing a synchronous task corresponding to the data writing request; the synchronization task is executed, so that the data of the data tables stored in each database are consistent, a complete data synchronization mechanism suitable for a data storage system of multiple write-in sources and multiple databases can be provided, the data synchronization operation can be executed under the protection of a service lock configured during data writing, the safety of the data synchronization operation and the accuracy of the data are ensured, and the consistency of the data among the databases can be effectively ensured.
Furthermore, the method and the device can also adopt the task management database to comprehensively manage all the tasks, and under the dispatching of the task dispatcher, the main node server selects and executes the unexecuted tasks, so that the execution safety of the synchronous tasks and the accuracy of data can be effectively ensured.
Furthermore, the method and the device can update the state of the task in task execution, avoid the task from being executed for multiple times, and ensure the accuracy of data synchronization and the consistency of data. Meanwhile, the state of the service lock can be updated in time, and the safety of data in the system can be effectively ensured.
Other effects of the above alternative will be described below in connection with specific embodiments.
Drawings
The drawings are for better understanding of the present solution and do not constitute a limitation of the present application. Wherein:
FIG. 1 is a schematic diagram according to a first embodiment of the present application;
FIG. 2 is a diagram of an application architecture of a data storage system with multiple write sources and multiple databases according to the present embodiment;
FIG. 3 is a schematic view of a second embodiment of the present application;
FIG. 4 is an application architecture diagram of the embodiment of FIG. 3;
FIG. 5 is a schematic diagram according to a third embodiment of the present application;
fig. 6 is a block diagram of an electronic device for implementing a service lock based data synchronization method of an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present application to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
FIG. 1 is a schematic diagram of a first embodiment of the present application, and as shown in FIG. 1, a service lock-based data synchronization method is described in detail, and the method is applicable to data synchronization in a data storage system for processing multiple write sources and multiple databases, and may specifically include the following steps:
s101, configuring a service lock of a data table for a writing source based on a data writing request of the writing source; the data writing request carries the identification of a writing source and the identification of a data table;
the execution main body of the service lock-based data synchronization method of the embodiment may be a service lock-based data synchronization device, where the service lock-based data synchronization device may be disposed in a multi-write source multi-database data storage system, and is configured to establish a corresponding service lock when writing data into a storage database from a write source, and further implement data synchronization between databases based on the service lock, so as to ensure accuracy and consistency of data in the data storage system.
For example, fig. 2 is an application architecture diagram of a data storage system with multiple write sources and multiple databases according to the present embodiment. As shown in fig. 2, taking an example of two databases including a and B, wherein the database a is responsible for data writing operation, the database B is responsible for data reading operation, and the data of the database B is synchronized by the data in the database a. C and D are two sources of data writing, where C may be a user and D represents a data administrator.
When the user C modifies a piece of data in the database a, the data manager D modifies the same data before the data in the database a is synchronized to the database B, and at this time, after the data synchronization is completed, the modification made by the user C is covered, and it cannot be known whether the operation of the user C is successful. Therefore, in the context of multiple write sources and multiple databases, it is desirable to provide a service lock-based data synchronization mechanism to ensure data consistency and accuracy.
The embodiment shown in fig. 2 uses two writing sources as an example, and in practical application, there may be other more users writing to the database a. In addition, optionally, other databases may be further included in the present embodiment, and during synchronization, the data in database a may be used to synchronize the data in other databases.
Specifically, the writing source in this embodiment may be a data administrator, that is, an administrator of the data storage system, or may be a general user. When in use, a user can log in the client of the data storage system to initiate a data writing request, for example, the data writing request can carry an identifier of a writing source and an identifier of a data table for requesting data writing. Wherein the identification of the write source is used to uniquely identify the write source. For example, if there are multiple data administrators in the system, the corresponding data Administrator identifiers may be respectively an administtrator 1, an administtrator 2, and the User identifiers may be a User1, a User2, and the like. The identification of the data table in this embodiment may specifically be the name of the data table.
The data write request of this embodiment may be a request initiated by way of an interface call, for example, the request may be a hypertext transfer protocol (hypertext transfer protocol; http) request.
For example, the data writing request in this embodiment may also be considered as a locking request initiated by a writing source, where the writing source initiates the request, and is used to request the data processing apparatus to configure a service lock of the data table for the writing source first, so that the writing source occupies the operation right of the data table, and can perform a data writing operation on the data table. However, since the data manager and any user can perform data writing operation on the data table, the data synchronizer based on the service lock can detect whether the operation right of the data table is occupied by the manager or other users after receiving the request; if the operation right is occupied, the operation right of the data table is fed back to the writing source, and the operation is ended. Otherwise, if not, a service lock of the data table can be configured for the writing source, so that a data maintenance period can be entered, the writing source can occupy the operation right of the data table, and the data table can be operated.
For example, in this embodiment, a piece of service lock information may be directly configured, so as to configure the service lock of the data table for the write source. The information of the service lock includes the identification of the write source, the identification of the data table, and the status of the service lock, which needs to be set to be occupied because the service lock is configured for the write source. For each unoccupied data table, the service lock-based data synchronization device may configure service lock information for the write source that first requests the operation right of the data table in the above manner, and store the information, which is equivalent to allocating a service lock for the write source. In practical applications, the information of all service locks can be stored one by one in a list manner.
Further, the information of the service lock may further include information such as an establishment time of the service lock, so that when the service lock is forgotten and is not released in time, an expiration time period may be set, and when the service lock occupies a time period exceeding the expiration time period, the service lock may be forcedly released. In this embodiment, the state of the service lock may be set to released or released according to different scenes.
Further alternatively, if the write source is a data manager, since the data manager usually modifies a larger amount of data, the write time is longer, and the synchronization time is longer, at this time, in addition to configuring the service lock information, a locking operation needs to be separately performed on the data table in the storage database, so as to ensure the security and accuracy of the data when the data table is subjected to the data write operation by the data manager. While multiple write sources are common users, it is contemplated that common users typically modify a smaller amount of data without having to perform a locking operation on the data table separately in the storage database. Only by configuring information of one service lock.
S102, analyzing a synchronous task corresponding to a data writing request;
s103, executing a synchronization task to make the data of the data tables stored in the databases consistent.
Under the limitation of the step S101, when the writing source writes data, after the service lock is configured for the data table to be written by the writing source, the data writing operation can be executed.
Since the data storage system of the present embodiment includes a plurality of databases, in order to ensure data consistency among the databases, in the present embodiment, it is necessary to perform data synchronization after data writing. Specifically, the synchronous task corresponding to the data writing request can be analyzed first, and a corresponding task chain can be arranged and generated.
In this embodiment, in order to ensure the data writing effect, different ways may be set for writing by the user and the data administrator, for example, writing by the user involves a small amount of data, and writing by the user may be set to writing in time; the writing of the data manager involves large data volume, and the writing of the data manager can be non-timely writing.
For timely writing of a user, data writing operation information can be directly carried in a data writing request; for non-timely writing by a data manager, the data writing operation information may not be carried in the data writing request. At this time, the synchronous task corresponding to the data writing request is analyzed, and the generated task chain can be arranged to sequentially comprise the steps of creating the synchronous task, writing the data into the task, executing the synchronous task and deleting the synchronous task. The data writing operation information of the present embodiment includes, but is not limited to, writing, updating, deleting of data.
In the above embodiment, the tasks in the two cases of parsing are only two examples, and in the actual scenario, other more tasks may be parsed according to the actual data writing request, which is not described in detail herein.
The data manager applies for locking firstly, after the locking is successful, the data manager performs data writing operation firstly, after the writing operation is finished, the data manager can apply for releasing the lock firstly, and trigger the synchronous task to start when the service lock is released in the storage database, but the state of the service lock in the information of the service lock configured at the moment is still in the release state, at the moment, the data table is still in a data maintenance period, and other users or the data manager cannot occupy the operation right of the data table. At this time, since the data writing operation is completed, the synchronous task corresponding to the data writing request is parsed, and the task chain generated by arranging may sequentially include creating the synchronous task, executing the synchronous task, and deleting the synchronous task.
Finally, executing the synchronous task, for example, executing each task in the task chain generated by arranging after analysis, in this embodiment, a plurality of task executors may be adopted to execute each task in the task chain respectively. In this embodiment, the synchronization task is synchronization with the data table as granularity, that is, synchronizing the whole data table in which data writing occurs in the storage database to other databases, so that the data of the data tables stored in the databases are consistent.
According to the service lock-based data synchronization method, a service lock of a data table is configured for a writing source through a data writing request based on the writing source; the data writing request carries the identification of a writing source and the identification of a data table; analyzing a synchronous task corresponding to the data writing request; the synchronization task is executed, so that the data of the data tables stored in each database are consistent, a complete data synchronization mechanism suitable for a data storage system of multiple write-in sources and multiple databases can be provided, the data synchronization operation can be executed under the protection of a service lock configured during data writing, the safety of the data synchronization operation and the accuracy of the data are ensured, and the consistency of the data among the databases can be effectively ensured.
Fig. 3 is a schematic view of a second embodiment of the present application. As shown in fig. 3, the present embodiment describes in detail a data synchronization scheme in a data storage system of a multi-write source multi-database. As shown in fig. 3, the service lock-based data synchronization method of the present embodiment may specifically include the following steps:
s301, a lock service component in a service lock-based data synchronization device receives a data writing request of a writing source; the data writing request carries an identification of a writing source and an identification of a data table;
s302, the lock service component detects whether the operation right of the data table is occupied; if the operation right of the data table is already occupied, step S303 is executed; otherwise, executing step S304;
specifically, in this embodiment, information of each service lock in the storage database is recorded in the lock service component, and each piece of information of the service lock may include an identifier of a writing source, that is, an identifier of a person applying for the service lock, a name of a data table, and a state of the service lock, for example, the state of the service lock may include: occupancy, release, and released. The lock service component can detect whether the operation right of the data table is occupied according to the recorded information of all service locks.
In practical applications, for a released service lock, only a certain length of time may be reserved in the lock service component, and the information of the corresponding service lock may be deleted.
S303, the lock service component returns the message that the operation right of the data table is occupied to the writing source; and (5) ending.
S304, the lock service component configures information of the service lock;
s305, the task dispatcher creates a synchronous task corresponding to the data writing request, and stores the task identification and the corresponding task state in a task management database;
the task created at this time is not yet executed, and the task state is set to be unexecuted correspondingly. In subsequent operations, the task state may also be in execution or already executed.
All data synchronization tasks of the data storage system may be recorded in the task management database one by one.
S306, the task dispatcher acquires unexecuted synchronous tasks from the task management database; analyzing the data writing request corresponding to the task to obtain a corresponding task chain;
for example, if the user is a write source, the corresponding task chain is to create a sync task, write data to a task, execute a sync task, and delete a sync task. If the data manager is a writing source, the corresponding task chain is to create a synchronous task, execute the synchronous task and delete the synchronous task.
S307, the task scheduler schedules a plurality of task executors on the main node server to execute each task in the task chain respectively;
s308, the task dispatcher modifies the state of the corresponding task in the task management database into execution;
first, the task scheduler needs to select a master node server that performs the task from a plurality of servers deployed. The specific operation process can be as follows: the task scheduler controls each of the plurality of deployed servers to detect whether the server itself is a master node server. When the detection is carried out, each server can send a main selection request carrying the node identification and the task identification of the server to the main selection module; and detecting whether other servers execute tasks corresponding to the task identifiers by the main selection module, if not, setting the servers as the main node servers, and feeding back detection results to the servers. Meanwhile, the main selection module also records the identification of the main node server and the identification of the task to be executed in the main selection module.
It should be noted that, a set of task executors on multiple servers are service instances where one service is deployed on different servers, in the task execution process, it is possible that multiple sets of task executors can all obtain unexecuted tasks, but each server can ignore tasks and not execute tasks if determining itself to be a non-master node server through detection of a master module; if the server is the master node server, the task of data synchronization is performed. Naturally, if there is only one server, all the servers need to execute the detection, and the detection of the master node is not needed.
In the process of executing the synchronous task, the task executor can acquire the data in the data table from a source database (such as a storage database); then converting the data into a data format which is adapted to the target database through a data adapter; further, the data converted by the data adapter is stored in the target database, so that the data in the data table in the target data are synchronously updated. That is, in the synchronization process, the data table is used as granularity synchronization.
S309, after the task scheduler detects that the execution of the task executors on the main node server is finished, modifying the state of the corresponding task in the task management database to be finished;
s310, a task dispatcher feeds back that the task of the lock service assembly is executed;
s311, the lock service component modifies the state of the service lock in the information of the configured service lock to released.
The process of this embodiment is emphasized on the execution of the synchronization task based on the data of the service lock. The set-up and release process of the service lock of this embodiment may also vary from one write source to another.
For example, the writing source is a user, referring to the technical solution of this embodiment, step S301 may be considered as a locking request applied while writing data, and step S304 is a configuration of the service lock, where a separate locking operation is not required to be performed in the storage database. According to the steps of the present embodiment, writing of data is completed in the process of executing the synchronization task.
If the write source is a data management source, as in the above embodiment, there is no data write operation in the synchronization task. After the service lock is configured in step S304, before step S305, the following steps may be further included:
(a) Performing a locking operation on the data table in a storage database; and returns a successful locking message to the data manager;
(b) Performing a data write operation in the storage database based on a data write operation performed by the data manager;
(c) After the data writing operation of the data manager is completed, a lock releasing request is initiated; the lock release request may include an identification of the data manager and a name of the data table;
(d) The lock service component receives a lock release request of a data manager and detects whether the data table meets a release condition; if yes, executing step (e); otherwise, returning to the data manager, and ending if the release condition is not satisfied.
In this embodiment, detecting whether the data table meets the release condition may specifically include detecting whether a service lock of the data table exists, expires, and is occupied by a current data administrator; if the service lock of the data table does exist and is not expired and is occupied by the current data manager, determining that a release condition is met; otherwise, if the service lock of the data table does not exist, or the service lock of the data table has expired, or the service lock is not occupied by the current data manager, the release condition is not satisfied.
Specifically, if the release condition is not satisfied, error information may be further returned to the data administrator, for example, the error information may include, but is not limited to, "operation authority of the data table is not obtained", "operation authority of the data table is expired", "request parameter is wrong", and the like.
(e) The lock service component requests the task scheduler to release the lock for the data table;
(f) The task scheduler releases the service lock of the data table configured by the data manager in the storage database;
(g) The lock service component modifies the state of the service lock in the information of the configured service lock to be in release; and returning the message in service lock release to the data manager; the synchronization task may then be performed starting from step S305.
Further, after step S310, the lock service component may also feed back the results to the write source. If the writing source is a user, the completion of data writing can be directly fed back to the user due to the link established by the previous request. If the write source is a data manager, the previously established request link is released, and the service component needs to inform the data manager that the service lock is released. For example, the notification service component may notify the data manager of the released completed message by way of a short message or mail.
Further, in this embodiment, in order to avoid a situation that a data administrator forgets to apply for releasing a lock after importing data is completed, and the data table cannot be released, the lock service component sets an expiration time for each service lock, and may further set a timing detection service component to periodically check the service lock, and check whether the service lock is overtime, that is, periodically detect whether the occupation time of the configured service lock exceeds a preset time length; when the occupied time of the service lock exceeds the preset time length, the service lock is considered to be out of date, the service lock is notified to the lock service component to automatically release the service lock, and the service lock is notified to the task dispatcher to release the service lock in the storage database by the lock service component; and notifies the data manager of the lock release message through the notification service. When the service locks are configured, the lock service component records the occupation starting time of each service lock and can be recorded in the information of the service lock. The preset time period may be set according to actual experience.
By adopting the technical scheme, the data synchronization method based on the service lock can provide a complete data synchronization mechanism suitable for the data storage system of multiple write-in sources and multiple databases, can execute data synchronization operation under the protection of the service lock configured during data writing, ensures the safety of the data synchronization operation and the accuracy of the data, and can also effectively ensure the consistency of the data among the databases.
In addition, in the embodiment, the task management database is adopted to comprehensively manage all tasks, and under the dispatching of the task dispatcher, the main node server selects and executes the unexecuted tasks, so that the execution safety of the synchronous tasks and the accuracy of data can be effectively ensured.
Furthermore, in the embodiment, the state of the task can be updated in the task execution process, so that the task is prevented from being executed for multiple times, and the accuracy of data synchronization and the consistency of data are ensured. Meanwhile, the state of the service lock can be updated in time, and the safety of data in the system can be effectively ensured.
Fig. 4 is an application architecture diagram of the embodiment shown in fig. 3. As shown in fig. 4, in this embodiment, a lock service component, a task scheduler, a task executor, a data adapter, a timing detection service component, and the like are included in the service lock-based data synchronization apparatus. The present embodiment includes four task executors, for example: creating a task executor (Create Task Executor), updating a data executor (Update Data Executor), synchronizing a task executor (SyncTask Executor), deleting a task executor (Delete Task Executor). And the embodiment shown in fig. 4 is exemplified by two databases including a source database and a target database. The data processing method according to the embodiment shown in fig. 3 may implement corresponding data processing in the application architecture shown in fig. 4.
FIG. 5 is a schematic diagram according to a third embodiment of the present application; as shown in fig. 5, the service lock-based data synchronization apparatus 500 of the present embodiment is suitable for processing data synchronization in a data storage system of multiple write sources and multiple databases, and includes:
the lock service component 501 is configured to configure a service lock of a data table for a write source based on a data write request of the write source; the data writing request carries the identification of a writing source and the identification of a data table;
the task scheduler 502 is configured to parse a synchronous task corresponding to the data writing request;
the task executor 503 is configured to execute a synchronization task so that data of the data tables stored in the respective databases are identical.
Further, in the service lock-based data synchronization apparatus 500 of the present embodiment, a lock service component 501 is configured to configure service lock information, where the service lock information includes an identifier of a writing source, an identifier of a data table, and a status of the service lock, and the status of the service lock is set to be occupied.
Further, in the service lock-based data synchronization device 500 of the present embodiment, the task scheduler 502 is configured to parse a synchronization task corresponding to a data writing request, and schedule and generate a task chain, where the task chain at least sequentially includes: creating a synchronous task, executing the synchronous task and deleting the synchronous task;
Or after the synchronous task is created in the task chain and before the synchronous task is executed, a data writing task is further included.
Further, in the service lock-based data synchronization device 500 of the present embodiment, the task scheduler 502 is further configured to:
creating a task corresponding to the data writing request, and storing a task identifier and a corresponding task state in a task management database; the task state is unexecuted;
the task scheduler 502 is further configured to obtain an unexecuted task from the task management database.
Further, in the service lock-based data synchronization device 500 of the present embodiment, the task scheduler 502 is specifically configured to:
scheduling a plurality of task executors 503 on the master node server to execute each task in the task chain, respectively;
modifying the state of the corresponding task in the task management database into execution;
the task scheduler 502 is further configured to control each of the plurality of deployed servers to detect whether the server is itself a master node server.
Further, in the service lock-based data synchronization apparatus 500 of the present embodiment, the task scheduler 502 is further configured to:
controlling each server to send a main selection request carrying a node identifier and a task identifier of the server to a main selection module; and detecting whether other servers execute tasks corresponding to the task identifiers by the main selection module, if not, setting the servers as the main node servers, and feeding back detection results to the servers.
Further, in the service lock-based data synchronization device 500 of the present embodiment, the task executor 503 is further configured to modify the state of the corresponding task in the task management database to be executed; in particular by the task executor 503 which performs the delete sync task.
The lock service component 501 is also operable to modify the status of a service lock in the information of a configured service lock to released.
Further optionally, the service lock-based data synchronization device 500 of the present embodiment may further include the timing detection service component shown in fig. 4, and details of the foregoing description of the embodiment shown in fig. 4 may be referred to, which is not described herein.
The implementation principle and technical effects of the service lock-based data synchronization device 500 in this embodiment for implementing the service lock-based data synchronization process by using the above components are the same as those of the related method embodiments, and detailed descriptions of the related method embodiments may be referred to and will not be repeated here.
According to embodiments of the present application, an electronic device and a readable storage medium are also provided.
As shown in fig. 6, a block diagram of an electronic device implementing a service lock-based data synchronization method according to an embodiment of the present application is shown. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the application described and/or claimed herein.
As shown in fig. 6, the electronic device includes: one or more processors 601, memory 602, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 601 is illustrated in fig. 6.
Memory 602 is a non-transitory computer-readable storage medium provided herein. Wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the service lock based data synchronization method provided herein. The non-transitory computer readable storage medium of the present application stores computer instructions for causing a computer to perform the service lock based data synchronization method provided by the present application.
The memory 602 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules (e.g., the components shown in fig. 5) corresponding to the service lock-based data synchronization method in the embodiments of the present application. The processor 601 executes various functional applications of the server and data processing by running non-transitory software programs, instructions and modules stored in the memory 602, i.e., implements the service lock-based data synchronization method in the above-described method embodiments.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for a function; the storage data area may store data created by the use of an electronic device implementing a service lock-based data synchronization method, and the like. In addition, the memory 602 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 602 optionally includes memory remotely located with respect to processor 601, which may be connected via a network to an electronic device implementing a service lock based data synchronization method. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device implementing the service lock-based data synchronization method may further include: an input device 603 and an output device 604. The processor 601, memory 602, input device 603 and output device 604 may be connected by a bus or otherwise, for example in fig. 6.
The input device 603 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device implementing the service lock based data synchronization method, such as a touch screen, keypad, mouse, trackpad, touch pad, pointer stick, one or more mouse buttons, trackball, joystick, etc. input devices. The output means 604 may include a display device, auxiliary lighting means (e.g., LEDs), tactile feedback means (e.g., vibration motors), and the like. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASIC (application specific integrated circuit), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computing programs (also referred to as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme of the embodiment of the application, the service lock of the data table is configured for the writing source through the data writing request based on the writing source; the data writing request carries the identification of a writing source and the identification of a data table; analyzing a synchronous task corresponding to the data writing request; the synchronization task is executed, so that the data of the data tables stored in each database are consistent, a complete data synchronization mechanism suitable for a data storage system of multiple write-in sources and multiple databases can be provided, the data synchronization operation can be executed under the protection of a service lock configured during data writing, the safety of the data synchronization operation and the accuracy of the data are ensured, and the consistency of the data among the databases can be effectively ensured.
According to the technical scheme of the embodiment of the application, the task management database can be used for comprehensively managing all tasks, and under the dispatching of the task dispatcher, the main node server selects and executes the unexecuted tasks, so that the execution safety of the synchronous tasks and the accuracy of data can be effectively ensured.
According to the technical scheme of the embodiment of the application, the state of the task can be updated in task execution, so that the task is prevented from being executed for multiple times, and the accuracy of data synchronization and the consistency of data are ensured. Meanwhile, the state of the service lock can be updated in time, and the safety of data in the system can be effectively ensured.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present application may be performed in parallel, sequentially, or in a different order, provided that the desired results of the technical solutions disclosed in the present application can be achieved, and are not limited herein.
The above embodiments do not limit the scope of the application. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application are intended to be included within the scope of the present application.

Claims (16)

CN202010085248.8A2020-02-102020-02-10 Data synchronization method and device, electronic equipment and storage medium based on service lockActiveCN111367995B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202010085248.8ACN111367995B (en)2020-02-102020-02-10 Data synchronization method and device, electronic equipment and storage medium based on service lock

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202010085248.8ACN111367995B (en)2020-02-102020-02-10 Data synchronization method and device, electronic equipment and storage medium based on service lock

Publications (2)

Publication NumberPublication Date
CN111367995A CN111367995A (en)2020-07-03
CN111367995Btrue CN111367995B (en)2023-07-21

Family

ID=71204473

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202010085248.8AActiveCN111367995B (en)2020-02-102020-02-10 Data synchronization method and device, electronic equipment and storage medium based on service lock

Country Status (1)

CountryLink
CN (1)CN111367995B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112069266B (en)*2020-09-162024-10-11青岛海信智慧家居系统股份有限公司Data synchronization method and service node
CN113282580A (en)*2021-04-282021-08-20青岛海尔科技有限公司Method, storage medium and server for executing timed task
CN114115963A (en)*2021-12-092022-03-01苏州盛科通信股份有限公司Data synchronization method in hot start application and application
CN114968516A (en)*2022-05-162022-08-30脸萌有限公司Scheduling method, device, equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN108153849A (en)*2017-12-202018-06-12杭州登虹科技有限公司A kind of database table cutting method, device, system and medium
CN110489388A (en)*2019-08-162019-11-22上海霄云信息科技有限公司A kind of implementation method and equipment locked for SCSI in distributed network storage system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102436366B (en)*2011-08-222014-07-16华为技术有限公司Data synchronization method and apparatus
CN106572054B (en)*2015-10-092019-09-17阿里巴巴集团控股有限公司Distributed lock service implementing method and device in distributed system
CN108573006B (en)*2017-06-062021-03-26北京金山云网络技术有限公司Cross-machine-room data synchronization system, method and device and electronic equipment
CN107347090A (en)*2017-06-082017-11-14广州市呼百应网络技术股份有限公司Method of data synchronization
CN107301250B (en)*2017-07-272020-06-26南京南瑞集团公司Multi-source database collaborative backup method
CN108647237A (en)*2018-03-302018-10-12厦门海迈科技股份有限公司Method of data synchronization between isomeric relationship type database
CN110321357B (en)*2019-06-142021-06-29北京奇艺世纪科技有限公司Read-write control method and device and server

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN108153849A (en)*2017-12-202018-06-12杭州登虹科技有限公司A kind of database table cutting method, device, system and medium
CN110489388A (en)*2019-08-162019-11-22上海霄云信息科技有限公司A kind of implementation method and equipment locked for SCSI in distributed network storage system

Also Published As

Publication numberPublication date
CN111367995A (en)2020-07-03

Similar Documents

PublicationPublication DateTitle
CN111367995B (en) Data synchronization method and device, electronic equipment and storage medium based on service lock
CN111930521B (en)Method, device, electronic equipment and readable storage medium for deploying application
CN111279314B (en)Providing tenant isolation in a multi-tenant API gateway using micro-service containers
US9721246B2 (en)Synchronization patterns for mobile applications
CN110727557B (en) Log collector management and control method, platform, electronic device and storage medium
CN111782365B (en) Scheduled task processing method, device, equipment and storage medium
CN111930487B (en) Job flow scheduling method, device, electronic device and storage medium
CN108345482A (en)The self-defined edit methods of dynamic page, device, electronic equipment and storage medium
CN103164525B (en)WEB application dissemination method and device
CN111966651B (en)Data synchronization method, device, electronic equipment and storage medium
CN112051993A (en)State machine template generation and task processing method, device, medium and equipment
CN111352944B (en)Data processing method, device, electronic equipment and storage medium
JP7114772B2 (en) Certificate sending method, certificate receiving method, cloud and terminal equipment
CN112015534A (en)Configurated platform scheduling method, system and storage medium
CN113722390A (en)Data storage method and system
WO2024066342A1 (en)Task processing method and apparatus, electronic device, and storage medium
CN105790963A (en)Method for managing multi-user control virtual meeting interface, server and client
CN115189931A (en)Distributed key management method, device, equipment and storage medium
CN115309827A (en) A kind of data differential synchronization method and system and device and medium
JP6997337B2 (en) User interface optimization for delayed data
JP2017102694A (en)Gantt chart generation program, gantt chart generation apparatus and gantt charge generation method
CN112000816B (en)Data processing method and device
US11983190B2 (en)System and method for configurable and automated data extraction, formatting and distribution
CN103782277A (en)Method and system for managing parallel resource requests in a portable computing device
CN117763043A (en)Data synchronous processing method, device, server and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp