Database synchronization method and device, electronic equipment and storage medium

By optimizing the data record grouping and queue matching in the database synchronization method, the problem of low database synchronization efficiency in the existing technology is solved, and the sequential writing of data records and the improvement of synchronization efficiency are achieved.

CN118535643APending Publication Date: 2024-08-23INFORMATION2 SOFTWARE SHANGHAI
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410406549.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-07
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing database synchronization methods have low synchronization efficiency when ensuring data consistency. Especially in the case of concurrent processing of multiple sessions, special sorting and waiting for records that have not been successfully parsed are required, resulting in a significant reduction in efficiency.

Method used

By obtaining the data records to be synchronized from the source database, grouping them according to the sorting results and the preset number, and matching the data groups to the parsing queue for concurrent parsing and writing, ensuring the sequential writing of data records and optimizing queue matching. and waiting mechanism to improve synchronization efficiency.

Benefits of technology

It is possible to improve the efficiency of database synchronization while maintaining the order of data records, and avoid the problem of reduced efficiency caused by waiting for records that have not been parsed successfully.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535643A
    Figure CN118535643A
Patent Text Reader

Abstract

The invention discloses a database synchronization method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a plurality of to-be-synchronized data records corresponding to a source database, and carrying out the grouping of the plurality of data records according to the sorting result of each data record and a preset number of data records, so as to obtain a plurality of data groups; obtaining a plurality of preset analysis queues, and determining an analysis queue matched with each data group according to the arrangement order of the data groups and the number of the analysis queues; respectively inserting each data group into the matched analysis queues, and carrying out concurrent analysis on the plurality of data groups according to the plurality of analysis queues; and according to the analysis result corresponding to each data group and the writing result of the previous data group corresponding to each data group, sequentially writing each data record into the target database. According to the technical scheme provided by the embodiment of the invention, the sequence of data records can be kept during database synchronization, and the database synchronization efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a database synchronization method, device, electronic equipment and storage medium. Background Art

[0002] At present, when synchronizing multiple databases, in order to improve synchronization efficiency, after extracting data records from the source database, multiple connections can be used to concurrently write to the target database. However, in order to ensure the consistency between the target database and the source database, there are requirements for the order of records when writing. Different records must be written to the target database in the same order as they were written to the source database. Usually, sequential writing is one of the methods to ensure data consistency.

[0003] In the prior art, in order to ensure the consistency of data written in the database, the following methods can be adopted: using a single session for writing, although the order can be maintained, but the synchronization efficiency is low; or using multiple sessions for concurrent processing, after the processing is completed, it is sent to the sorting queue for sorting, but this method requires special sorting, the buffer is large, and it is necessary to wait for records that have not been successfully parsed. It often happens that each record needs to wait, which greatly affects the synchronization efficiency. Summary of the invention

[0004] The present invention provides a database synchronization method, device, electronic equipment and storage medium, which can maintain the order of data records during database synchronization and improve the synchronization efficiency of the database.

[0005] According to one aspect of the present invention, a database synchronization method is provided, the method comprising:

[0006] Acquire multiple data records to be synchronized corresponding to the source database, and group the multiple data records according to the sorting results and the preset number of each data record to obtain multiple data groups;

[0007] Acquire a plurality of preset parsing queues, and determine a parsing queue matching each data group according to the arrangement order of each of the data groups and the number of parsing queues;

[0008] Inserting each of the data groups into a matching parsing queue respectively, and concurrently parsing the multiple data groups according to the multiple parsing queues;

[0009] According to the analysis result corresponding to each of the data groups and the writing result of the previous data group corresponding to each of the data groups, each of the data records is written into the target database in sequence.

[0010] Optionally, the plurality of data records are grouped according to the sorting result of each data record and a preset number of records to obtain a plurality of data groups, including:

[0011] According to the sorting results of each data record, determine the record number corresponding to each data record;

[0012] According to the record number corresponding to each of the data records and the preset number of records, the multiple data records are grouped to obtain multiple data groups.

[0013] Optionally, inserting each of the data groups into a matching parsing queue comprises:

[0014] sequentially acquiring one data group from the multiple data groups as a current data group;

