Cross-table transaction support method, device and readable storage medium for distributed database

By using the mechanism of suspending record folders and files to be submitted in a distributed database, it supports atomic submission and failure recovery of cross-table transactions, solves the consistency problem in cross-table transaction processing, and improves the efficiency and stability of the database. sex.

CN117971975BActive Publication Date: 2024-10-22OUSHU INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410144419.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-01
Publication Date
2024-10-22
Estimated Expiration
2044-02-01

AI Technical Summary

Technical Problem

Distributed databases may have data consistency issues when processing cross-table transactions, resulting in reduced processing speed and errors. Existing methods are complex and not effective enough.

Method used

By obtaining the pending transaction, determine whether it is a cross-table transaction. If so, call the preset pending record folder for support, create the file to be submitted and submit the relevant tables in sequence to ensure data consistency and fault recovery; if it is not a cross-table transaction, Table transactions are submitted directly.

Benefits of technology

Effectively handle cross-table transactions in distributed databases, improve database efficiency and stability, ensure data integrity and consistency, and provide error handling mechanisms to deal with abnormal situations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117971975B_ABST
    Figure CN117971975B_ABST
Patent Text Reader

Abstract

The present invention discloses a cross-table transaction support method, device and readable storage medium of a distributed database, comprising: obtaining a pending transaction based on a distributed database, and then determining whether the pending transaction is a cross-table transaction. If it is a cross-table transaction, calling a pre-set pending record folder to support the pending transaction; if it is not a cross-table transaction, directly submitting the pending transaction. Such a design can effectively handle the cross-table transaction problem in a distributed database and improve the efficiency and stability of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database management, and in particular to a method, device and readable storage medium for supporting cross-table transactions of a distributed database. Background Art

[0002] With the advent of the big data era, the amount of data is increasing, and traditional stand-alone databases can no longer meet the demand. The emergence of distributed databases solves this problem, but when processing cross-table transactions in distributed databases, data consistency issues may arise. Especially when the transactions to be processed involve multiple tables, the complexity of data updates increases. Current processing methods often require complex coordination and synchronization, which not only affects the processing speed of the database, but may also cause errors. Therefore, how to effectively and securely handle cross-table transactions in distributed databases has become an urgent problem to be solved. Summary of the invention

[0003] The object of the present invention is to provide a method, device and readable storage medium for supporting cross-table transactions in a distributed database.

[0004] In a first aspect, an embodiment of the present invention provides a cross-table transaction support method for a distributed database, comprising:

[0005] Get pending transactions based on distributed databases;

[0006] Determine whether the transaction to be processed is a cross-table transaction;

[0007] If yes, calling a preset pending record folder to support the pending transaction;

[0008] If not, directly submit the pending transaction.

[0009] In a possible implementation, the calling of a preset pending record folder to support the pending transaction includes:

[0010] Acquire multiple related tables of the pending transaction;

[0011] Calling the pending record folder, and creating a file to be submitted in the pending record folder;

[0012] Submitting the multiple related tables in sequence, and recording the table information of the multiple related tables in the file to be submitted;

[0013] When the multiple related tables are submitted normally, the to-be-submitted files are deleted.

[0014] In a possible implementation, calling the pending record folder and creating a file to be submitted in the pending record folder includes:

[0015] Acquire the text length of the table information of the multiple related tables;

[0016] Determining whether the text length exceeds a preset text length threshold;

[0017] If yes, then using the UUIDs of the multiple related tables as file names, creating the to-be-submitted file for storing the table information;

[0018] If not, the table information of the multiple related tables is used as the file name to create the empty file to be submitted.

[0019] In a possible implementation, the method further includes:

[0020] Circularly detecting whether there is any failure in the submission process of the pending transaction;

[0021] If yes, performing fault recovery based on the suspended record folder;

[0022] If not, the step of cyclically detecting whether there is any failure in the submission process of the pending transaction is repeated.

