Data extraction method and device, program product and medium

By using multiple service instances to perform data extraction in turn in a large distributed database, and utilizing the distributed lock mechanism, the real-time and reliability problems of data extraction in the existing technology are solved, and efficient data extraction is achieved.

CN118626539APending Publication Date: 2024-09-10VOYAH AUTOMOBILE TECH CO LTD

Patent Information

Application Number
CN202410790708.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing technology is difficult to achieve real-time and stable extraction of data in large-scale distributed databases. Writing complex SQL statements increases development and maintenance costs. Specialized data extraction tools are mainly used for stand-alone databases and cannot meet the real-time extraction needs of large-scale distributed databases. .

Method used

Multiple service instances are used to participate in data extraction. Each data extraction is executed by one service instance. Two adjacent extractions are executed by two service instances in turn. The distributed lock mechanism ensures the real-time and reliability of data extraction and avoids repeated operations. .

Benefits of technology

It realizes real-time data extraction of large distributed databases, improves the reliability and stability of the system, and avoids duplication of data extraction and waste of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626539A
    Figure CN118626539A
Patent Text Reader

Abstract

The invention discloses a data extraction method and device, a program product and a medium. The method comprises the steps that a data extraction task instruction is received; according to the data extraction task instruction, obtaining a distributed lock of a task execution permission; if one service instance in the multiple service instances obtains the distributed lock, the service instance obtaining the distributed lock obtains the latest extraction time from a data extraction record table, and the data extraction record table records the extraction time of each service instance for data extraction each time; and if the latest extraction time is obtained, extracting data between the latest extraction time and the current extraction time in a distributed database by the service instance which obtains the distributed lock. Through the technical scheme provided by the invention, the real-time performance, continuity and stability of data extraction can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a data extraction method, device, program product and medium. Background Art

[0002] With the development of big data technology, large-scale distributed databases are increasingly widely used. The amount of data in these databases is huge, the data types are complex, and the data is updated frequently, which puts higher requirements on the real-time extraction and processing of data. At the same time, the introduction of distributed systems makes the storage and processing of data more complicated. How to achieve real-time and stable data extraction in large-scale distributed systems is an important research direction in the current fields of database technology, distributed system field, and data extraction technology.

[0003] Related data extraction technology mainly extracts the required data from the database by writing complex structured query languages ​​(SQL) or using specialized data extraction tools. However, on the one hand, writing complex SQL statements not only increases the cost of development and maintenance, but also reduces the reliability of the system; on the other hand, the use of specialized data extraction tools is generally applicable to stand-alone databases, mainly for the synchronization of business data, and rarely for real-time data extraction from large distributed databases. These methods often encounter performance bottlenecks when processing large-scale distributed databases and cannot meet real-time requirements. Summary of the invention

[0004] In view of the above problems, the present application is proposed to provide a data extraction method, device, program product and medium that solve the above problems or at least partially solve the above problems.

[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0006] According to the first aspect of an embodiment of the present application, a data extraction method is provided, wherein the method is executed by multiple service instances, and each data extraction is executed by one of the service instances, and two adjacent data extractions are respectively executed by two of the service instances, and the method comprises: receiving a data extraction task instruction; obtaining a distributed lock of task execution authority according to the data extraction task instruction; if one of the multiple service instances obtains the distributed lock, the service instance that obtains the distributed lock obtains the latest extraction time from a data extraction record table, and the data extraction record table records the extraction time of each data extraction performed by each service instance; if the latest extraction time is obtained, the service instance that obtains the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

[0007] In some embodiments of the present application, based on the aforementioned scheme, the method further includes: if the latest extraction time is not obtained, the service instance that obtains the distributed lock extracts the data in the distributed database before the current extraction time.

[0008] In some embodiments of the present application, based on the aforementioned scheme, the method also includes: determining the validity period of the distributed lock of the service instance that obtains the distributed lock according to the extraction time of each data extraction; if the validity period is exceeded, releasing the distributed lock so that other service instances that have not obtained the distributed lock can subsequently obtain the distributed lock.

[0009] In some embodiments of the present application, based on the aforementioned scheme, the effective time that the service instance that obtains the distributed lock has the distributed lock is determined according to the extraction time of each data extraction, including: calculating the sum of the extraction time of each data extraction and the preset delay time, and using the calculated sum as the effective time that the service instance that obtains the distributed lock has the distributed lock.