[0015] According to the maximum record threshold corresponding to the parsing queue, determine whether there is any free space in the parsing queue matching the current data group;

[0016] If yes, insert the current data group into the matching parsing queue;

[0017] If not, wait according to the preset time length until there is a vacant position in the parsing queue that matches the current data group.

[0018] Optionally, writing each of the data records into the target database in sequence according to the parsing result of the data records corresponding to each of the data groups and the writing result of the data records of the previous data group corresponding to each of the data groups includes:

[0019] Sequentially acquiring one data group from the multiple data groups as a current data group, and sequentially acquiring one data record from the current data group as a current data record;

[0020] Determine whether the current data record has been parsed;

[0021] If yes, determine whether the data records in the previous data group corresponding to the current data group have been written;

[0022] If so, the current data record is written into the target database.

[0023] Optionally, after determining whether the data records in the previous data group corresponding to the current data group have been written, the method further includes:

[0024] If not, inserting the current data record into the corresponding cache queue;

[0025] Traversing the cache queue, and querying whether the previous data group corresponding to the current data record in the cache queue has been written according to the preset waiting time;

[0026] If so, the current data record is written into the target database.

[0027] Optionally, after writing the current data record into the target database, the method further includes:

[0028] Determine whether the current data record is the last data record in the current data group;

[0029] If so, mark the current data group as being in a write-completed state.

[0030] Optionally, determining a parsing queue matching each data group according to the arrangement order of each of the data groups and the number of parsing queues includes:

[0031] Perform modulo processing on the arrangement order of each of the data groups and the number of parsing queues;

[0032] According to the remainder result and the sequence number of the parsing queue, the parsing queue matching each data group is determined.

[0033] According to another aspect of the present invention, a database synchronization device is provided, the device comprising:

[0034] A record grouping module is used to obtain multiple data records to be synchronized corresponding to the source database, and group the multiple data records according to the sorting results of each data record and a preset number of records to obtain multiple data groups;

[0035] A queue determination module, used to obtain a plurality of preset parsing queues, and determine a parsing queue matching each data group according to the arrangement order of each of the data groups and the number of parsing queues;

[0036] A data group parsing module, used for inserting each of the data groups into a matching parsing queue, and performing concurrent parsing on the multiple data groups according to the multiple parsing queues;

[0037] The record writing module is used to write each of the data records into the target database in sequence according to the analysis results corresponding to each of the data groups and the writing results of the previous data group corresponding to each of the data groups.

[0038] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0039] at least one processor; and

[0040] a memory communicatively connected to the at least one processor; wherein,

[0041] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the database synchronization method described in any embodiment of the present invention.

[0042] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the database synchronization method described in any embodiment of the present invention when executed.

[0043] The technical solution provided by the embodiment of the present invention obtains multiple data records to be synchronized corresponding to the source database, groups the multiple data records according to the sorting results of each data record and a preset number of records to obtain multiple data groups, obtains multiple preset parsing queues, determines the parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues, inserts each data group into the matching parsing queue respectively, and concurrently parses the multiple data groups according to the multiple parsing queues, and writes each data record into the target database in sequence according to the parsing results corresponding to each data group and the writing results of the previous data group corresponding to each data group. This technical means can ensure that the data records in the data group are written in an orderly manner. At the same time, by maintaining sequential processing of multiple data groups, the sequentiality between processing groups can be processed without affecting the parsing analysis of the data within the group, thereby greatly improving the synchronization efficiency of the database.

[0044] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 is a flowchart of a database synchronization method provided according to an embodiment of the present invention;

[0047] Figure 2 is a flowchart of another database synchronization method provided according to an embodiment of the present invention;

[0048] Figure 3 is a flowchart of another database synchronization method provided according to an embodiment of the present invention;

[0049] Figure 4 is a schematic diagram of the structure of a database synchronization device provided according to an embodiment of the present invention;

[0050] Figure 5It is a schematic structural diagram of an electronic device for implementing the database synchronization method of the embodiments of the present invention. Detailed implementation manners