[0023] In a possible implementation, the performing fault recovery based on the suspension record folder includes:

[0024] Scan the to-be-submitted files in the pending record folder, obtain table information storing the to-be-submitted files, and obtain the to-be-submitted information corresponding to the table information;

[0025] Submitting the multiple related tables in sequence according to the information to be submitted;

[0026] When the multiple related tables are submitted normally, the to-be-submitted files are deleted.

[0027] In a possible implementation, the method further includes:

[0028] Determining whether the fault recovery is successful;

[0029] If so, a fault recovery record is generated;

[0030] If not, restart the distributed database, and repeat the step of performing fault recovery based on the suspended record folder until the fault recovery is successful.

[0031] In a possible implementation manner, the related table is compressed in the following manner, including:

[0032] Obtaining the identity number and transaction number of the related table;

[0033] The identity number and the transaction number are encoded into a character string with a length of target bytes based on Base64, thereby completing the compression of the related table.

[0034] In a second aspect, an embodiment of the present invention provides a cross-table transaction support device for a distributed database, comprising:

[0035] An acquisition module, used to acquire pending transactions based on a distributed database;

[0036] The support module is used to determine whether the pending transaction is a cross-table transaction; if so, call a preset pending record folder to support the pending transaction; if not, directly submit the pending transaction.

[0037] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor and a non-volatile memory storing computer instructions, wherein when the computer instructions are executed by the processor, the computer device executes the cross-table transaction support method for a distributed database described in at least one possible implementation of the first aspect.

[0038] In a fourth aspect, an embodiment of the present invention provides a readable storage medium, wherein the readable storage medium includes a computer program, and when the computer program is running, the computer device where the readable storage medium is located is controlled to execute the cross-table transaction support method for a distributed database described in at least one possible implementation of the first aspect.

[0039] Compared with the prior art, the beneficial effects provided by the present invention include: using a distributed database cross-table transaction support method, device and readable storage medium disclosed by the present invention, including: obtaining a pending transaction based on a distributed database, and then determining whether the pending transaction is a cross-table transaction. If it is a cross-table transaction, calling a pre-set pending record folder to support the pending transaction; if it is not a cross-table transaction, directly submitting the pending transaction. Such a design can effectively handle the cross-table transaction problem in the distributed database and improve the efficiency and stability of the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative work.

[0041] Figure 1A schematic diagram of the steps of a cross-table transaction support method for a distributed database provided by an embodiment of the present invention;

[0042] Figure 2 A schematic block diagram of the structure of a cross-table transaction support device for a distributed database provided by an embodiment of the present invention;

[0043] Figure 3 A schematic block diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0045] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings.

[0046] In order to solve the technical problems in the aforementioned background technology, Figure 1 This is a flow chart of a cross-table transaction support method for a distributed database provided in an embodiment of the present disclosure. The cross-table transaction support method for a distributed database is introduced in detail below.

[0047] Step S201, obtaining pending transactions based on a distributed database;

[0048] Step S202, determining whether the transaction to be processed is a cross-table transaction;

[0049] Step S203: If yes, calling a preset pending record folder to support the pending transaction;

[0050] Step S204: if not, directly submit the pending transaction.

[0051] In an embodiment of the present invention, for example, it is assumed that there is a distributed e-commerce platform that uses a distributed database to store user information, order information, inventory information, etc. In this case, the pending transaction can be a user order operation, including creating an order, updating inventory, and deducting money. Assume that the user order operation needs to modify the order information table and the inventory information table at the same time. When the distributed database receives the transaction of the user's order, it will detect that the transaction involves write operations on multiple tables, and therefore judge it as a cross-table transaction. In this step, the distributed database will call a pre-set suspended record folder to support cross-table transactions. The suspended record folder is a special folder for saving the intermediate state of ongoing cross-table transactions. For example, in the above-mentioned e-commerce platform, the distributed database can temporarily save the modification records of the order information table and the inventory information table in the suspended record folder so as to restore or roll back these modifications in the commit phase. If the pending transaction does not involve write operations on multiple tables, that is, it is not a cross-table transaction, the distributed database will directly commit the transaction. For example, suppose there is an operation of a user updating personal information, and only the records in the user information table need to be modified. In this case, there is no need to use a suspended record folder, and the modification can be directly submitted. Through the above steps, the distributed database can call the pending record folder to support the atomicity of cross-table transactions when necessary, depending on whether the pending transaction is a cross-table transaction. This ensures that when a failure or interruption occurs, the distributed database can correctly recover or roll back partially submitted transactions to protect the atomicity of transactions.