[0010] In some embodiments of the present application, based on the aforementioned scheme, the data extraction record table also includes a service identifier of each of the service instances, and the method also includes: after extracting data from the distributed database, the service instance that obtains the distributed lock writes the current extraction time into the data extraction record table, and the written current extraction time corresponds to the service identifier of the service instance that obtains the distributed lock.

[0011] In some embodiments of the present application, based on the aforementioned scheme, the method also includes: if an abnormal situation occurs in the service instance that obtains the distributed lock, resulting in failure to extract data between the latest extraction time and the current extraction time in the distributed database and / or failure to write the current extraction time into the data extraction record table, then determining that the data extraction is to be rolled back, the rollback operation is used to indicate returning to the state before the service instance that obtains the distributed lock performs data extraction.

[0012] In some embodiments of the present application, based on the aforementioned scheme, the method also includes: after performing the rollback operation, the other service instances that have not acquired the distributed lock acquire the distributed lock, and after acquiring the distributed lock, extract the data between the latest extraction time and the current extraction time in the distributed database.

[0013] According to a second aspect of an embodiment of the present application, a data extraction device is provided, wherein the device is arranged in a plurality of service instances, and each data extraction is executed by one of the service instances, and two adjacent data extractions are respectively executed by two of the service instances, and the device comprises: a receiving unit, configured to receive a data extraction task instruction; a first acquisition unit, configured to acquire a distributed lock of task execution authority according to the data extraction task instruction; a second acquisition unit, configured to, if a service instance among the plurality of service instances acquires the distributed lock, then the service instance that acquires the distributed lock acquires the latest extraction time from a data extraction record table, wherein the data extraction record table records the extraction time of each data extraction performed by each service instance; an extraction unit, configured to, if the latest extraction time is acquired, then the service instance that acquires the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

[0014] According to a third aspect of an embodiment of the present application, a computer program product is provided, which includes computer instructions stored in a computer-readable storage medium and suitable for being read and executed by a processor, so that a computer device having the processor executes a method as described in any embodiment of the first aspect above.

[0015] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one computer program instruction is stored. The at least one computer program instruction is loaded and executed by a processor to implement the operations performed by the method described in any embodiment of the first aspect above.

[0016] Based on the technical solution proposed in this application, multiple service instances extract data from a distributed database. Each data extraction is performed by only one of the service instances, and two adjacent data extractions are performed by two of the service instances respectively. This method of continuous data extraction by multiple service instances ensures the real-time data extraction compared to the interval extraction of a service instance. At the same time, multiple service instances extract data. Even if a service instance hangs up, other service instances can still perform data extraction, which greatly improves the reliability and stability of the entire system. Moreover, in the technical solution of this application, each data extraction is performed only by the service instance that obtains the distributed lock, which avoids the simultaneous execution of data extraction operations by multiple service instances, resulting in repeated data extraction and waste of resources.

[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0019] Figure 1 A system architecture diagram of a data extraction method application provided according to an embodiment of the present application is shown;

[0020] Figure 2 A flow chart of a data extraction method according to an embodiment of the present application is shown;

[0021] Figure 3 A flow chart of a data extraction method according to an embodiment of the present application is shown;

[0022] Figure 4 A block diagram of a data extraction device according to an embodiment of the present application is shown;

[0023] Figure 5 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

[0026] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0027] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0028] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of this application, unless otherwise specified, "plurality" means two or more.

[0029] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein are only for the purpose of describing the embodiments of the present invention and are not intended to limit the present invention.

[0030] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are subject to the following interpretations.

[0031] 1) Distributed locks are a way to control the synchronous access to shared resources between distributed systems. When different processes need to access shared resources, they often need to use mutual exclusion to prevent different processes from interfering with each other to ensure consistency. In this case, distributed locks are needed. The difference from ordinary locks is that distributed locks are usually stored in an independent component, and all processes or threads obtain or release lock resources through interfaces.

[0032] 2) Service instance. In a distributed system, each service is deployed as a group of service instances to improve throughput and availability. Usually each service instance is a separate process.

[0033] 3) Validity time refers to the estimated length of time a distributed lock is held, which means starting from the moment the distributed lock is acquired. If the validity time is exceeded, the distributed lock will be automatically released so that the distributed lock can be acquired by other service instances, thereby avoiding deadlock.