[0051] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0053] Figure 1 It is a flowchart of a database synchronization method provided by an embodiment of the present invention. This embodiment is applicable to the case of synchronizing data records in a Postgres database. This method can be executed by a database synchronization device, which can be implemented in the form of hardware and / or software, and the database synchronization device can be configured in an electronic device. As Figure 1 shown, the method includes:

[0054] Step 110, obtain multiple data records to be synchronized corresponding to the source database, and group the multiple data records according to the sorting result of each data record and a preset number to obtain multiple data groups.

[0055] In this step, optionally, multiple data records to be synchronized can be obtained successively according to the writing time of each data record in the source database.

[0056] Specifically, assuming that there are n (n>1) data records in the source database, then every m (1<m<n) data records can be divided into a group according to the writing order of each data record, and the data group number ig corresponding to the nth record can be determined by ig=n / m.

[0057] Step 120: Obtain a plurality of preset parsing queues, and determine a parsing queue that matches each data group according to the arrangement order of each of the data groups and the number of parsing queues.

[0058] In this embodiment, before obtaining multiple data records, multiple parsing queues can be pre-built. After obtaining multiple data groups through the above steps, a corresponding number of data groups can be first obtained from the multiple data groups according to the number of parsing queues, and these data groups can be matched one-to-one with the parsing queues, and then a corresponding number of data can be obtained from the remaining data groups again according to the number of parsing queues, and these data groups can be matched one-to-one with the parsing queues.

[0059] In one implementation of the present embodiment, a parsing queue matching each data group is determined based on the arrangement order of each data group and the number of parsing queues, including: taking the remainder of the arrangement order of each data group and the number of parsing queues; and determining a parsing queue matching each data group based on the remainder result and the sequence number of the parsing queue.

[0060] In a specific embodiment, assuming that the group number of a data group is ig and the number of parsing queues is q, the sequence number iq corresponding to the parsing queue matching the data group can be determined by iq=ig% / q.

[0061] In this embodiment, assuming that 10 data groups are acquired through step 110 and the number of parsing queues is 5, data group 1 and data group 6 can be corresponded to parsing queue 1, data group 2 and data group 7 can be corresponded to parsing queue 2, data group 3 and parsing queue 8 can be corresponded to parsing queue 3, data group 4 and parsing queue 9 can be corresponded to parsing queue 4, and data group 5 and parsing queue 10 can be corresponded to parsing queue 5.

[0062] Step 130: insert each of the data groups into a matching parsing queue respectively, and perform concurrent parsing on the multiple data groups according to the multiple parsing queues.

[0063] In this embodiment, each data group can be inserted into a matching parsing queue according to the parsing queue that matches each data group, and then the data records in the multiple data groups can be parsed concurrently through the multiple parsing queues.

[0064] Step 140: write each of the data records into the target database in sequence according to the analysis result corresponding to each of the data groups and the writing result of the previous data group corresponding to each of the data groups.

[0065] In this embodiment, specifically, assuming that the data records in a certain data group have been parsed, and all the data records in the previous data group corresponding to the data group have been written, the parsed data records in the data group can be written into the target database.

[0066] The technical solution provided by the embodiment of the present invention obtains multiple data records to be synchronized corresponding to the source database, groups the multiple data records according to the sorting results of each data record and a preset number of records to obtain multiple data groups, obtains multiple preset parsing queues, determines the parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues, inserts each data group into the matching parsing queue respectively, and concurrently parses the multiple data groups according to the multiple parsing queues, and writes each data record into the target database in sequence according to the parsing results corresponding to each data group and the writing results of the previous data group corresponding to each data group. This technical means can ensure that the data records in the data group are written in an orderly manner. At the same time, by maintaining sequential processing of multiple data groups, the sequentiality between processing groups can be processed without affecting the parsing analysis of the data within the group, thereby greatly improving the synchronization efficiency of the database.

[0067] Figure 2 A flowchart of another database synchronization method provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method includes:

[0068] Step 210: Acquire multiple data records to be synchronized corresponding to the source database, and determine the record number corresponding to each data record according to the sorting result of each data record.

[0069] Step 220: group the plurality of data records according to the record number corresponding to each of the data records and the preset number of records to obtain a plurality of data groups.