[0052] In the embodiment of the present invention, the aforementioned step S203 can be implemented through the following example execution.

[0053] (1) obtaining multiple related tables of the pending transaction;

[0054] (2) calling the pending record folder and creating a file to be submitted in the pending record folder;

[0055] (3) submitting the multiple related tables in sequence, and recording table information of the multiple related tables in the file to be submitted;

[0056] (4) When the multiple related tables are submitted normally, the to-be-submitted files are deleted.

[0057] In the embodiment of the present invention, for example, it is assumed that there is an e-commerce platform, which contains three related database tables of users, orders and products. In this case, the pending transaction may be that the user submits a new order. When the user submits a new order, the system will call the pending record folder and create a pending file in the folder. This pending file will be used to record data related to the order, such as user information, order details and product information. In the above example, the system will submit the three related database tables of users, orders and products in sequence. It will extract the corresponding data from the pending file and insert it into the respective tables. At the same time, the system will also record the submission information of each table in the pending file to track the submission status of each table. When all related tables have successfully submitted data, the system will check the submission information in the pending file. If all tables are successfully submitted, the system will confirm that the transaction has been completed and delete the pending file. Otherwise, the system will issue a warning or execute the corresponding error handling mechanism to handle the unsubmitted table. In this design, through the use of the pending record folder and the pending file, the system can effectively record and track the submission status of each table and complete the transaction after all tables are successfully submitted. This ensures data integrity and consistency while providing error handling mechanisms to deal with exceptional situations.

[0058] In the embodiment of the present invention, the aforementioned steps of calling the suspension record folder and creating the file to be submitted in the suspension record folder can be implemented through the following example.

[0059] (1) obtaining the text length of the table information of the multiple related tables;

[0060] (2) determining whether the text length exceeds a preset text length threshold;

[0061] (3) If yes, then using the UUIDs of the multiple related tables as file names, create the to-be-submitted file for storing the table information;

[0062] (4) If not, use the table information of the multiple related tables as the file name to create the empty file to be submitted.

[0063] In an embodiment of the present invention, illustratively, it is assumed that there is a database management system, which contains multiple related tables, such as a student table, a course table, and a score table. In this scenario, it is necessary to obtain the table information of these tables and calculate their text length. For example, for a student table, information such as the column name, data type, and constraint conditions of the student table can be obtained and converted into text form. Assume that the table information text length of the student table is 10 characters. Assume that in the above scenario, the preset text length threshold is 8 characters. By comparing the obtained table information text length and the threshold, it is determined whether the text length exceeds the set threshold. If the table information text length is 10 characters, it exceeds the preset 8-character threshold. According to the previous judgment results, there are two cases to be processed: If the text length exceeds the preset text length threshold: In this case, the UUIDs of multiple related tables are used as file names to create files to be submitted. For example, assuming that the UUIDs of the student table, course table, and score table are 123, 456, and 789, respectively, then a file named after these UUIDs can be created to store table information. For example, a file to be submitted named "123_456_789.txt" is created, and the table information of multiple related tables is stored in it. If the text length does not exceed the preset text length threshold: In this case, the table information of multiple related tables is used as the file name to create an empty file to be submitted. For example, assuming that the table information of the student table, course table, and grade table can be represented by the string "student_table_course_table_grade_table", then a file to be submitted named "student_table_course_table_grade_table.txt" can be created and set to be empty.