[0034] In order to enable those skilled in the art to better understand the present application, the application scenarios involved in the present application are first briefly described.

[0035] like Figure 1 , which is a schematic diagram of an application scenario of a data extraction method provided by an embodiment of the present application. To support an exemplary application, the data extraction system includes multiple service instances 100 (exemplarily showing service instance 100-1 and service instance 100-2) and a distributed database 200.

[0036] In actual implementation, each data extraction is performed by one of the service instances, and two adjacent data extractions are performed by two of the service instances respectively. Exemplarily, when the data extraction system only includes service instance 100-1 and service instance 100-2, service instance 100-1 and service instance 100-2 perform data extraction in turn, for example, service instance 100-1 performs data extraction first, and after service instance 100-1 performs data extraction, service instance 100-2 performs data extraction; or, service instance 100-2 performs data extraction first, and after service instance 100-2 performs data extraction, service instance 100-1 performs data extraction.

[0037] The data extraction system in the embodiment of the present application includes multiple service instances. The advantage of this is that compared to executing data extraction through only one service instance, there must be a time interval between the operations of a service instance executing data extraction. Multiple service instances can realize continuous data extraction, ensuring the real-time performance of data extraction. At the same time, when data is extracted by multiple service instances, even if a service instance crashes, other service instances can still execute data extraction, thereby improving the reliability and stability of the entire system.

[0038] The data extraction method of this embodiment is described below by taking an example where the data extraction system includes a service instance 100 - 1 and a service instance 100 - 2 .

[0039] After service instance 100-1 and service instance 100-2 receive the data extraction task instruction, they first need to obtain the distributed lock of the task execution authority according to the data extraction task instruction. If service instance 100-1 obtains the distributed lock, service instance 100-1 obtains the latest extraction time from the data extraction record table. The data extraction record table records the extraction time of each data extraction performed by service instance 100-1 and service instance 100-2; if service instance 100-1 obtains the latest extraction time, service instance 100-1 extracts the data between the latest extraction time and the current extraction time in the distributed database 200.

[0040] In some embodiments, if the service instance 100-1 does not obtain the latest extraction time, the service instance 100-1 extracts the data before the current extraction time in the distributed database 200. It should be noted that if the service instance 100-1 does not obtain the latest extraction time, it means that the service instance 100-1 and the service instance 100-2 have not extracted data from the distributed database 200. Therefore, the data extraction needs to extract the full amount of data before the current extraction time.

[0041] The solution of the embodiment of the present application proposes a method for extracting data from a distributed database 200 by multiple service instances, and continuous extraction is achieved by multiple service instances. Compared with the intermittent extraction of a service instance, this method can ensure the real-time performance of data extraction. At the same time, multiple service instances extract data, and even if a service instance hangs up, other service instances can still perform data extraction, which greatly improves the reliability and stability of the entire system. In addition, through the distributed lock method, there will be no conflict when multiple service instances perform data extraction, that is, each data extraction is only performed by one of the service instances, that is, each data extraction is only performed by the service instance that obtains the distributed lock, which avoids multiple service instances from performing data extraction operations at the same time, causing duplication of data extraction and waste of resources.

[0042] The following describes the data extraction method provided by the exemplary embodiment of the present application in combination with the application scenario described above and with reference to the accompanying drawings. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this regard.

[0043] Figure 2is a flow chart of a data extraction method provided by an embodiment of the present application. The data extraction method is executed by multiple service instances, and each data extraction is executed by one of the service instances, and two adjacent data extractions are executed by two of the service instances respectively. Figure 2 As shown, the data extraction method includes the following steps:

[0044] Step S210, receiving a data extraction task instruction;

[0045] Step S220: Acquire a distributed lock of task execution authority according to the data extraction task instruction;

[0046] Step S230: If a service instance among the multiple service instances obtains the distributed lock, the service instance that obtains the distributed lock obtains the latest extraction time from the data extraction record table, and the data extraction record table records the extraction time of each service instance for each data extraction;

[0047] Step S240: If the latest extraction time is obtained, the service instance that obtains the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

[0048] These steps are described in detail below.

[0049] Step S210: receiving a data extraction task instruction.