[0070] In this step, specifically, multiple data records may be grouped according to the record number corresponding to each data record and the preset number of records to obtain each data group and the corresponding group number.

[0071] Step 230: Obtain a plurality of preset parsing queues, and determine a parsing queue that matches each data group according to the arrangement order of each of the data groups and the number of parsing queues.

[0072] Step 240: sequentially obtain one data group from the multiple data groups as the current data group.

[0073] Step 250 , based on the maximum record threshold corresponding to the parsing queue, determine whether there is any free space in the parsing queue that matches the current data group. If so, execute step 260 ; if not, execute step 270 .

[0074] In this step, specifically, it can be determined whether there is any free space in the parsing queue according to the number of data records currently inserted in the parsing queue and the maximum record threshold corresponding to the parsing queue.

[0075] Step 260: Insert the current data group into a matching parsing queue.

[0076] Step 270: Wait for a preset time until there is a vacant position in the parsing queue that matches the current data group.

[0077] Step 280: concurrently parse the multiple data groups according to the multiple parsing queues.

[0078] Step 290: Write each of the data records into the target database in sequence according to the analysis result corresponding to each of the data groups and the writing result of the previous data group corresponding to each of the data groups.

[0079] The technical solution provided by the embodiment of the present invention obtains multiple data records to be synchronized corresponding to the source database, determines the record number corresponding to each data record according to the sorting result of each data record, groups the multiple data records according to the record number corresponding to each data record and the preset number to obtain multiple data groups, obtains multiple preset parsing queues, determines the parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues, obtains one data group in turn from the multiple data groups as the current data group, judges whether there is a vacant position in the parsing queue matching the current data group according to the maximum record threshold corresponding to the parsing queue, and if so, inserts the current data group into the matching parsing queue, concurrently parses the multiple data groups according to the multiple parsing queues, and writes each data record into the target database in turn according to the parsing result corresponding to each data group and the writing result of the previous data group corresponding to each data group. The technical means can achieve the sequentiality of data records when synchronizing the database and improve the synchronization efficiency of the database.

[0080] Figure 3 A flowchart of another database synchronization method provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the method includes:

[0081] Step 301: Acquire multiple data records to be synchronized corresponding to a source database, and group the multiple data records according to the sorting results of the data records and a preset number of records to obtain multiple data groups.

[0082] Step 302: Obtain a plurality of preset parsing queues, and determine a parsing queue that matches each data group according to the arrangement order of each of the data groups and the number of parsing queues.

[0083] Step 303: insert each of the data groups into a matching parsing queue respectively, and perform concurrent parsing on the multiple data groups according to the multiple parsing queues.

[0084] Step 304: sequentially obtain one data group from the multiple data groups as the current data group.

[0085] Step 305: sequentially obtain one data record in the current data group as the current data record.

[0086] Step 306: After the current data record is parsed, determine whether the data record in the previous data group corresponding to the current data group has been written; if so, execute step 307; if not, execute steps 308-309.

[0087] In this step, specifically, after the current data record is parsed, it can be determined whether all the data records in the previous data group have been written.

[0088] Step 307: Write the current data record into the target database.

[0089] Step 308: Insert the current data record into the corresponding cache queue.

[0090] In this embodiment, after the current data record is parsed, if the data records in the previous data group have not been fully written, the current data record can be inserted into the corresponding cache queue. Specifically, each parsing queue corresponds to a cache queue.

[0091] Step 309, traverse the cache queue, and query whether the previous data group corresponding to the current data record in the cache queue has been written according to the preset waiting time; if so, execute step 307, if not, continue to execute step 309.

[0092] In this step, it is possible to query whether all data records in the previous data group corresponding to the current data record have been written. If so, the current data record is written into the target database; if not, wait for a preset time and query again.

[0093] Step 310 , determine whether the current data record is the last data record in the current data group, if so, execute step 311 , if not, return to execute step 305 .

[0094] Step 311: Mark the current data group as being in a write-completed state.