[0064] In the embodiments of the present invention, the following implementation modes are also provided.

[0065] (1) cyclically detecting whether there is any failure in the submission process of the pending transaction;

[0066] (2) If yes, perform fault recovery based on the suspended record folder;

[0067] (3) If not, repeat the step of cyclically detecting whether there is any failure in the submission process of the pending transaction.

[0068] In the embodiment of the present invention, for example, suppose there is an online shopping website. After the user places an order, the system will generate a pending transaction, including operations such as recording order information and deducting money. In this step, the system will cyclically detect whether there is a fault in the submission process of the pending transaction. For example, the system will check whether the order is successfully recorded in the database, whether the deduction is successful, and whether the inventory is correctly updated. If any of the links fails, the system will proceed to the next step. Assuming that the online shopping website system detects that there is a fault in the submission process in the previous step, the system will perform fault recovery through a suspended record folder. This suspended record folder stores relevant information of the pending transaction, such as order content, user information, etc. The system will try to re-execute the submission process based on the information in the suspended record folder, and ensure that all operations are successfully completed, thereby restoring the normal state. In the above steps, the system has performed a detection and fault recovery. However, due to various reasons, the system may still fail to successfully process the pending transaction. Therefore, in this step, the system will repeatedly perform the step of cyclically detecting whether there is a fault in the submission process of the pending transaction. This can be a continuous process until all operations are successfully executed or the preset maximum number of retries is reached.

[0069] In the embodiment of the present invention, the aforementioned step of performing fault recovery based on the suspended record folder can be implemented through the following example.

[0070] (1) Scan the files to be submitted in the pending record folder, obtain table information storing the files to be submitted, and obtain the information to be submitted corresponding to the table information;

[0071] (2) submitting the multiple related tables in sequence according to the information to be submitted;

[0072] (3) When the multiple related tables are submitted normally, the to-be-submitted files are deleted.

[0073] In the embodiment of the present invention, for example, it is assumed that there is an e-commerce website that receives user orders and saves them in files to be submitted. These files to be submitted are stored in the pending record folder. The system regularly scans the pending record folder to check whether there are new files to be submitted. For example, the system scans the folder every 5 minutes. If a file to be submitted named "order123.txt" is found, the system will perform the next step. In the above example, the "order123.txt" file contains order-related data. The system reads the file and extracts the table information therein, such as order number, customer information, product information, etc. Then, the system associates these table information with the information to be submitted. For example, the system extracts the information to be submitted with order number 123 from the file and associates it with the table information. In this example, the system submits multiple related tables in sequence according to the table information contained in the information to be submitted. For example, according to the information to be submitted with order number 123, the system submits the order number, customer information and product information to the corresponding database table in sequence to ensure the accuracy and completeness of the data. The system may use transaction management to ensure that all related tables can be successfully submitted to maintain data consistency. In the above example, the system checks the submission status of each related table to ensure that they have all been successfully submitted. The system may query the database to confirm that the data of each table has been correctly inserted or updated. Only when all related tables have been successfully submitted will the system perform the next step. In the above example, once all related tables have been submitted normally, the system will delete the corresponding pending files. This ensures that the submitted data is not processed repeatedly and keeps the pending record folder tidy and manageable. This design can be used in various scenarios where fault recovery needs to be performed by scanning pending files, such as e-commerce websites, financial transaction systems, etc., to ensure the accuracy and integrity of the data and improve the reliability and recoverability of the system.

[0074] In the embodiments of the present invention, the following implementation modes are also provided.

[0075] (1) Determine whether the fault recovery is successful;

[0076] (2) If yes, generate a fault recovery record;

[0077] (3) If not, restart the distributed database and repeat the steps of performing fault recovery based on the suspended record folder until the fault recovery is successful.

