Global anti-duplication method and device for heterogeneous database, electronic equipment and storage medium
By using the global anti-duration method in heterogeneous databases, querying business identification information and performing anti-duration control in accordance with the global reliance strategy, the problem of inability to effectively prevent repeated storage of database data in the existing technology is solved, and the saving of storage space and effective anti-duration of databases is achieved.
Patent Information
- Application Number
- CN202411941596.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, it is impossible to effectively prevent duplicate storage of data in the database, resulting in excessive storage space and may lead to database crashes, which will in turn be unable to effectively prevent heavy loads.
The global anti-duration method of heterogeneous database is adopted, and the business identification information is queried in the target control table stored in the second database in the heterogeneous database, and the heterogeneous database is subject to anti-duration control according to the global judgment strategy based on the query results.
It effectively avoids the heterogeneous database storing multiple records of duplicate business processing, saves storage space, and realizes effective prevention of the database.
Smart Images

Figure CN119884096A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a global anti-duplication method, device, electronic device and storage medium for heterogeneous databases. Background Art
[0002] Transaction processing is the core point of designing a database management system. In order to avoid users making duplicate payments, a business anti-duplicate table is currently often designed using the business unique key as the unique index to achieve anti-duplicate protection. As time goes by, the storage space required for the business anti-duplicate table becomes larger and larger. Due to the capacity limitation of the database, the database is prone to crashes, resulting in data loss, and thus the technical problem of being unable to effectively prevent duplicate databases.
[0003] With regard to the technical problem that related technologies cannot effectively prevent database duplication, no effective solution has been proposed so far. Summary of the Invention
[0004] The main purpose of this application is to provide a global anti-duplication method, device, electronic device and storage medium for heterogeneous databases to solve the technical problem in related technologies that databases cannot be effectively prevented from duplication.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a global anti-duplicate method for heterogeneous databases is provided. The method comprises: obtaining a business request of a first database in a heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent the target object's operational requirements for the first database; in response to the business request, querying the business identification information of the task corresponding to the business request in the target control table stored in the second database in the heterogeneous database to obtain a query result, wherein the query result is used to represent whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than that of the first database; based on the query result, performing anti-duplicate control on the heterogeneous database according to the global duplicate detection strategy, wherein the global duplicate detection strategy is used to represent the rules for performing anti-duplicate control on the heterogeneous database.
[0006] Optionally, the target control table includes: a target inventory anti-duplication control table and a target business anti-duplication control table. Before obtaining the business request of the first database in the heterogeneous database, the method also includes: obtaining the initial business anti-duplication control table of the first database, and the initial inventory anti-duplication control table of the second database; based on the transaction information of the first database within the target time period, updating the initial business anti-duplication control table to obtain the target business anti-duplication control table; based on the initial inventory anti-duplication control table and the target business anti-duplication control table, determining the target inventory anti-duplication control table.
[0007] Optionally, based on the initial inventory anti-duplication control table and the target business anti-duplication control table, the target inventory anti-duplication control table is determined, including: storing the target business anti-duplication control table in a second database, and updating the initial inventory anti-duplication control table based on the target business anti-duplication control table to obtain the target inventory anti-duplication control table.
[0008] Optionally, based on the query results, anti-duplication control is performed on heterogeneous databases according to the global duplication detection strategy, including: in response to the query result that the business identification information has been queried in the target control table, generating a rejection execution instruction, wherein the rejection execution instruction is used to represent the rejection of the execution business request; in response to the query result that the business identification information has not been queried in the target control table, generating a target anti-duplication record, and storing the target anti-duplication record in the target business anti-duplication control table of the target control table.
[0009] Optionally, in response to a business request, the business identification information of the task corresponding to the business request is queried in the target control table stored in the second database of the heterogeneous database to obtain a query result, including: obtaining the data transaction status of the first database; determining the usage status of the target control table based on the data transaction status; in response to the usage status being a normal usage status, based on the business request, querying the business identification information in the target control table to obtain a query result.
[0010] Optionally, based on the data transaction status, determining the usage status of the target control table includes: in response to the data transaction status being that the data in the first database is in a normal transaction status, calling the query service of the second database to obtain a call result, wherein the call result is used to indicate that the first database successfully calls the query service; based on the call result, determining the flow switching operation of the first database, wherein the flow switching operation is used to indicate that the data in the first database is synchronously stored in the second database; based on the flow switching operation, determining that the usage status of the target control table is a normal usage status.
[0011] Optionally, the method also includes: in response to the data transaction status being that the data in the first database is in an abnormal transaction status, determining that the usage status is an abnormal usage status; based on the abnormal usage status, triggering a transaction rollback instruction; and generating transaction rollback information in response to the transaction rollback instruction.
[0012] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a global anti-duplicate device for heterogeneous databases is provided. The device comprises: a first acquisition unit, for acquiring a business request of a first database in a heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent the operation requirements of the target object on the first database; a query unit, for responding to the business request, querying the business identification information of the task corresponding to the business request in the target control table stored in the second database in the heterogeneous database to obtain a query result, wherein the query result is used to represent whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than that of the first database; a control unit, for performing anti-duplicate control on the heterogeneous database according to the global duplicate detection strategy based on the query result, wherein the global duplicate detection strategy is used to represent the rules for performing anti-duplicate control on the heterogeneous database.
[0013] Optionally, the target control table includes: a target inventory anti-duplication control table and a target business anti-duplication control table. Before obtaining the business request of the first database in the heterogeneous database, the device also includes: a second acquisition unit, used to obtain the initial business anti-duplication control table of the first database, and the initial inventory anti-duplication control table of the second database; an update unit, used to update the initial business anti-duplication control table based on the transaction information of the first database within the target time period to obtain the target business anti-duplication control table; a determination unit, used to determine the target inventory anti-duplication control table based on the initial inventory anti-duplication control table and the target business anti-duplication control table.
[0014] Optionally, the determination unit may include: an updating module, configured to store the target service anti-duplicate control table in the second database, and update the initial stock anti-duplicate control table based on the target service anti-duplicate control table to obtain the target stock anti-duplicate control table.
[0015] Optionally, the control unit may include: a first generation module for generating a rejection execution instruction in response to the query result that the business identification information has been queried in the target control table, wherein the rejection execution instruction is used to represent the rejection of the execution business request; a second generation module for generating a target anti-duplication record in response to the query result that the business identification information has not been queried in the target control table, and storing the target anti-duplication record in the target business anti-duplication control table of the target control table.
[0016] Optionally, the query unit may include: an acquisition module for acquiring the data transaction status of the first database; a first determination module for determining the usage status of the target control table based on the data transaction status; a query module for querying the business identification information in the target control table based on the business request in response to the usage status being a normal usage status to obtain the query result.
[0017] Optionally, the first determination module may include: a calling submodule, used to call the query service of the second database in response to the data transaction status being that the data in the first database is in a normal transaction status, and obtain a calling result, wherein the calling result is used to indicate that the first database successfully calls the query service; a first determination submodule, used to determine the flow switching operation of the first database based on the calling result, wherein the flow switching operation is used to indicate that the data in the first database is synchronously stored in the second database; a second determination submodule, used to determine that the usage status of the target control table is a normal usage status based on the flow switching operation.
[0018] Optionally, the query unit may also include: a second determination module, used to determine that the usage status is an abnormal usage status in response to the data transaction status being that the data in the first database is in an abnormal transaction status; a triggering module, used to trigger a transaction rollback instruction based on the abnormal usage status; and a third generation module, used to generate transaction rollback information in response to the transaction rollback instruction.
[0019] In an embodiment of the present application, a business request of a first database in a heterogeneous database can be obtained. Based on the business request, the business identification information of the task corresponding to the business request can be queried in the target control table stored in the second database in the heterogeneous database to obtain the query result. Then, based on the query result, the heterogeneous database can be controlled to prevent duplication according to the global duplication detection strategy to avoid the heterogeneous database storing multiple records of a certain business processing, effectively saving the storage space of the heterogeneous database, thereby achieving the technical effect of effectively preventing duplication of the database and solving the technical problem of being unable to effectively prevent duplication of the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:
[0021] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a global anti-duplicate method for heterogeneous databases is shown;
[0022] Figure 2 is a flow chart of a global anti-duplicate method for heterogeneous databases according to an embodiment of the present application;
[0023] Figure 3 is a schematic diagram of preventing duplication in heterogeneous databases according to an embodiment of the present application;
[0024] Figure 4 is a schematic diagram of a global anti-duplication device for a heterogeneous database according to an embodiment of the present application;
[0025] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] According to an embodiment of the present application, a method embodiment of a global anti-duplication method for heterogeneous databases is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a global anti-duplicate method for heterogeneous databases is shown. Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0030] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0031] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the global anti-duplication method for heterogeneous databases in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, realizing the above-mentioned global anti-duplication method for heterogeneous databases. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include but are not limited to the Internet, corporate intranet, local area network, mobile communication network and combinations thereof.
[0032] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0033] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0034] Under the above operating environment, this application provides Figure 2 The global anti-duplication method for heterogeneous databases shown. Figure 2 This is a flowchart of a global anti-duplicate method for heterogeneous databases according to an embodiment of the present application, which mainly includes the following steps:
[0035] Step S201: Obtain a service request of a first database in a heterogeneous database.
[0036] In step S201 of an embodiment of the present application, a business request of a first database in a heterogeneous database can be obtained, where the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent the target object's operational requirements for the first database, which can be called a business processing request.
[0037] Optionally, the first database may be a lightweight database, such as a Structured Query Language (MySQL) database, wherein the MySQL database is an open source relational database management system that is suitable for small projects and can be quickly built and deployed.
[0038] Optionally, the target object can be an operator. Operation requirements are used to represent operations such as accessing, modifying, querying, and managing data in the database. It should be noted that these operation requirements include, but are not limited to, inserting new data, updating existing data, deleting data, querying data, filtering data, and joining data, thereby satisfying the target object's various requirements for the database data.
[0039] Step S202 : In response to the service request, the target control table stored in the second database of the heterogeneous database is searched for service identification information of the task corresponding to the service request to obtain a search result.
[0040] In step S202 of an embodiment of the present application, after obtaining the business request, the business identification information of the task corresponding to the business request is queried in the target control table stored in the second database in the heterogeneous database according to the business request to obtain a query result, wherein the query result is used to characterize whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database.
[0041] Optionally, the business identification information may be represented by a business unique key, wherein the business unique key is used to uniquely identify the task corresponding to the business request. The second database may be an enterprise-level database, such as an Oracle database, wherein the Oracle database is suitable for large-scale projects and has rich functions and high performance.
[0042] It should be noted that this is only a preferred implementation method for obtaining the query results of the target control table, and does not specifically limit the process and method of obtaining the query results of the target control table. As long as it is in response to a business request, the business identification information of the task corresponding to the business request is queried in the target control table stored in the second database of the heterogeneous database, and the process and method of obtaining the query results are all within the scope of protection of this application and are not listed here.
[0043] Step S203: Based on the query result, anti-duplicate control is performed on the heterogeneous database according to the global duplicate detection strategy.
[0044] In step S203 of the embodiment of the present application, based on the query results obtained in the above steps, anti-duplicate control can be performed on the heterogeneous database according to the global duplicate detection strategy, so as to achieve the purpose of deduplication of the heterogeneous database and save the storage space of the heterogeneous database. The global duplicate detection strategy is used to represent the rules for anti-duplicate control of the heterogeneous database. Heterogeneous databases can choose different types of database systems for deployment and management according to user needs, thereby better meeting different application scenarios and data processing requirements.
[0045] Optionally, in order to improve data security, the data in the first database can be synchronously stored in the second database. In order to save storage space of heterogeneous databases and improve the flexibility of calling data in heterogeneous databases, a global duplicate detection strategy is used to perform duplicate detection on tasks to be executed in heterogeneous databases. If the task to be executed at this time is a repeated task, there is no need to execute it; if the task to be executed is not a repeated task, a corresponding duplicate record is generated for the next judgment.
[0046] It should be noted that this is only a preferred implementation method for anti-duplicate control of heterogeneous databases, and does not specifically limit the process and method of anti-duplicate control of heterogeneous databases. As long as the process and method of anti-duplicate control of heterogeneous databases are based on the query results and the global duplicate judgment strategy, they are within the scope of protection of this application and will not be listed here.
[0047] Furthermore, the business request of the second database in the heterogeneous database can be obtained. In response to the business request of the second database, the business identification information of the task corresponding to the business request of the second database at this time is queried in the target control table to obtain the target query result. Based on the target query result, anti-duplication control is performed on the heterogeneous database according to the global duplication detection strategy.
[0048] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, the target control table includes: a target inventory anti-duplication control table and a target business anti-duplication control table. Before obtaining the business request of the first database in the heterogeneous database, the method also includes: obtaining the initial business anti-duplication control table of the first database, and the initial inventory anti-duplication control table of the second database; based on the transaction information of the first database within the target time period, updating the initial business anti-duplication control table to obtain the target business anti-duplication control table; based on the initial inventory anti-duplication control table and the target business anti-duplication control table, determining the target inventory anti-duplication control table.
[0049] In this embodiment, the initial business anti-duplication control table of the first database and the initial stock anti-duplication control table of the second database can be obtained first, and then the initial business anti-duplication control table can be updated according to the transaction information of the first database within the target time period to obtain the target business anti-duplication control table, and then the target stock anti-duplication control table can be determined based on the above-obtained initial stock anti-duplication control table and target business anti-duplication control table.
[0050] Optionally, the target existing duplicate prevention control table is used to represent existing service records to be processed in the heterogeneous database. The target service duplicate prevention control table can be called a new service duplicate prevention table, used to represent new service records to be processed in the first database.
[0051] Optionally, the target time period can be a preset time period, such as 20 minutes, half an hour, etc. Transaction information is used to represent transaction records in the first database. The target business duplicate prevention control table may include physical primary keys, such as region, year, voucher type, voucher number, and detail number. It should be noted that this is only an example of a physical primary key and does not specifically limit the type of physical primary key.
[0052] Optionally, the transaction information is stored in real time in the transaction details table of the first database, and the transaction details table is synchronously stored in the second database. The initial business anti-duplicate control table is updated based on the transaction details table to achieve the purpose of obtaining the target business anti-duplicate control table, so as to obtain the real-time transaction data of the first database and achieve the effect of quickly processing real-time data.
[0053] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, a target stock anti-duplication control table is determined based on the initial stock anti-duplication control table and the target business anti-duplication control table, including: storing the target business anti-duplication control table in a second database, and updating the initial stock anti-duplication control table based on the target business anti-duplication control table to obtain the target stock anti-duplication control table.
[0054] In this embodiment, after obtaining the target service duplicate prevention control table, the target service duplicate prevention control table is stored in the second database, and then the initial existing duplicate prevention control table is updated based on the target service duplicate prevention control table to obtain the target existing duplicate prevention control table. The target service duplicate prevention control table is stored in a newly added table in the second database.
[0055] For example, the target business anti-duplication control table updated in real time in the MySQL database is synchronously stored in the Oracle database, and then the initial stock anti-duplication control table is updated using the Oracle database based on the target business anti-duplication control table, thereby obtaining the target stock anti-duplication control table. That is, the relevant data involved in the Oracle database is updated according to the real-time data in the MySQL database, thereby achieving the effect of improving the data storage security of the MySQL database.
[0056] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, based on the query results, anti-duplication control is performed on the heterogeneous database in accordance with the global duplication detection strategy, including: in response to the query result that the business identification information has been queried in the target control table, generating a rejection execution instruction, wherein the rejection execution instruction is used to represent the rejection of the execution business request; in response to the query result that the business identification information has not been queried in the target control table, generating a target anti-duplication record, and storing the target anti-duplication record in the target business anti-duplication control table of the target control table.
[0057] In this embodiment, after obtaining the query result, if the query result at this time is that the business identification information has been queried in the target control table, a rejection execution instruction needs to be generated; if the query result at this time is that the business identification information has not been queried in the target control table, a target anti-duplication record can be generated, and the target anti-duplication record can be stored in the target business anti-duplication control table of the target control table.
[0058] For example, based on the business unique key, the target stock anti-duplicate control table and the newly added business anti-duplicate table are queried respectively. If the business unique key does not exist in both tables, a new anti-duplicate record is added to the initial business anti-duplicate table; if the business unique key exists in both tables, the transaction operation at this time is rejected, so as to achieve the effect of anti-duplicate control of pending businesses in heterogeneous databases.
[0059] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, in response to a business request, the business identification information of the task corresponding to the business request is queried in the target control table stored in the second database of the heterogeneous database to obtain a query result, including: obtaining the data transaction status of the first database; determining the usage status of the target control table based on the data transaction status; in response to the usage status being a normal usage status, querying the business identification information in the target control table based on the business request to obtain a query result.
[0060] In this embodiment, the data transaction status of the first database can be obtained, and then the usage status of the target control table can be determined based on the data transaction status. If the usage status of the target control table is normal at this time, it means that the target control table can perform storage operations normally. Then, according to the business request, the business identification information is queried in the target control table to achieve the purpose of obtaining the query results.
[0061] For example, by obtaining the data transaction status of the MySQL database, the purpose of determining the usage status of the target control table can be achieved based on the data transaction status of the MySQL database at this time. When the target control table is in normal usage at this time, a query operation can be performed on the target control table to obtain the query results, thereby achieving the effect of quickly obtaining the query results.
[0062] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, the usage status of the target control table is determined based on the data transaction status, including: in response to the data transaction status being that the data in the first database is in a normal transaction status, calling the query service of the second database to obtain a call result, wherein the call result is used to characterize that the first database successfully calls the query service; based on the call result, determining the flow switching operation of the first database, wherein the flow switching operation is used to characterize the synchronous storage of the data in the first database to the second database; based on the flow switching operation, determining that the usage status of the target control table is a normal usage status.
[0063] In this embodiment, after obtaining the data transaction status, if the data transaction status is that the data in the first database is in a normal transaction state, the query service of the second database can be called to obtain the call result, and then based on the call result, the flow switching operation of the first database is determined to achieve the synchronization storage of the data in the first database to the second database. Furthermore, based on the flow switching operation obtained above, it is determined that the usage status of the target control table at this time is a normal usage status.
[0064] For example, when the data transaction status of the MySQL database is in a normal transaction status, the query service of the Oracle database can be called. If the query service is successfully called, the data of the MySQL database will be synchronized and stored in the Oracle database, which means that the target control table can be used normally at this time. Among them, the query service only needs to be called before the flow switching operation is completed. After the MySQL database carries the full transaction and the transaction is stable, the call can be disconnected through the technical switch.
[0065] Optionally, the MySQL database has a total of 32 nodes, the concurrency limit of asynchronous tasks is 10, the average processing time is 2.5 seconds (two payment processing), and the current maximum business concurrency is 217 transactions / second; the Oracle database has a total of 4 nodes, the average query service time is less than 100 milliseconds (ms), and the evaluation concurrency limit is set to 10.
[0066] It should be noted that this is only a preferred implementation method for determining that the usage status of the target control table is a normal usage status, and does not specifically limit the process and method for determining that the usage status of the target control table is a normal usage status. As long as it is based on the data transaction status, the process and method for determining that the usage status of the target control table is a normal usage status are within the scope of protection of this application and will not be listed here.
[0067] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, the method also includes: in response to the data transaction status being that the data in the first database is in an abnormal transaction state, determining that the usage status is an abnormal usage state; based on the abnormal usage state, triggering a transaction rollback instruction; and generating transaction rollback information in response to the transaction rollback instruction.
[0068] In this embodiment, when the data transaction status is that the data in the first database is in an abnormal transaction state, it can be determined that the usage status of the target control table at this time is an abnormal usage state. Based on the abnormal usage status obtained above, a transaction rollback instruction can be triggered, and transaction rollback information is generated in response to the transaction rollback instruction.
[0069] For example, when the query service has an abnormal situation and cannot be called, the transaction will fail and need to be processed manually. At this time, the heterogeneous database supports voucher return or repayment without external impact, thus achieving the effect of using heterogeneous database to effectively avoid duplicate payments.
[0070] It should be noted that this is only a preferred implementation method for obtaining transaction rollback information, and does not specifically limit the process and method for obtaining transaction rollback information.
[0071] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, a business request of a first database in a heterogeneous database can be obtained. Based on the business request, the business identification information of the task corresponding to the business request can be queried in the target control table stored in the second database in the heterogeneous database to obtain the query result. Then, based on the query result, the heterogeneous database can be controlled for anti-duplication according to the global duplication detection strategy to avoid the heterogeneous database storing multiple records of a certain business processing, effectively saving the storage space of the heterogeneous database, thereby achieving the technical effect of effectively preventing duplication of the database and solving the technical problem of being unable to effectively prevent duplication of the database.
[0072] The technical solutions of the embodiments of the present application are illustrated below with reference to preferred implementation methods.
[0073] Transaction processing is a core element of database management system design. Standard end-to-end business duplication prevention solutions exist to guide implementation. Currently, duplication prevention is achieved by designing business duplication prevention tables using business unique keys as unique indexes. However, with the advancement of information technology and architectural transformation, application architectures have generally changed. Over time, the storage space required for business duplication prevention tables has increased. Due to database capacity limitations, database crashes are prone to occur, leading to data loss and, consequently, the inability to effectively prevent database duplication.
[0074] In order to solve the above problems, the present application proposes a global anti-duplication method for heterogeneous databases, which includes: obtaining a business request of a first database in a heterogeneous database, and according to the business request, querying the business identification information of the task corresponding to the business request in the target control table stored in the second database in the heterogeneous database to obtain the query result, and then according to the query result, the heterogeneous database can be controlled for anti-duplication according to the global duplication detection strategy to avoid the heterogeneous database storing multiple records of a certain business processing, effectively saving the storage space of the heterogeneous database, thereby achieving the technical effect of effectively preventing duplication of the database, and solving the technical problem of being unable to effectively prevent duplication of the database.
[0075] In this embodiment, Figure 3Schematic diagram of anti-duplication for heterogeneous databases according to an embodiment of the present application. Figure 3 As shown, after the MySQL database receives the business processing request, it can update the voucher duplicate detection control table and the transaction detail table, and then synchronize the updated voucher duplicate detection control table to the target inventory anti-duplication control table in the Oracle database. According to the business processing request, the MySQL database can be used to determine the business unique key corresponding to the business processing request, and the business unique key can be synchronized and stored in the target business anti-duplication control table of the Oracle database. The target business anti-duplication control table contains a business anti-duplication table, and the business anti-duplication table includes a physical primary key, such as year, voucher number, and detail number. Among them, the voucher duplicate detection control table is used to represent the duplicate detection records of the vouchers corresponding to the business processing request in the MySQL database.
[0076] In this embodiment, a global anti-duplicate service is established based on the Oracle database, providing anti-duplicate capabilities for the MySQL database. Before executing a transaction in the MySQL database, the global anti-duplicate service in the Oracle database is invoked. Based on the business unique key, the target existing anti-duplicate control table and the newly added business anti-duplicate table are queried. If the business unique key does not exist in either table, a new anti-duplicate record is added to the business anti-duplicate table. If it does exist, the transaction is rejected. The global anti-duplicate service supports anti-hanging.
[0077] Optionally, the MySQL database has a total of 32 nodes, the concurrency limit of asynchronous tasks is 10, the average processing time is 2.5 seconds (two payment processing), and the current maximum business concurrency is 217 transactions / second; the Oracle database has a total of 4 nodes, the average query service time is less than 100 milliseconds (ms), and the evaluation concurrency limit is set to 10.
[0078] Optionally, add global duplicate detection logic to the Oracle database. This logic queries both the target existing duplicate prevention control table and the newly added business duplicate prevention table for the presence of a unique business key. If the unique business key does not exist in either table, a new duplicate prevention record is added to the business duplicate prevention table; if it does exist, the transaction is rejected. The target existing duplicate prevention control table represents existing business records awaiting duplicate prevention in heterogeneous databases, while the newly added business duplicate prevention table represents newly added business records awaiting duplicate prevention in the MySQL database.
[0079] Optionally, the query service only needs to be called before the flow switching operation is completed. Once the MySQL database carries the full amount of transactions and the transactions are stable, the call can be disconnected through the technical switch.
[0080] Optionally, when the query service has an abnormal situation and cannot be called, the transaction will fail and manual processing is required. At this time, the heterogeneous database supports voucher return or repayment without external impact, thereby achieving the effect of effectively avoiding duplicate payments by using heterogeneous databases.
[0081] Optionally, heterogeneous databases can establish an end-to-end anti-duplicate mechanism based on business unique keys transmitted downstream. This allows for operations such as switching, switching back, and emergency changes to be performed on heterogeneous databases. Switching is used to transfer data from one database to another. Switching back is used to roll back data from the target database to the source database. Emergency changes are used to make urgent modifications or adjustments to the database to address emergencies or failures.
[0082] In the global anti-duplication method for heterogeneous databases provided in an embodiment of the present application, a business request of a first database in a heterogeneous database can be obtained. Based on the business request, the business identification information of the task corresponding to the business request can be queried in the target control table stored in the second database in the heterogeneous database to obtain the query result. Then, based on the query result, the heterogeneous database can be controlled for anti-duplication according to the global duplication detection strategy to avoid the heterogeneous database storing multiple records of a certain business processing, effectively saving the storage space of the heterogeneous database, thereby achieving the technical effect of effectively preventing duplication of the database and solving the technical problem of being unable to effectively prevent duplication of the database.
[0083] The present application also provides a global anti-duplicate device for heterogeneous databases. It should be noted that the global anti-duplicate device for heterogeneous databases in the present application can be used to execute the global anti-duplicate method for heterogeneous databases provided in the present application. The following describes the global anti-duplicate device for heterogeneous databases provided in the present application.
[0084] According to an embodiment of the present application, a device for implementing the above-mentioned global anti-duplicate method for heterogeneous databases is also provided. Figure 4 Schematic diagram of a global anti-duplication device for heterogeneous databases according to an embodiment of the present application. Figure 4 As shown, the device includes:
[0085] The first acquisition unit 401 is configured to acquire a business request of a first database in a heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent an operation requirement of a target object on the first database.
[0086] The query unit 402 is used to query the business identification information of the task corresponding to the business request in the target control table stored in the second database of the heterogeneous database in response to the business request, and obtain a query result, wherein the query result is used to indicate whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database.
[0087] The control unit 403 is configured to perform anti-duplicate control on the heterogeneous database according to the global duplicate detection strategy based on the query result, wherein the global duplicate detection strategy is used to represent a rule for performing anti-duplicate control on the heterogeneous database.
[0088] In the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, a business request of a first database in a heterogeneous database is obtained through a first acquisition unit, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent the operation requirements of the target object on the first database; the query unit responds to the business request and queries the business identification information of the task corresponding to the business request in the target control table stored in the second database in the heterogeneous database to obtain a query result, wherein the query result is used to represent whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database; the control unit performs anti-duplication control on the heterogeneous database based on the query result in accordance with the global duplication detection strategy, wherein the global duplication detection strategy is used to represent the rules for anti-duplication control on heterogeneous databases, which solves the technical problem in the related technology that the database cannot be effectively prevented from being duplicated, thereby achieving the technical effect of effectively preventing duplication on the database.
[0089] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the target control table includes: a target inventory anti-duplication control table and a target business anti-duplication control table. Before obtaining the business request of the first database in the heterogeneous database, the device also includes: a second acquisition unit, used to obtain the initial business anti-duplication control table of the first database, and the initial inventory anti-duplication control table of the second database; an update unit, used to update the initial business anti-duplication control table based on the transaction information of the first database within the target time period to obtain the target business anti-duplication control table; a determination unit, used to determine the target inventory anti-duplication control table based on the initial inventory anti-duplication control table and the target business anti-duplication control table.
[0090] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the determination unit may include: an update module for storing the target business anti-duplication control table in a second database, and updating the initial stock anti-duplication control table based on the target business anti-duplication control table to obtain the target stock anti-duplication control table.
[0091] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the control unit 403 may include: a first generation module for generating a refuse to execute instruction in response to a query result that the business identification information has been queried in the target control table, wherein the refuse to execute instruction is used to represent a refusal to execute a business request; a second generation module for generating a target anti-duplication record in response to a query result that the business identification information has not been queried in the target control table, and storing the target anti-duplication record in the target business anti-duplication control table of the target control table.
[0092] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the query unit 402 may include: an acquisition module for acquiring the data transaction status of the first database; a first determination module for determining the usage status of the target control table based on the data transaction status; and a query module for querying the business identification information in the target control table based on the business request in response to the usage status being a normal usage status to obtain a query result.
[0093] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the first determination module may include: a calling sub-module, for calling the query service of the second database in response to the data transaction status being that the data in the first database is in a normal transaction state, and obtaining a calling result, wherein the calling result is used to characterize that the first database successfully calls the query service; a first determination sub-module, for determining the flow switching operation of the first database based on the calling result, wherein the flow switching operation is used to characterize the synchronous storage of the data in the first database to the second database; and a second determination sub-module, for determining that the usage status of the target control table is a normal usage status based on the flow switching operation.
[0094] Optionally, in the global anti-duplication device for heterogeneous databases provided in an embodiment of the present application, the query unit 402 may further include: a second determination module for determining that the usage status is an abnormal usage status in response to the data transaction status being that the data in the first database is in an abnormal transaction status; a triggering module for triggering a transaction rollback instruction based on the abnormal usage status; and a third generation module for generating transaction rollback information in response to the transaction rollback instruction.
[0095] It should be noted that the above-mentioned modules or units can be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above-mentioned modules can also be run as part of the device in the computer terminal 10 provided in Example 1.
[0096] An embodiment of the present application may provide an electronic device, Figure 5 This is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 5As shown, the electronic device may include: one or more ( Figure 5 Only one is shown) processor 502, memory 504, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0097] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0098] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain a business request of the first database in the heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent the target object's operation requirements for the first database; in response to the business request, query the business identification information of the task corresponding to the business request in the target control table stored in the second database in the heterogeneous database to obtain a query result, wherein the query result is used to represent whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database; based on the query result, perform anti-duplication control on the heterogeneous database according to the global duplication detection strategy, wherein the global duplication detection strategy is used to represent the rules for anti-duplication control on the heterogeneous database.
[0099] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: the target control table includes: a target inventory anti-duplication control table and a target business anti-duplication control table. Before obtaining the business request of the first database in the heterogeneous database, it is also used to perform the following steps: obtain the initial business anti-duplication control table of the first database, and the initial inventory anti-duplication control table of the second database; based on the transaction information of the first database within the target time period, update the initial business anti-duplication control table to obtain the target business anti-duplication control table; based on the initial inventory anti-duplication control table and the target business anti-duplication control table, determine the target inventory anti-duplication control table.
[0100] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: based on the initial inventory anti-duplication control table and the target business anti-duplication control table, determine the target inventory anti-duplication control table, including: storing the target business anti-duplication control table in a second database, and updating the initial inventory anti-duplication control table based on the target business anti-duplication control table to obtain the target inventory anti-duplication control table.
[0101] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: based on the query result, anti-duplication control is performed on the heterogeneous database according to the global duplication detection strategy, including: in response to the query result that the business identification information has been queried in the target control table, generating a rejection execution instruction, wherein the rejection execution instruction is used to represent the rejection of the execution business request; in response to the query result that the business identification information has not been queried in the target control table, generating a target anti-duplication record, and storing the target anti-duplication record in the target business anti-duplication control table of the target control table.
[0102] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: in response to the business request, query the business identification information of the task corresponding to the business request in the target control table stored in the second database of the heterogeneous database to obtain the query result, including: obtaining the data transaction status of the first database; based on the data transaction status, determining the usage status of the target control table; in response to the usage status being a normal usage status, querying the business identification information in the target control table based on the business request to obtain the query result.
[0103] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: based on the data transaction status, determine the usage status of the target control table, including: in response to the data transaction status being that the data in the first database is in a normal transaction state, call the query service of the second database to obtain a call result, wherein the call result is used to indicate that the first database successfully calls the query service; based on the call result, determine the flow switching operation of the first database, wherein the flow switching operation is used to indicate that the data in the first database is synchronously stored in the second database; based on the flow switching operation, determine that the usage status of the target control table is a normal usage status.
[0104] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: in response to the data transaction status being that the data in the first database is in an abnormal transaction state, determine that the usage status is an abnormal usage state; based on the abnormal usage state, trigger a transaction rollback instruction; in response to the transaction rollback instruction, generate transaction rollback information.
[0105] By using an embodiment of the present application, a global duplicate prevention method for heterogeneous databases is provided. A business request of a first database in a heterogeneous database can be obtained. Based on the business request, the business identification information of the task corresponding to the business request is queried in a target control table stored in a second database in the heterogeneous database to obtain a query result. Then, based on the query result, duplicate prevention control can be performed on the heterogeneous database according to a global duplicate detection strategy, avoiding the heterogeneous database from storing multiple records of a certain business process, effectively saving the storage space of the heterogeneous database, thereby achieving the technical effect of effectively preventing duplicates in the database and solving the technical problem of being unable to effectively prevent duplicates in the database.
[0106] It can be understood by those skilled in the art that Figure 5 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID for short), a PAD, or other terminal devices. Figure 5 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 5 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 5 Different configurations shown.
[0107] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0108] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the global anti-duplication method for heterogeneous databases provided in the first embodiment.
[0109] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0110] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the global anti-duplication method for heterogeneous databases.
[0111] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0112] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0113] 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 is only a logical function division. In actual implementation, there may be other division methods, such as 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.
[0114] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0115] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0116] 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 is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0117] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A global anti-duplicate method for heterogeneous databases, characterized in that: include: Acquire a business request of a first database in a heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent an operation requirement of a target object on the first database; In response to the business request, in a target control table stored in a second database in the heterogeneous database, querying business identification information of a task corresponding to the business request to obtain a query result, wherein the query result is used to indicate whether the business identification information is queried in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database; Based on the query result, anti-duplicate control is performed on the heterogeneous database according to a global duplicate detection strategy, wherein the global duplicate detection strategy is used to characterize a rule for performing anti-duplicate control on the heterogeneous database.
2. The method according to claim 1, characterized in that The target control table includes: a target inventory anti-duplicate control table and a target service anti-duplicate control table. Before obtaining a service request of a first database in a heterogeneous database, the method further includes: Obtaining an initial service anti-duplicate control table of the first database and an initial stock anti-duplicate control table of the second database; Based on the transaction information of the first database within the target time period, the initial service anti-duplicate control table is updated to obtain the target service anti-duplicate control table; Based on the initial stock anti-duplicate control table and the target service anti-duplicate control table, the target stock anti-duplicate control table is determined.
3. The method according to claim 2, characterized in that Determining the target stock anti-duplicate control table based on the initial stock anti-duplicate control table and the target service anti-duplicate control table includes: The target service anti-duplicate control table is stored in the second database, and the initial stock anti-duplicate control table is updated based on the target service anti-duplicate control table to obtain the target stock anti-duplicate control table.
4. The method according to claim 1, characterized in that: Based on the query result, anti-duplicate control is performed on the heterogeneous database according to the global duplicate detection strategy, including: In response to the query result that the service identification information has been queried in the target control table, generating a rejection execution instruction, wherein the rejection execution instruction is used to indicate that the service request is rejected; In response to the query result that the service identification information is not found in the target control table, a target anti-duplication record is generated, and the target anti-duplication record is stored in a target service anti-duplication control table of the target control table.
5. The method according to claim 1, characterized in that In response to the service request, in the target control table stored in the second database of the heterogeneous database, the service identification information of the task corresponding to the service request is queried to obtain the query result, including: Acquire the data transaction status of the first database; Based on the data transaction status, determining the usage status of the target control table; In response to the usage status being a normal usage status, based on the service request, the service identification information is queried in the target control table to obtain the query result.
6. The method according to claim 5, characterized in that Determining the use status of the target control table based on the data transaction status includes: In response to the data transaction status being that the data in the first database is in a normal transaction status, calling a query service of the second database to obtain a call result, wherein the call result is used to indicate that the first database successfully calls the query service; Based on the call result, determining a stream switching operation of the first database, wherein the stream switching operation is used to represent synchronous storage of data in the first database to the second database; Based on the flow switching operation, it is determined that the use state of the target control table is a normal use state.
7. The method according to claim 5, characterized in that The method further comprises: In response to the data transaction status being that the data in the first database is in an abnormal transaction status, determining that the usage status is an abnormal usage status; Based on the abnormal usage status, trigger a transaction rollback instruction; In response to the transaction rollback instruction, transaction rollback information is generated.
8. A global anti-duplicate device for heterogeneous databases, characterized in that: include: A first acquisition unit is used to acquire a business request of a first database in a heterogeneous database, wherein the heterogeneous database is used to represent a database composed of different types of database management systems, and the business request is used to represent an operation requirement of a target object on the first database; A query unit, configured to query, in response to the service request, service identification information of a task corresponding to the service request in a target control table stored in a second database in the heterogeneous database, to obtain a query result, wherein the query result is used to indicate whether the service identification information is found in the target control table, and the scenario complexity of the second database is higher than the scenario complexity of the first database; A control unit is used to perform anti-duplicate control on the heterogeneous database according to a global duplicate detection strategy based on the query result, wherein the global duplicate detection strategy is used to characterize a rule for performing anti-duplicate control on the heterogeneous database.
9. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 7 when running.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 7.