[0095] The technical solution provided by the embodiment of the present invention obtains multiple data records to be synchronized corresponding to the source database, groups the multiple data records into multiple data groups according to the sorting results of each data record and a preset number, determines the parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues, inserts each data group into the matching parsing queue, performs concurrent parsing on the multiple data groups according to the multiple parsing queues, obtains one data group in turn from the multiple data groups as the current data group, obtains one data record in turn from the current data group as the current data record, determines whether the data records in the previous data group have been written after the parsing of the current data record is completed, and if so, writes the current data record into the target database, determines whether the current data record is the last data record in the current data group, and if so, marks the current data group as being in a written state. This technical solution can achieve the sequentiality of data records during database synchronization and improve the synchronization efficiency of the database.

[0096] Figure 4 A schematic diagram of the structure of a database synchronization device provided by an embodiment of the present invention, wherein the device is applied to an electronic device, such as Figure 4 As shown, the device includes: a record grouping module 410, a queue determination module 420, a data group parsing module 430 and a record writing module 440.

[0097] The record grouping module 410 is used to obtain a plurality of data records to be synchronized corresponding to the source database, and group the plurality of data records according to the sorting result of each data record and a preset number of records to obtain a plurality of data groups;

[0098] The queue determination module 420 is used to obtain a plurality of preset parsing queues, and determine a parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues;

[0099] A data group parsing module 430, for inserting each of the data groups into a matching parsing queue, and performing concurrent parsing on the multiple data groups according to the multiple parsing queues;

[0100] The record writing module 440 is used to write each of the data records into the target database in sequence according to the analysis result corresponding to each of the data groups and the writing result of the previous data group corresponding to each of the data groups.

[0101] The technical solution provided by the embodiment of the present invention obtains multiple data records to be synchronized corresponding to the source database, groups the multiple data records according to the sorting results of each data record and a preset number of records to obtain multiple data groups, obtains multiple preset parsing queues, determines the parsing queue matching each data group according to the arrangement order of each data group and the number of parsing queues, inserts each data group into the matching parsing queue respectively, and concurrently parses the multiple data groups according to the multiple parsing queues, and writes each data record into the target database in sequence according to the parsing results corresponding to each data group and the writing results of the previous data group corresponding to each data group. This technical means can ensure that the data records in the data group are written in an orderly manner. At the same time, by maintaining sequential processing of multiple data groups, the sequentiality between processing groups can be processed without affecting the parsing analysis of the data within the group, thereby greatly improving the synchronization efficiency of the database.

[0102] Based on the above embodiment, the record grouping module 410 includes:

[0103] A numbering unit, used to determine a record number corresponding to each data record according to the sorting result of each data record;

[0104] The grouping unit is used to group the multiple data records according to the record number corresponding to each of the data records and a preset number of records to obtain multiple data groups.

[0105] The queue determination module 420 includes:

[0106] The remainder unit is used to perform remainder processing on the arrangement order of each data group and the number of parsing queues; and determine the parsing queue matching each data group based on the remainder result and the sequence number of the parsing queue.

[0107] The data group parsing module 430 includes:

[0108] A position determination unit, configured to sequentially obtain one data group from the plurality of data groups as the current data group; and determine whether there is an empty position in the parsing queue matched by the current data group according to the maximum record threshold corresponding to the parsing queue;

[0109] A data group inserting unit, configured to insert the current data group into the matching parsing queue when there is a vacant position in the parsing queue matching the current data group;

[0110] The waiting execution unit is used to wait according to a preset time length when there is no free position in the parsing queue matching the current data group, until there is a free position in the parsing queue matching the current data group.

[0111] The record writing module 440 includes:

[0112] A record acquisition unit, used to sequentially acquire one data group from the multiple data groups as a current data group, and sequentially acquire one data record from the current data group as a current data record;

[0113] A data group determination unit, used to determine whether the data record in the previous data group corresponding to the current data group has been written after the current data record is parsed, and if so, write the current data record into the target database;

[0114] A cache queue insertion unit, used for inserting the current data record into the corresponding cache queue when the data record in the previous data group corresponding to the current data group has not been written completely;

[0115] A cache queue traversal unit is used to traverse the cache queue and query whether the previous data group corresponding to the current data record in the cache queue has been written according to a preset waiting time; if so, write the current data record into the target database;

[0116] The record determination unit is used to determine whether the current data record is the last data record in the current data group; if so, mark the current data group as being in a write-completed state.