[0050] In this embodiment, the data extraction method is executed by multiple service instances, and the multiple service instances receive data extraction task instructions and respond to the data extraction task instructions. The data extraction task instructions can be triggered by a trigger, and the data extraction task instructions are generated by the trigger, and the data extraction task instructions are used to instruct data extraction from a distributed database.

[0051] Step S220: Acquire a distributed lock of task execution authority according to the data extraction task instruction.

[0052] After receiving the data extraction task instruction in step S210, the multiple service instances may respond to the data extraction task instruction and obtain a distributed lock of the task execution authority.

[0053] Distributed locks are a way to control the synchronous access to shared resources between distributed systems. When different processes need to access shared resources, they often need to use mutual exclusion to prevent different processes from interfering with each other to ensure consistency. In this case, distributed locks are needed.

[0054] In this embodiment, in order to avoid problems such as disorder, duplication, and loss when multiple service instances extract data from a distributed database, a distributed lock method is adopted. The service instance responds to the data extraction task instruction and needs to obtain the distributed lock of the task execution authority before executing the data extraction.

[0055] In some embodiments, the distributed lock may be a distributed lock based on redis, which is an open source key-value pair storage system with high performance, high availability, scalability, etc. In this embodiment, the distributed lock function of redis is used to effectively control multiple service instances to concurrently access the distributed database.

[0056] Step S230: If a service instance among multiple service instances obtains a distributed lock, the service instance that obtains the distributed lock obtains the latest extraction time from the data extraction record table, and the data extraction record table records the extraction time of each service instance for each data extraction.

[0057] When multiple service instances acquire distributed locks, if one of the service instances acquires the distributed lock, the service instance can execute the data extraction task instruction to extract data from the distributed database.

[0058] The data extraction of this embodiment can be data extraction based on timestamps. Specifically, the time of each data extraction of each service instance will be recorded to form a data extraction record table. After obtaining the distributed lock, the service instance that obtains the distributed lock needs to obtain the latest extraction time from the data extraction record table.

[0059] Step S240: If the latest extraction time is obtained, the service instance that obtains the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

[0060] If the service instance that obtains the distributed lock obtains the latest extraction time, the service instance can further extract the incremental data between the latest extraction time and the current extraction time from the distributed database. In other words, if the latest extraction time is obtained, it means that the data before the latest extraction time has been extracted by the service instance, and the incremental data in the distributed database between the latest extraction time and the current extraction time has not been extracted, so the current extraction can extract these incremental data.

[0061] In one embodiment of the present application, if the service instance that obtains the distributed lock does not obtain the latest extraction time, the service instance can extract the data before the current extraction time in the distributed database. In this embodiment, if the service instance that obtains the distributed lock does not obtain the latest extraction time, it means that data has not been extracted from the distributed database yet. Therefore, this data extraction needs to extract the full amount of data before the current extraction time.

[0062] According to the data extraction method provided in the embodiment of the present application, multiple service instances extract data from a distributed database, and each data extraction is performed by only one of the service instances, and two adjacent data extractions are performed by two of the service instances respectively. This method of continuous data extraction by multiple service instances ensures the real-time performance of data extraction compared to the interval extraction of a service instance. At the same time, multiple service instances perform data extraction, and even if a service instance hangs up, other service instances can still perform data extraction, which greatly improves the reliability and stability of the entire system. Moreover, in the technical solution of the present application, each data extraction is performed only by the service instance that obtains the distributed lock, which avoids the simultaneous execution of data extraction operations by multiple service instances, resulting in disorder, duplication, and loss of data extraction, and waste of resources.

[0063] In one embodiment of the present application, in order to ensure that the distributed lock is not occupied for a long time and affect the real-time performance of data extraction, the effective time of the distributed lock can be set. Specifically, Figure 3 As shown, the data extraction method may further include steps S310 to S320, which are described in detail as follows:

[0064] Step S310: Determine the validity period of the distributed lock of the service instance that obtains the distributed lock according to the extraction time of each data extraction.

[0065] The effective time refers to the expected length of time to hold the distributed lock, which means starting from the moment the distributed lock is acquired. If the effective time is exceeded, the distributed lock will be automatically released so that the distributed lock can be acquired by other service instances, thereby avoiding deadlock.