[0078] In an embodiment of the present invention, for example, it is assumed that a company uses a distributed database to manage its customer information. On a certain day, the database cannot operate normally due to a server failure. The system administrator takes fault recovery measures and attempts to restart the database. After the restart, the system automatically checks to determine whether the recovery is successful. If no errors or exceptions are found within a certain period of time, the system determines that the fault recovery is successful. In the above scenario, if the system determines that the fault recovery is successful, it will generate a fault recovery record. The record will contain the time when the fault occurred, the type of fault, the recovery measures taken, and the time when the recovery is successful. This record can be used for future reference and review to better understand the system performance and fault handling process. If the system determines that the recovery fails during the fault recovery attempt, it will trigger a restart operation. This means that the system will shut down the current database process and restart the entire distributed database system. The restart is to try to clear any problems that may cause the failure and prepare for the next recovery attempt. After restarting the distributed database, the system will perform the fault recovery steps based on the suspended record folder again. These steps may involve finding and applying previously saved suspended records to restore the database to the state before the failure. For example, the system may obtain previously unfinished transactions from the suspended record and reapply them to ensure data consistency. After re-executing the steps for failure recovery based on the suspended record folder, the system will judge the failure recovery result again. If the recovery is successful, the system will continue to run and be available to users. If it still cannot be successfully recovered, the system will repeat the restart and recovery steps based on the suspended record until it succeeds. Through these steps, the system can automatically determine whether the failure recovery is successful and take appropriate measures to ensure the normal operation of the distributed database.

[0079] In the embodiment of the present invention, the correlation table is compressed in the following manner.

[0080] (1) Obtaining the identity number and transaction number of the relevant table;

[0081] (2) Encode the identity number and the transaction number into a character string with a length of target bytes based on Base64, thereby completing the compression of the related table.

[0082] In an embodiment of the present invention, for example, it is assumed that there is a distributed database system, which includes multiple tables, such as a user table, an order table, and a product table. Each table has a unique identity number and a transaction number associated with it. In a cross-table transaction, the user table, the order table, and the product table are involved. Assume that the identity number of the user table is 1234, and the transaction number is 567890; the identity number of the order table is 5678, and the transaction number is 987654; the identity number of the product table is 9012, and the transaction number is 345678. These identity numbers and transaction numbers are Base64 encoded to obtain corresponding string representations. For the user table: the identity number 1234 and the transaction number 567890 are Base64 encoded to obtain the string "ABCD".

[0083] For the order table: the identity number 5678 and the transaction number 987654 are Base64 encoded to get the string "EFGH". For the product table: the identity number 9012 and the transaction number 345678 are Base64 encoded to get the string "IJKL". According to the previous content, we can know that the submission information of each table only includes the table ID and transaction number. In this scenario, the strings encoded with the table identity number and transaction number are concatenated as the submission information of the table. Assume that the number of related tables of the cross-table transaction does not exceed 10+. For the cross-table transaction in this example, it includes the user table, order table and product table. Their compressed submission information is:

[0084] User table: ID is "ABCD", transaction number is "567890".

[0085] Order table: ID is "EFGH" and transaction number is "987654".

[0086] Product table: ID is "IJKL" and transaction number is "345678".

[0087] The compressed submission information of these tables is concatenated to obtain the final file name: "ABCD567890EFGH987654IJKL345678". The length of this file name is 30 bytes, which is much smaller than the HDFS file name length limit of 255 bytes.

[0088] Through the above examples, we can see how to use Base64 encoding to compress the identity number and transaction number of the related table to achieve the simplification of table information and generate a file name that meets the file name requirements of the distributed system. This compression method can help manage submission information more effectively when processing cross-table transactions in a distributed system.

[0089] The following provides an overall implementation process of an embodiment of the present invention.

[0090] 1. When a transaction is committed, the following steps are performed:

[0091] If the current transaction involves only a single table, it is directly submitted according to the existing technology to end the current process;