[0117] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not fully described in the embodiments of the present invention, please refer to the methods provided by all the above embodiments of the present invention.

[0118] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0119] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0120] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0121] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a database synchronization method.

[0122] In some embodiments, the database synchronization method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the database synchronization method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the database synchronization method in any other appropriate manner (e.g., by means of firmware).

[0123] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0124] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0125] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0126] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the 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, voice input, or tactile input).

[0127] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0128] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0129] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0130] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A database synchronization method, characterized in that: The method comprises: Acquire multiple data records to be synchronized corresponding to the source database, and group the multiple data records according to the sorting results and the preset number of each data record to obtain multiple data groups; Acquire a plurality of preset parsing queues, and determine a parsing queue matching each data group according to the arrangement order of each of the data groups and the number of parsing queues; Inserting each of the data groups into a matching parsing queue respectively, and concurrently parsing the multiple data groups according to the multiple parsing queues; According to the analysis result corresponding to each of the data groups and the writing result of the previous data group corresponding to each of the data groups, each of the data records is written into the target database in sequence.

2. The method according to claim 1, characterized in that According to the sorting results of each data record and the preset number of records, the multiple data records are grouped to obtain multiple data groups, including: According to the sorting results of each data record, determine the record number corresponding to each data record; According to the record number corresponding to each of the data records and the preset number of records, the multiple data records are grouped to obtain multiple data groups.

3. The method according to claim 1, characterized in that Inserting each of the data groups into a matching parsing queue respectively includes: sequentially acquiring one data group from the multiple data groups as a current data group; According to the maximum record threshold corresponding to the parsing queue, determine whether there is any free space in the parsing queue matching the current data group; If yes, insert the current data group into the matching parsing queue; If not, wait according to the preset time length until there is a vacant position in the parsing queue that matches the current data group.

4. The method according to claim 1, characterized in that: According to the data record parsing result corresponding to each data group and the data record writing result of the previous data group corresponding to each data group, each data record is sequentially written into the target database, including: Sequentially acquiring one data group from the multiple data groups as a current data group, and sequentially acquiring one data record from the current data group as a current data record; Determine whether the current data record has been parsed; If yes, determine whether the data records in the previous data group corresponding to the current data group have been written; If so, the current data record is written into the target database.

5. The method according to claim 4, characterized in that After determining whether the data records in the previous data group corresponding to the current data group have been written, the method further includes: If not, inserting the current data record into the corresponding cache queue; Traversing the cache queue, and querying whether the previous data group corresponding to the current data record in the cache queue has been written according to the preset waiting time; If so, the current data record is written into the target database.

6. The method according to claim 4 or 5, characterized in that: After writing the current data record into the target database, the method further includes: Determine whether the current data record is the last data record in the current data group; If so, mark the current data group as being in a write-completed state.

7. The method according to claim 1, characterized in that According to the arrangement order of each of the data groups and the number of parsing queues, determining a parsing queue matching each data group includes: Perform modulo processing on the arrangement order of each of the data groups and the number of parsing queues; According to the remainder result and the sequence number of the parsing queue, the parsing queue matching each data group is determined.

8. A database synchronization device, characterized in that: The device comprises: A record grouping module is used to obtain multiple data records to be synchronized corresponding to the source database, and group the multiple data records according to the sorting results of each data record and a preset number of records to obtain multiple data groups; A queue determination module, used to obtain a plurality of preset parsing queues, and determine a parsing queue matching each data group according to the arrangement order of each of the data groups and the number of parsing queues; A data group parsing module, used for inserting each of the data groups into a matching parsing queue, and performing concurrent parsing on the multiple data groups according to the multiple parsing queues; The record writing module is used to write each of the data records into the target database in sequence according to the analysis results corresponding to each of the data groups and the writing results of the previous data group corresponding to each of the data groups.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the database synchronization method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the database synchronization method according to any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • Incremental log processing method and device, electronic equipment and storage medium

    CN113760885A

  • Data synchronization method and device

    CN114490050A

  • Data synchronization method and device, server and storage medium

    CN116719883A

  • Data replication technique in database management system

    US20190361913A1