[0066] In this embodiment, the effective time of the distributed lock held by the service instance that has obtained the distributed lock can be determined based on the extraction time of each data extraction. Specifically, in some embodiments, the method for determining the effective time can be: calculating the sum of the extraction time of each data extraction and the preset delay time, and using the calculated sum as the effective time of the distributed lock held by the service instance that has obtained the distributed lock. For example, assuming that the extraction time of each service instance for each data extraction is 1s, and the preset delay time is set to 1s, then the effective time of the distributed lock held by the service instance is 2s.

[0067] Step S320: If the validity time has expired, the distributed lock is released so that other service instances that have not acquired the distributed lock can subsequently acquire the distributed lock.

[0068] If the validity period exceeds, the service instance that obtains the distributed lock will release the distributed lock so that other service instances that have not obtained the distributed lock can subsequently obtain the distributed lock and thus have the task execution permission.

[0069] For example, if the validity period of a service instance is 2 seconds and the current extraction time is 10:51:12, it means that the service instance has a distributed lock from 10:51:12 to 10:51:14. If the time exceeds 10:51:14, the distributed lock will be automatically released.

[0070] This embodiment can effectively control concurrent access, avoid lock contention, and improve the efficiency of data operations by setting the effective time of the distributed lock.

[0071] In one embodiment of the present application, the data extraction record table not only records the extraction time of each service instance for each data extraction, but also records the service identifier of each service instance. The service identifier is a mark or tag used to distinguish the service instance. For example, the service identifier can be the network address of the service instance. In the data extraction record table, the extraction time of each service instance for data extraction corresponds to the service identifier of the service instance. By designing the data extraction record table, the data extraction process is simplified and the code is made more concise and clear.

[0072] Exemplarily, the content recorded in the data extraction record table may be as shown in the following Table 1. As shown in Table 1, there are at least four service instances in the data extraction system, and the service identifiers of the four service instances are service identifier A, service identifier B, service identifier C, and service identifier D, respectively, wherein the extraction times in the order of extraction time are extraction time 1, extraction time 2, extraction time 3, extraction time 4, extraction time 5, extraction time 6, extraction time 7, extraction time 8, extraction time 9, extraction time 10, extraction time 11, and extraction time 12.

[0073] It can be clearly seen from Table 1 that the latest extraction time is extraction time 12, and it can be seen that the service instance corresponding to service ID A extracts the full data before extraction time 1 in the distributed database, and the service instance corresponding to service ID B extracts the incremental data between extraction time 1 and extraction time 2 in the distributed database, and so on.

[0074] Table 1

[0075] Service Logo A Service Logo B Service Logo C Service Logo D …… Extraction time 1 Extraction time 2 Extraction time 3 Extraction time 4 …… Extraction time 7 Extraction time 9 Extraction time 5 Extraction time 6 …… Extraction time 10 …… Extraction time 8 Extraction time 11 …… Extraction time 12 …… …… …… ……

[0076] In this embodiment, after the service instance that obtains the distributed lock extracts data from the distributed database, it is necessary to write the current extraction time into the data recording table, and the written current extraction time corresponds to the service identifier of the service instance.

[0077] In one embodiment of the present application, if an abnormal situation occurs in the service instance that obtains the distributed lock, resulting in a failure to extract data between the latest extraction time and the current extraction time in the distributed database and / or a failure to write the current extraction time into the data extraction record table, at least one of the following situations occurs, then it is determined that the data extraction is to be rolled back, and the rollback operation is used to indicate a return to the state before the service instance that obtains the distributed lock performs data extraction. The abnormal situation here may refer to a situation where a network abnormality occurs in the service instance, and of course, it may also refer to other abnormal situations, which are not specifically limited in this embodiment.

[0078] Further, in some embodiments, after the rollback operation is performed, that is, after returning to the state before the service instance that obtains the distributed lock extracts data, due to an abnormality in the service instance, other service instances that have not obtained the distributed lock will then acquire the distributed lock, and after obtaining the distributed lock, extract data from the distributed database between the latest extraction time and the current extraction time.

[0079] The following describes an apparatus embodiment of the present application, which can be used to execute the vehicle voice control method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the vehicle voice control method of the present application.

[0080] See also Figure 4 , shows a block diagram of the data extraction device in an embodiment of the present application.