[0092] If multiple tables are involved, create a pending file in the pending folder (i.e. the pending record folder) to record the information of all related tables:

[0093] If the text format of the table information is short, it can be directly used as the file name and created with an empty file;

[0094] If the text format of the table information is long, the UUID is used as the file name to record this information;

[0095] Submit each relevant table in turn until all are completed, then delete the file created in step 2;

[0096] If a failure occurs during the submission process, the entire database will be restarted and the following failure recovery process will be entered

[0097] 2. Fault recovery process:

[0098] Scan all files in the pending folder, parse the pending information one by one, continue to submit the relevant tables in each information, and delete the records in the pending folder after completion

[0099] If a failure occurs during the recovery process, restart the entire database again and retry the current process

[0100] 3. Available table information compression methods:

[0101] The actual submission information of each table only includes the table ID (4 bytes) and its transaction number (6 bytes) in the current transaction. If it is directly converted into a decimal string, it may be long. It can be encoded into a string with a length of 15 bytes in Base64 to ensure that the information is concise and can meet the file name requirements of the distributed system. Taking HDFS as an example, the default length limit of its file name is 255 bytes, so if the number of related tables in a cross-table transaction does not exceed 10+, the submission information can be directly concatenated as the file name.

[0102] With this design, there is additional overhead when using cross-table transaction commits. No other background services are required, so there is no additional deployment and maintenance work. Latency and throughput are affected by the file system. Generally, as the number of concurrent transactions increases, latency remains relatively stable, while throughput can grow linearly.

[0103] The embodiment of the present invention also provides another overall implementation process.

[0104] The implementation process of the cross-table transaction support method of the distributed database is as follows:

[0105] Get pending transactions based on a distributed database.

[0106] Determine whether the pending transaction is a cross-table transaction:

[0107] If the current transaction involves only a single table, it is directly submitted according to the existing technology to end the current process.

[0108] If multiple tables are involved, proceed to the next step.

[0109] In the preset pending record folder, do the following:

[0110] The information of multiple related tables of the transaction to be processed is obtained.

[0111] According to the text length of the table information, it is determined whether it exceeds a preset text length threshold.

[0112] If the text format of the table information is short, this information will be used directly as the file name to create an empty file to be submitted in the pending folder.

[0113] If the text format of the table information is long, create a pending file in the pending folder with the UUID as the file name and record the information in it.

[0114] Begin a transaction that commits these related tables:

[0115] Submit transactions for each related table in turn until all are completed.

[0116] After the submission is complete, delete the file to be submitted created in step 3.

[0117] During the transaction submission process, loop to check whether there is a failure:

[0118] If no failure occurs, continue with the transaction commit process.

[0119] If a failure occurs, the entire database needs to be restarted and the failure recovery process begins.

[0120] The fault recovery process is as follows:

[0121] Scan all the files to be submitted in the pending folder and parse the information to be submitted one by one.

[0122] Based on the information to be submitted, continue to submit the transactions of the related tables in each piece of information until all are completed.

[0123] After submission is completed, delete the corresponding records in the pending folder.

[0124] If a failure occurs again during the recovery process, you will need to restart the entire database again and retry the current failure recovery process.

[0125] When processing cross-table transactions, you can compress the information of related tables to simplify processing in the following ways:

[0126] Get the ID (4 bytes) and transaction number (6 bytes) of each table.

[0127] Convert this information into a 15-byte string using Base64 encoding.

[0128] If the fault recovery is successful, a fault recovery record is generated. If it is unsuccessful, you need to restart the distributed database and repeat the steps of fault recovery based on the suspended record folder until the fault recovery is successful.

[0129] In addition, the embodiments of the present invention also provide the following examples.

[0130] Instead of storing all pending information in a pending folder, storing them separately in the data directory of the relevant table can provide better organization and manageability. This can be achieved by following the steps below:

[0131] Create data directories for related tables: Create a dedicated data directory for each related table to store all data files of the table.

[0132] Store the information to be submitted in the data directory of the relevant table: Store the information to be submitted in a subdirectory of the data directory of the table to which it is related. You can use a specific naming convention to identify these files to be submitted in order to distinguish between submitted and unsubmitted data.

[0133] Organize and manage the information to be submitted: In the data catalog of the relevant table, you can further organize and manage it as needed. For example, you can classify the information to be submitted by date, type, or other criteria. This makes it easier to find and process specific data to be submitted.

[0134] Move files when submitting data: Once the information to be submitted is ready and to be submitted to the database, the corresponding files can be moved from the directory to be submitted to the appropriate location in the database. This ensures data consistency and allows the data to be submitted and submitted to be managed correctly physically.

[0135] In short, distributing the information to be submitted in the data directory of related tables can improve the organization and manageability of data, and also facilitate future maintenance and query operations. This approach can be adjusted and expanded according to specific business needs.

[0136] Please refer to Figure 2 , Figure 2 A cross-table transaction support device 110 for a distributed database provided in an embodiment of the present invention includes:

[0137] An acquisition module 1101 is used to acquire pending transactions based on a distributed database;

[0138] The support module 1102 is used to determine whether the pending transaction is a cross-table transaction; if so, call a preset pending record folder to support the pending transaction; if not, directly submit the pending transaction.

[0139] It should be noted that the implementation principle of the cross-table transaction support device 110 of the above-mentioned distributed database can refer to the implementation principle of the cross-table transaction support method of the above-mentioned distributed database, and will not be repeated here. It should be understood that the division of the various modules of the above-mentioned device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the cross-table transaction support device 110 of the distributed database can be a separately established processing element, or it can be integrated in a chip of the above-mentioned device. In addition, it can also be stored in the memory of the above-mentioned device in the form of program code, and a processing element of the above-mentioned device can call and execute the functions of the cross-table transaction support device 110 of the above-mentioned distributed database. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in a processor element or an instruction in software form.

[0140] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital signal processors, DSP), or one or more field programmable gate arrays (FPGA), etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0141] The embodiment of the present invention provides a computer device 100, which includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device 100 executes the above-mentioned cross-table transaction support device 110 of the distributed database. Figure 3 As shown, Figure 3 The computer device 100 is a block diagram of a structure of a computer device 100 provided in an embodiment of the present invention. The computer device 100 includes a cross-table transaction support device 110 for a distributed database, a memory 111, a processor 112, and a communication unit 113.

[0142] To achieve data transmission or interaction, the memory 111, the processor 112 and the communication unit 113 are electrically connected to each other directly or indirectly. For example, the electrical connection between these elements can be achieved through one or more communication buses or signal lines. The cross-table transaction support device 110 of a distributed database includes at least one software function module that can be stored in the memory 111 in the form of software or firmware or solidified in the operating system (OS) of the computer device 100. The processor 112 is used to execute the cross-table transaction support device 110 of a distributed database stored in the memory 111, such as the software function modules and computer programs included in the cross-table transaction support device 110 of a distributed database.

[0143] An embodiment of the present invention provides a readable storage medium, which includes a computer program. When the computer program is running, the computer device where the readable storage medium is located is controlled to execute the aforementioned cross-table transaction support method for a distributed database.

[0144] For illustrative purposes, the foregoing description is made with reference to specific embodiments. However, the above illustrative discussion is not intended to be exhaustive or to limit the present disclosure to the precise form disclosed. Numerous modifications and variations are possible in accordance with the above teachings. These embodiments are selected and described in order to best illustrate the principles of the present disclosure and its practical application, so that those skilled in the art can best utilize the present disclosure and utilize various embodiments with different modifications to suit the intended specific application.

Claims