[0081] like Figure 4 As shown, according to the data extraction device 400 of the embodiment of the present application, the data extraction device 400 is set in multiple service instances, and each data extraction is performed by one of the service instances, and two adjacent data extractions are respectively performed by two of the service instances. The data extraction device 400 includes: a receiving unit 401, a first acquisition unit 402, a second acquisition unit 403 and an extraction unit 404.

[0082] Among them, the receiving unit 401 is configured to receive a data extraction task instruction; the first acquisition unit 402 is configured to obtain a distributed lock of task execution authority according to the data extraction task instruction; the second acquisition unit 403 is configured so that if a service instance among multiple service instances obtains the distributed lock, the service instance that obtains the distributed lock obtains the latest extraction time from the data extraction record table, and the data extraction record table records the extraction time of each data extraction performed by each service instance; the extraction unit 404 is configured so that if the latest extraction time is obtained, the service instance that obtains the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

[0083] In one embodiment of the present application, the extraction unit 404 is further configured to extract data in the distributed database before the current extraction time by the service instance that obtains the distributed lock if the latest extraction time is not obtained.

[0084] In one embodiment of the present application, the data extraction device 400 also includes a determination unit and a release unit, the determination unit is configured to determine the validity period of the distributed lock of the service instance that obtains the distributed lock based on the extraction time of each data extraction; the release unit is configured to release the distributed lock if the validity period is exceeded, so that other service instances that have not obtained the distributed lock can subsequently obtain the distributed lock.

[0085] In one embodiment of the present application, the determination unit is further configured to calculate the sum of the extraction time and the preset delay time for each data extraction, and use the calculated sum as the effective time for the service instance that obtains the distributed lock to have the distributed lock.

[0086] In one embodiment of the present application, the data extraction record table also includes a service identifier of each of the service instances, and the data extraction device 400 also includes a writing unit, which is configured to, after extracting data from the distributed database, write the current extraction time into the data extraction record table by the service instance that obtains the distributed lock, and the written current extraction time corresponds to the service identifier of the service instance that obtains the distributed lock.

[0087] In one embodiment of the present application, the determination unit is also configured to determine that the data extraction is to be rolled back if an abnormal situation occurs in the service instance that obtains the distributed lock, resulting in failure to extract data between the latest extraction time and the current extraction time in the distributed database and / or failure to write the current extraction time into the data extraction record table. The rollback operation is used to indicate returning to the state before the service instance that obtains the distributed lock performs data extraction.

[0088] In one embodiment of the present application, the extraction unit 404 is also configured to, after the rollback operation, acquire the distributed lock by other service instances that have not acquired the distributed lock, and after acquiring the distributed lock, extract data between the latest extraction time and the current extraction time in the distributed database.

[0089] Based on the same inventive concept, an embodiment of the present application also provides a computer program product, which includes computer instructions, which are stored in a computer-readable storage medium and are suitable for being read and executed by a processor, so that a computer device having the processor executes the method as described above.

[0090] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, in which at least one computer program instruction is stored. The at least one computer program instruction is loaded and executed by a processor to implement the operations performed by the method described above.

[0091] Based on the same inventive concept, Figure 5 The embodiment of the present application also provides a structural diagram of a computer system of an electronic device suitable for implementing the embodiment of the present application.

[0092] It should be noted that Figure 5 The computer system of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0093] like Figure 5 As shown, the computer system includes one or more memories 504, one or more processors 502, and at least one computer program (computer program instruction) stored in the memory 504 and executable on the processor 502. When the processor 502 executes the computer program, the method described above is implemented.

[0094] Among them, Figure 5In the embodiment of the present invention, a bus architecture (represented by bus 500) is shown, which may include any number of interconnected buses and bridges, and bus 500 links various circuits including one or more processors represented by processor 502 and memory represented by memory 504. Bus 500 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 505 provides an interface between bus 500 and receiver 501 and transmitter 503. Receiver 501 and transmitter 503 may be the same element, namely a transceiver, providing a unit for communicating with various other devices over a transmission medium. Processor 502 is responsible for managing bus 500 and general processing, while memory 504 may be used to store data used by processor 502 when performing operations.

[0095] The functions described herein may be implemented in hardware, software executed by a processor, firmware, or any combination thereof. If implemented in software executed by a processor, the functions may be stored as one or more instructions or codes on a computer-readable medium or transmitted via a computer-readable medium. Other examples and implementations are within the scope and spirit of the present application and the appended claims. For example, due to the nature of software, the functions described above may be implemented using software executed by a processor, hardware, firmware, hard wiring, or a combination of any of these. In addition, each functional unit may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit.