1. A cross-table transaction support method for a distributed database, characterized in that: include: Get pending transactions based on distributed databases; Determine whether the transaction to be processed is a cross-table transaction; If yes, calling a preset pending record folder to support the pending transaction; If not, directly submit the pending transaction; The calling of a preset pending record folder to support the pending transaction includes: Acquire multiple related tables of the pending transaction; Calling the pending record folder, and creating a file to be submitted in the pending record folder; Submitting the multiple related tables in sequence, and recording the table information of the multiple related tables in the file to be submitted; When the multiple related tables are submitted normally, the to-be-submitted files are deleted; The calling of the pending record folder and creating a file to be submitted in the pending record folder includes: Acquire the text length of the table information of the multiple related tables; Determining whether the text length exceeds a preset text length threshold; If yes, then using the UUIDs of the multiple related tables as file names, creating the to-be-submitted file for storing the table information; If not, the table information of the multiple related tables is used as the file name to create the empty file to be submitted; The method further comprises: Circularly detecting whether there is any failure in the submission process of the pending transaction; If yes, performing fault recovery based on the suspended record folder; If not, repeat the step of cyclically detecting whether there is a fault in the submission process of the pending transaction; The performing fault recovery based on the suspended record folder includes: Scan the to-be-submitted files in the pending record folder, obtain table information storing the to-be-submitted files, and obtain the to-be-submitted information corresponding to the table information; Submitting the multiple related tables in sequence according to the information to be submitted; When the multiple related tables are submitted normally, the to-be-submitted files are deleted; The method further comprises: Determining whether the fault recovery is successful; If so, a fault recovery record is generated; If not, restarting the distributed database, and repeatedly executing the step of performing fault recovery based on the suspended record folder until the fault recovery is successful; The related table is compressed by: Obtaining the identity number and transaction number of the related table; The identity number and the transaction number are encoded into a character string with a length of target bytes based on Base64, thereby completing the compression of the related table.

2. A cross-table transaction support device for a distributed database, characterized in that: include: An acquisition module, used to acquire pending transactions based on a distributed database; A support module, used to determine whether the transaction to be processed is a cross-table transaction; If yes, then call the preset pending record folder to support the pending transaction; if no, then directly submit the pending transaction; The support module is specifically used for: Acquire multiple related tables of the pending transactions; Calling the pending record folder, creating a to-be-submitted file in the pending record folder; submitting the multiple related tables in sequence, and recording the table information of the multiple related tables in the to-be-submitted file; when the multiple related tables are submitted normally, deleting the to-be-submitted file; The support module is also specifically used for: Obtain the text length of the table information of the multiple related tables; determine whether the text length exceeds a preset text length threshold; if so, use the UUIDs of the multiple related tables as file names to create the to-be-submitted file for storing the table information; if not, use the table information of the multiple related tables as file names to create the to-be-submitted file which is empty; The support module is also specifically used for: Circularly detect whether there is a fault in the submission process of the pending transaction; if so, perform fault recovery based on the suspended record folder; if not, repeat the step of cyclically detecting whether there is a fault in the submission process of the pending transaction; The support module is also specifically used for: Scan the to-be-submitted files in the pending record folder, obtain table information storing the to-be-submitted files, and obtain the to-be-submitted information corresponding to the table information; Submitting the multiple related tables in sequence according to the information to be submitted; When the multiple related tables are submitted normally, the to-be-submitted files are deleted; The support module is also specifically used for: Determine whether the fault recovery is successful; if so, generate a fault recovery record; if not, restart the distributed database and repeat the steps of performing fault recovery based on the suspended record folder until the fault recovery is successful; The support module is also specifically used for: Obtain the identity number and transaction number of the related table; encode the identity number and the transaction number into a character string with a length of target bytes based on Base64, and complete the compression of the related table.

3. A computer device, characterized in that: The computer device includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device executes the cross-table transaction support method for a distributed database according to claim 1.

4. A readable storage medium, characterized in that: The readable storage medium includes a computer program, and when the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the cross-table transaction support method of the distributed database according to claim 1.