[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0097] The units described as separate components may or may not be physically separated, and the components of the control device may or may not be physical units, that is, they may be located in one place or distributed in multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0098] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly or all or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc., which can store computer program instructions.

[0099] The above description is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present application shall be included in the scope of the claims of the present application.

Claims

1. A data extraction method, It is characterized in that The method is executed by multiple service instances, and each data extraction is executed by one of the service instances, and two adjacent data extractions are respectively executed by two of the service instances. The method includes: Receive data extraction task instructions; Extract task instructions according to the data and obtain a distributed lock for task execution authority; If one of the multiple service instances obtains the distributed lock, the service instance that obtains the distributed lock obtains the latest extraction time from the data extraction record table, and the data extraction record table records the extraction time of each data extraction performed by each service instance; If the latest extraction time is obtained, the service instance that obtains the distributed lock extracts data between the latest extraction time and the current extraction time in the distributed database.

2. The method according to claim 1, It is characterized in that The method further comprises: If the latest extraction time is not obtained, the service instance that obtains the distributed lock extracts the data in the distributed database before the current extraction time.

3. The method according to claim 1, It is characterized in that The method further comprises: Determine, according to the extraction time of each data extraction, the validity period of the distributed lock held by the service instance that has acquired the distributed lock; If the validity period exceeds the validity period, the distributed lock is released so that other service instances that have not acquired the distributed lock can subsequently acquire the distributed lock.

4. The method according to claim 3, It is characterized in that Determining, according to the extraction time of each data extraction, that the service instance that obtains the distributed lock has a valid time of the distributed lock, including: The sum of the extraction time and the preset delay time for each data extraction is calculated, and the calculated sum is used as the effective time for the service instance that obtains the distributed lock to have the distributed lock.

5. The method according to claim 1, It is characterized in that The data extraction record table also includes a service identifier of each service instance, and the method further includes: After extracting data from the distributed database, the service instance that obtains the distributed lock writes the current extraction time into the data extraction record table, and the written current extraction time corresponds to the service identifier of the service instance that obtains the distributed lock.

6. The method according to claim 5, It is characterized in that The method further comprises: If an abnormal situation occurs in the service instance that obtains the distributed lock, resulting in failure to extract data between the latest extraction time and the current extraction time in the distributed database and / or failure to write the current extraction time into the data extraction record table, it is determined that the data extraction is to be rolled back, and the rollback operation is used to indicate returning to the state before the service instance that obtains the distributed lock performed data extraction.

7. The method according to claim 6, It is characterized in that The method further comprises: After the rollback operation is performed, the other service instances that have not acquired the distributed lock acquire the distributed lock, and after acquiring the distributed lock, extract data between the latest extraction time and the current extraction time in the distributed database.

8. A data extraction device, It is characterized in that The device is arranged in a plurality of service instances, and each data extraction is performed by one of the service instances, and two adjacent data extractions are respectively performed by two of the service instances. The device comprises: A receiving unit configured to receive a data extraction task instruction; A first acquisition unit is configured to extract a task instruction according to the data and acquire a distributed lock of a task execution authority; A second acquisition unit is configured to, if a service instance among the multiple service instances acquires the distributed lock, obtain the latest extraction time from the data extraction record table by the service instance that acquires the distributed lock, wherein the data extraction record table records the extraction time of each data extraction performed by each service instance; The extraction unit is configured to extract data between the latest extraction time and the current extraction time in the distributed database by the service instance that obtains the distributed lock if the latest extraction time is obtained.

9. A computer program product, It is characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium and are suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, which are loaded and executed by a processor to implement the operations performed by the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Incremental data capturing and extraction method based on timestamps and logs

    CN102915336A

  • Incremental data extraction method, device and server

    CN109213817A

  • Data extraction method and device and storage medium

    CN112035446A

  • Distributed lock setting method and device

    CN115543640A

  • Realization method of redis distributed lock

    CN115794847A

Cited By

  • UPF high availability method and device based on Redis, equipment and medium

    CN120111543A

  • Redis-based upf high availability method, device, equipment and medium

    CN120111543B