Temporary table information processing method and device

By sending instructions for obtaining and establishing information tables in the Gaussian database, the problem that the client cannot access temporary tables after the master and backup switch is solved, and the stability and business reliability of the database are improved.

CN119988369APending Publication Date: 2025-05-13INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311491061.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-09
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

After the Gaussian database is switched to the main and standby, the client cannot find the temporary table in the standby database, resulting in a business error.

Method used

By receiving the client's connection establishment request, the addresses of the first database and the second database are determined. If the addresses are not the same, the obtaining information table instruction is sent to the first server, the information table is received and the establishment information table instruction is sent to the second server, so as to establish the second information table in the first database and establish the connection between the client and the first database.

Benefits of technology

It solves the problem that the client cannot access temporary tables after the Gaussian database master and backup switch, improves the stability of database operation and avoids business errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988369A_ABST
    Figure CN119988369A_ABST
Patent Text Reader

Abstract

The invention discloses a temporary table information processing method and device, relates to the technical field of databases, can also be used in the financial field, and comprises the following steps: receiving a connection establishment request sent by a client, the connection establishment request being a request for establishing a connection between the client and a database in a database cluster; determining a first database connected with the client and an address corresponding to the first database from a database cluster; determining a second database and an address corresponding to the second database from the database cluster; if the address corresponding to the first database is different from the address corresponding to the second database, sending an information table acquisition instruction to the first server; and receiving a first information table sent by the first server, and sending an information table establishment instruction to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the information table establishment instruction, and establishes a connection between the client and the first database based on the second information table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology and can also be used in the financial field, and in particular to a method and device for processing temporary table information. Background Art

[0002] Gaussian database is a database product developed by Huawei based on the PostgreSQL kernel. To ensure high availability of the database, its deployment architecture is generally in active-standby mode. Under normal circumstances, when the application connects to the database and configures the address of the active-standby cluster, the driver will automatically connect to the primary database. However, when the primary database is full of threads, connections, or memory overflows, it will cause active-standby switching. Figure 1 Schematic diagram of abnormal master-slave switching in the prior art, such as Figure 1 As shown in the figure, although Gaussian database has certain high availability capabilities, if the database connection fails to access the temporary table content, a business error will be triggered. Specifically, after the active-standby switch, the temporary table created on the faulty shard becomes invalid, and an error will be reported when the business connection involving the temporary table is continued to be used.

[0003] Therefore, it is urgent to solve the technical problem that after the primary and backup databases of the Gaussian database are switched, the client cannot find the temporary table in the backup database, which leads to abnormalities. Summary of the invention

[0004] An embodiment of the present invention provides a method for processing temporary table information, the method comprising:

[0005] Receive a connection establishment request sent by a client, where the connection establishment request is a request to establish a connection between the client and a database in the database cluster;

[0006] Determine a first database connected to the client and an address corresponding to the first database from the database cluster; and determine a second database and an address corresponding to the second database from the database cluster; wherein the second database is the database in the database cluster that was connected to the client last time;

[0007] If the address corresponding to the first database is different from the address corresponding to the second database, sending an instruction to obtain the information table to the first server; wherein the second database is deployed on the first server;

[0008] Receive a first information table sent by a first server, and send an instruction to establish an information table to a second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

[0009] Optionally, in one embodiment of the present invention, after determining the second database and the address corresponding to the second database from the database cluster, it also includes: if the address corresponding to the first database is the same as the address corresponding to the second database, sending a connection establishment indication message to the first server, so that the first server establishes a connection between the client and the first database based on the first information table.

[0010] Optionally, in one embodiment of the present invention, determining the first database to establish a connection with the client from the database cluster includes: obtaining a processing capability index corresponding to each database in the database cluster; and determining the first database from the database cluster based on the processing capability index corresponding to each database.

[0011] Optionally, in one embodiment of the present invention, determining the first database that establishes a connection with the client from the database cluster also includes: determining the second database that was last connected to the client, and determining a processing capability index corresponding to the second database; when the processing capability index corresponding to the second database is less than a processing capability threshold, determining the first database from the database cluster, wherein the processing capability index corresponding to the first database is greater than or equal to the processing capability threshold; when the processing capability index corresponding to the second database is greater than or equal to the processing capability threshold, determining the second database to be the first database.

[0012] Optionally, in one embodiment of the present invention, after receiving the first information table sent by the first server and before sending an instruction to establish an information table to the second server, it also includes: determining the table type of the first information table; sending a delete table instruction to the second server, so that the second server deletes the historical information table corresponding to the table type in the first database, wherein the delete table instruction carries the table type.

[0013] Optionally, in one embodiment of the present invention, before the first database establishes the second information table in the first database based on the information in the first information table, it also includes: querying the write status of the first database in the second server; when the write status is an unwritable state, sending a status setting instruction to the second server, wherein the status setting instruction is used to enable the second server to set the write status of the first database to a writable state.

[0014] An embodiment of the present invention provides a method for processing temporary table information, the method comprising:

[0015] Receive an instruction to establish an information table sent by the scheduling server, the instruction to establish an information table carrying a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by the client, determining that an address corresponding to the first database is different from an address corresponding to the second database, and obtaining the first information table; the second database is a database in the database cluster that last established a connection with the client;

[0016] Based on the first information table, establish a second information table;

[0017] Based on the second information table, a connection is established between the client and the first database.

[0018] Optionally, in one embodiment of the present invention, a second information table is established based on the first information table, including: determining the table type of the first information table; searching for a blank third information table corresponding to the table type from the first database based on the table type; obtaining information in the first information table, and refreshing the information to the third information table to obtain the second information table.

[0019] An embodiment of the present invention provides a device for processing temporary table information, the device comprising:

[0020] A first receiving module is used to receive a connection establishment request sent by a client, where the connection establishment request is a request to establish a connection between the client and a database in the database cluster;

[0021] A determination module, used to determine a first database connected to the client and an address corresponding to the first database from the database cluster, and to determine a second database and an address corresponding to the second database from the database cluster, wherein the second database is the database in the database cluster that last established a connection with the client;

[0022] A sending module, configured to send an instruction to obtain an information table to a first server if the address corresponding to the first database is different from the address corresponding to the second database, wherein the second database is deployed on the first server;

[0023] The second receiving module is used to receive the first information table sent by the first server, and send an instruction to establish an information table to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

[0024] Optionally, in one embodiment of the present invention, it also includes: a first sending unit, used to determine the second database from the database cluster, and after the address corresponding to the second database, if the address corresponding to the first database is the same as the address corresponding to the second database, send a connection establishment indication message to the first server, so that the first server establishes a connection between the client and the first database based on the first information table.

[0025] Optionally, in one embodiment of the present invention, the determination module includes: an acquisition unit, used to obtain a processing capability index corresponding to each database in the database cluster; and a first determination unit, used to determine a first database from the database cluster based on the processing capability index corresponding to each database.

[0026] Optionally, in one embodiment of the present invention, the determination module also includes: a second determination unit, used to determine the second database that was last connected to the client, and determine the processing capability index corresponding to the second database; a third determination unit, used to determine the first database from the database cluster when the processing capability index corresponding to the second database is less than the processing capability threshold, wherein the processing capability index corresponding to the first database is greater than or equal to the processing capability threshold; and a fourth determination unit, used to determine that the second database is the first database when the processing capability index corresponding to the second database is greater than or equal to the processing capability threshold.

[0027] Optionally, in one embodiment of the present invention, it also includes: a fifth determination unit, used to determine the table type of the first information table after receiving the first information table sent by the first server and before sending an instruction to establish the information table to the second server; a deletion unit, used to send a delete table instruction to the second server, so that the second server deletes the historical information table corresponding to the table type in the first database, wherein the delete table instruction carries the table type.

[0028] Optionally, in one embodiment of the present invention, it also includes: a query unit, used to query the write status of the first database in the second server before the first database establishes the second information table in the first database based on the information in the first information table; a second sending unit, used to send a status setting instruction to the second server when the write status is a non-writable state, wherein the status setting instruction is used to enable the second server to set the write status of the first database to a writable state.

[0029] An embodiment of the present invention further provides a device for processing temporary table information, the device comprising:

[0030] A receiving module, used for receiving an instruction to establish an information table sent by a scheduling server, wherein the instruction to establish an information table carries a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by a client, determining that an address corresponding to the first database is different from an address corresponding to a second database, and obtaining the first information table; the second database is a database in the database cluster that established a connection with the client last time;

[0031] A first establishing module, used to establish a second information table based on the first information table;

[0032] The second establishing module is used to establish a connection between the client and the first database based on the second information table.

[0033] Optionally, in one embodiment of the present invention, the first establishment module includes: a determination unit for determining the table type of the first information table; a search unit for searching for a blank third information table corresponding to the table type from the first database based on the table type; and an acquisition unit for acquiring information in the first information table and refreshing the information to the third information table to obtain the second information table.

[0034] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for processing temporary table information when executing the computer program.

[0035] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for processing the temporary table information is implemented.

[0036] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method for processing temporary table information is implemented.

[0037] In an embodiment of the present invention, a connection establishment request sent by a client is received, the connection establishment request is a request for establishing a connection between the client and a database in a database cluster; a first database to be connected to the client and an address corresponding to the first database are determined from the database cluster; a second database and an address corresponding to the second database are determined from the database cluster; wherein the second database is the database in the database cluster that was connected to the client last time; if the address corresponding to the first database is different from the address corresponding to the second database, an information table acquisition instruction is sent to the first server; wherein the second database is deployed on the first server; a first information table sent by the first server is received, and an information table establishment instruction is sent to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the information table establishment instruction, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server, which improves the stability of the operation of the Gaussian database, thereby solving the technical problem in the prior art that the client cannot find a temporary table in the standby database after the primary and standby databases of the Gaussian database are switched, resulting in an abnormality. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] Figure 1 A schematic diagram of an abnormal situation of master-slave switching in the prior art;

[0040] Figure 2 is a flowchart of a method for processing temporary table information in an embodiment of the present invention;

[0041] Figure 3 A flowchart of a preferred method for processing temporary table information in an embodiment of the present invention;

[0042] Figure 4 It is a flowchart of another method for processing temporary table information in an embodiment of the present invention;

[0043] Figure 5 is a timing flow chart of a method for processing temporary table information in an embodiment of the present invention;

[0044] Figure 6 A schematic diagram of a device for processing temporary table information in an embodiment of the present invention;

[0045] Figure 7 A schematic diagram of another device for processing temporary table information according to an embodiment of the present invention;

[0046] Figure 8 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0047] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0048] Figure 2 Flow chart of a method for processing temporary table information in an embodiment of the present invention. An embodiment of the present invention provides a method for processing temporary table information. The following is an example of a scheduling server as an execution subject for explanation. The method shown in the figure includes:

[0049] Step S201, receiving a connection establishment request sent by a client, where the connection establishment request is a request to establish a connection between the client and a database in a database cluster;

[0050] In the above steps, a connection establishment request with a database in the database cluster is received from a client. It should be noted that the client includes but is not limited to: an intelligent terminal and an external server.

[0051] Step S202, determining a first database connected to the client and an address corresponding to the first database from the database cluster; and determining a second database and an address corresponding to the second database from the database cluster; wherein the second database is the database in the database cluster that was connected to the client last time;

[0052] In the above steps, after obtaining the connection establishment request, the database with the highest processing capability index (i.e., the first database) is determined from multiple databases in the database cluster based on the processing capability index of each database in the database cluster, and the database is used to establish a connection with the client, and the address corresponding to the database is obtained at the same time, and the database that last established a connection with the client (i.e., the second database) is determined from multiple databases in the database cluster. The first database and the second database can be the same database or different databases. It should be noted that the address is a kind of identification information, including but not limited to an IP address, or other identification information that can represent the database, and the present invention does not make too many restrictions on this.

[0053] It should be noted that the database cluster is composed of multiple databases, each of which is deployed on a server. The server can perform data processing, data interaction, data transmission and other operations on the database.

[0054] Step S203, if the address corresponding to the first database is different from the address corresponding to the second database, sending an instruction to obtain the information table to the first server; wherein the second database is deployed on the first server;

[0055] In the above steps, when the address corresponding to the database (i.e., the first database) that establishes a connection with the client this time is different from the address corresponding to the database (i.e., the second database) that established a connection with the client last time, it is determined that the client's connection object has switched from the primary database to the backup database, i.e., the primary-backup database has switched, and the dispatch server sends an information table acquisition instruction to the server (i.e., the first server in the present invention) where the database that established the connection last time (i.e., the second database in the present invention, i.e., the primary database) is deployed to acquire the information in the information table of the second database, i.e., back up the information data. It should be noted that the information table includes but is not limited to a temporary table used in the database to store data.

[0056] Step S204, receiving the first information table sent by the first server, and sending an instruction to establish an information table to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

[0057] In the above steps, after sending an information table acquisition instruction to the first server where the second database is deployed, the first server sends the first information table to the scheduling server after receiving the information table acquisition instruction. After receiving the first information table, the scheduling server sends an information table establishment instruction to the second server where the first database is deployed. After the second server receives the information establishment instruction, the second server acquires the information in the first information table in the instruction through the instruction to establish a second information table on the first database.

[0058] It should be noted that the information in the information table may be information for interaction between the client and the database. The information table is used to store storage information that the client needs to access and information used to establish a connection with the client. The nature of the information table may be a temporary table.

[0059] In an embodiment of the present invention, a connection establishment request sent by a client is received, the connection establishment request is a request for establishing a connection between the client and a database in a database cluster; a first database to be connected to the client and an address corresponding to the first database are determined from the database cluster; a second database and an address corresponding to the second database are determined from the database cluster; wherein the second database is the database in the database cluster that was connected to the client last time; if the address corresponding to the first database is different from the address corresponding to the second database, an information table acquisition instruction is sent to the first server; wherein the second database is deployed on the first server; a first information table sent by the first server is received, and an information table establishment instruction is sent to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the information table establishment instruction, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server, which improves the stability of the operation of the Gaussian database, thereby solving the technical problem in the prior art that the client cannot find a temporary table in the standby database after the primary and standby databases of the Gaussian database are switched, resulting in an abnormality.

[0060] As an embodiment of the present invention, after determining the second database and the address corresponding to the second database from the database cluster, it also includes: if the address corresponding to the first database is the same as the address corresponding to the second database, sending a connection establishment indication message to the first server, so that the first server establishes a connection between the client and the first database based on the first information table.

[0061] In the above optional embodiment, after determining the database connected to the client and its corresponding address from the database cluster, when the address corresponding to the database is the same as the address corresponding to the database last connected to the client, it is determined that no master-slave database switching has occurred in the database cluster to which the client is connected.

[0062] It should be noted that, specifically, the comparison process of whether the addresses corresponding to the first database and the second database are the same is as follows: first, initialize two key-value pairs [DBO:ip], [DBN:ip]. Using the gsql tool, multiple IPs corresponding to multiple databases in the database cluster can be automatically connected to the master node of the current master database after the -h field. Therefore, to query the master node IP of the current master database, the sql command SELECTinet_server_addr() can be executed to return the IP value of the master node. Determine whether the IP value in [DBO:ip] is empty. If it is empty, it means that it is the first execution to establish a connection, and the node IP value is assigned to [DBO:ip] and [DBN:ip] respectively; if [DBO:ip] is not empty, it means that it is the second execution, and only the node IP value is assigned to [DBN:ip], and then compare the IP value of DBN and the IP value of DBO to see if they are consistent. If they are consistent, it means that the client has been establishing a connection on the same database, and no switch between the master and standby databases has occurred; if they are inconsistent, it means that the client has changed the database to establish a connection, and a switch between the master and standby databases has occurred.

[0063] As an embodiment of the present invention, determining the first database to establish a connection with the client from the database cluster includes: obtaining a processing capability index corresponding to each database in the database cluster; and determining the first database from the database cluster according to the processing capability index corresponding to each database.

[0064] In the above optional embodiment, after obtaining the connection establishment request of the client, the processing capability index corresponding to each database in the multiple databases in the database cluster is obtained. It should be noted that the processing capability index is a value indicating whether the database has the ability to establish a connection with the client. The processing capability index can be evaluated by the response time, throughput, concurrency, scalability and performance test in the database. Specifically, taking the response time as an example, the database processing capability index is closely related to the response time of the database. The processing capability of the database can be evaluated by performing various queries and operations on the database and recording its response time. A lower response time indicates a higher processing capability; taking throughput as an example, throughput refers to the number of transactions or queries that the database can process per unit time. The processing capability of the database is evaluated by performing a large number of concurrent operations or queries on the database and recording the number of transactions or queries processed. A higher throughput indicates a higher processing capability; taking concurrency as an example, concurrency refers to the ability of the database to maintain good performance when multiple users access it at the same time. The concurrency capability of the database can be evaluated by simulating multiple users concurrently accessing the database and observing the response time and throughput of the database. Better concurrency means higher processing power; taking scalability as an example, scalability refers to the ability of a database to maintain good performance when facing an increase in data volume or the number of users. The scalability of a database can be evaluated by simulating an increase in data volume or the number of users and observing the response time and throughput of the database. Better scalability means higher processing power; taking performance testing as an example, a comprehensive performance test of the database can be performed using performance testing tools, including load testing, stress testing, stability testing, etc., to evaluate the processing power of the database. Performance testing can simulate actual usage scenarios and more accurately evaluate the processing power of a database. The above are some common methods to determine the processing power index of a database. You can choose the appropriate method for evaluation according to the specific situation. Finally, the first database to establish a connection with the client is determined by the processing power indexes corresponding to multiple databases.

[0065] As an embodiment of the present invention, determining the first database that establishes a connection with a client from a database cluster also includes: determining the second database that was last connected to the client, and determining a processing capability index corresponding to the second database; when the processing capability index corresponding to the second database is less than a processing capability threshold, determining the first database from the database cluster, wherein the processing capability index corresponding to the first database is greater than or equal to the processing capability threshold; when the processing capability index corresponding to the second database is greater than or equal to the processing capability threshold, determining the second database to be the first database.

[0066] In the above optional embodiment, the database that the client last connected to (i.e., the second database) is first determined, and the processing capability index corresponding to the database is determined. If the processing capability index corresponding to the database does not reach the processing capability threshold, then a database whose processing capability index can reach the processing capability threshold is determined from multiple databases in the database cluster, that is, determined as the first database.

[0067] As an embodiment of the present invention, after receiving the first information table sent by the first server and before sending an instruction to establish an information table to the second server, it also includes: determining the table type of the first information table; sending a delete table instruction to the second server, so that the second server deletes the historical information table corresponding to the table type in the first database, wherein the delete table instruction carries the table type.

[0068] In the above optional embodiment, the table type of the first information table is determined before sending the instruction to create the information table to the database, and the historical information table of the same type as the first information table in the first database deployed on the second server is deleted to save database memory space and improve performance.

[0069] As an embodiment of the present invention, before the first database establishes the second information table in the first database based on the information in the first information table, it also includes: querying the write status of the first database in the second server; when the write status is a non-writable state, sending a status setting instruction to the second server, wherein the status setting instruction is used to enable the second server to set the write status of the first database to a writable state.

[0070] In the above optional embodiment, before establishing an information table in the first database, it is necessary to query the read and write status of the database to prevent the database's default read and write mode from being a read-only but not writable mode, thereby affecting the creation of the information table and the connection between the client and the database. When the database status is a non-writable state, the scheduling server sends a status setting instruction to the second server to set the write status in the first database to a writable state so as to write the information table in the database.

[0071] Figure 3 Flow chart of a preferred method for processing temporary table information in an embodiment of the present invention. Figure 3 As shown in the figure, the processing steps of temporary table information are as follows:

[0072] Step 301: The program starts, first enters the cluster connection 21, and logs in to the server for monitoring.

[0073] It should be noted that you can log in to the database through the Huawei Gaussian connection client gsql tool using the gsql-d postgres-p8000-h [cluster ip]-Uxx-Wxx method.

[0074] Step 302: Node record 22, determine the current master node IP, and record it in the form of a key-value pair.

[0075] It should be noted that two key-value pairs [DBO:ip] and [DBN:ip] are initialized first. Since the gsql tool can automatically connect to the current master node if multiple IPs of the cluster are provided after the -h field, the current master node IP is queried (that is, the address corresponding to the database) and the master node IP is returned by executing the SQL command SELECT inet_server_addr(). Determine whether [DBO:ip] is empty. If it is empty, it means that it is the first execution, then the node IP is assigned to [DBO:ip] and [DBN:ip]. If [DBO:ip] is not empty, it means that it is the second execution, then the node IP is assigned to [DBN:ip].

[0076] Step 303: Node comparison 23, check whether the values ​​of the key-value pairs are inconsistent, and make a judgment. If they are consistent, return to step 401, otherwise go to step 404.

[0077] In the above steps, compare the IP of DBN and the IP of DBO to see if they are consistent. If they are consistent, continue to loop this step. Otherwise, clean up the temporary table on the main database.

[0078] Step 304: Execute temporary table backup 31 to back up the temporary table on the original master node.

[0079] In the above steps, you can use gs_dump (Huawei backup tool) to export the table structure (table type) and table content (information of the information table).

[0080] Step 305: Temporary table cleanup 32, clean up the temporary table on the original master node.

[0081] In the above steps, connect to the database server through gsql. At this time, specify the connection IP as the IP in [DBO:ip], the user password as the system administrator user, and execute the SET TRANSACTION command to set this session to READWRITE. (Because sometimes the backup database connection can only read but not write by default, set this connection to read and write to operate the database), and then execute the drop command to delete the temporary table.

[0082] Step 306: Temporary table reconstruction 3, rebuild the backup temporary table on the new primary node and connect to the new primary node.

[0083] Step 307: Refresh temporary table information 4 and update the temporary table information into the system table.

[0084] It should be noted that the gsql tool is used to log in to the database server and execute the analyze temporary table command to update the statistical information to PG_STATISTIC (i.e., the system table). In this way, the transaction using this temporary table can correctly find the content of this table on the new master node. It should be noted that the system table is used to record the table used to find the temporary table information, which is used to quickly find the information in the temporary table.

[0085] Figure 4 Flow chart of another method for processing temporary table information in an embodiment of the present invention. An embodiment of the present invention provides a method for processing temporary table information. This embodiment is described with the second server as the execution subject. The method shown in the figure includes:

[0086] Step S401, receiving an instruction to establish an information table sent by a scheduling server, wherein the instruction to establish an information table carries a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by a client, determining that an address corresponding to the first database is different from an address corresponding to a second database, and obtaining the first information table; the second database is a database in the database cluster that established a connection with the client last time;

[0087] In the above steps, after the scheduling server determines that the address of the database establishing a connection with the client this time is different from the address of the database establishing a connection with the client last time, it will send an instruction to establish an information table to the first database (i.e., the backup database). The second server deployed with the first database receives the instruction to establish an information table sent by the scheduling server, and obtains the first information table carried in the instruction to establish the information table. It should be noted that the first information table is used to perform subsequent operations on the first database.

[0088] Step S402, establishing a second information table based on the first information table;

[0089] In the above steps, the first information table carried in the instruction for obtaining the information table received in step S401 is used to obtain the information in the first information table and the table type of the first information table through the first information table, and a blank information table of the corresponding type (i.e., the third information table) is found in the first database through the table type, and then the information in the first information table is updated to the blank information table found to establish a second information table in the first database. It should be noted that the information in the information table includes at least the data stored by the client in the database and the identification and verification information required to establish a connection with the client. Specifically, taking the TCP connection between the server and the client as an example, the information in the information table also includes the syn packet sent by the client when requesting to establish a connection, or other identification and verification information used to establish a connection. Similarly, other connection methods such as HTTP connection can also be used between the server and the client, and the present invention does not make too many restrictions here.

[0090] Step S403: establishing a connection between the client and the first database based on the second information table.

[0091] In the above optional embodiment, a connection between the standby database (ie, the first database) and the client is established through the information in the second information table to complete the active / standby switch.

[0092] In the embodiment of the present invention, by receiving the instruction to establish an information table sent by the scheduling server, the instruction to establish an information table carries the first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving the connection establishment request sent by the client, determining that the address corresponding to the first database is different from the address corresponding to the second database and obtaining the first information table; the second database is the database in the database cluster that established a connection with the client last time; based on the first information table, the second information table is established; based on the second information table, the connection between the client and the first database is established. , the stability of the operation of the Gaussian database is improved, thereby solving the technical problem in the prior art that the client cannot find the temporary table in the standby database after the primary and standby databases of the Gaussian database are switched, resulting in an abnormality.

[0093] Optionally, in one embodiment of the present invention, a second information table is established based on the first information table, including: determining the table type of the first information table; searching for a blank third information table corresponding to the table type from the first database based on the table type; obtaining information in the first information table, and refreshing the information to the third information table to obtain the second information table.

[0094] As an optional embodiment, the table type of the first information table is first determined, and then a blank information table corresponding to the table type is selected from the first database, and the information in the first information table is refreshed to the blank information table to complete the creation of the second information table in the first database. Using a blank information table can increase the information carrying capacity to enhance data processing capabilities.

[0095] It should be noted that the table types in the database include but are not limited to: document data table (a data table containing multiple columns, each column represents a subject or information), relational data table (containing two data columns, each data column is a table or table structure. Relational data table includes table header and column header) and data dictionary table (a data table containing a key-value pair, each key-value pair indicates a specific attribute or value of the data type. This type of table is usually used for queries or views).

[0096] Figure 5 FIG. 1 is a timing flow chart of a method for processing temporary table information in an embodiment of the present invention. Figure 5 As shown, the specific process includes:

[0097] S501, first the client sends a connection establishment request to the scheduling server;

[0098] S502, the scheduling server determines the first database based on the processing capability index corresponding to each database in the database cluster; and determines the second database that established a connection with the client last time;

[0099] S503, the scheduling server determines a first database deployed on the second server; and determines a second database deployed on the first server;

[0100] S504, the second server sends the address of the first database to the scheduling server; and the first server sends the address of the second database to the scheduling server;

[0101] S505: The scheduling server compares the address of the first database with the address of the second database to see if they are the same;

[0102] S506: When the address of the first database and the address of the second database are different, the scheduling server sends an instruction to obtain the information table to the first server;

[0103] S507, the first server sends a first information table to the scheduling server;

[0104] S508, after receiving the first information tag, the dispatch server sends an instruction to create an information table to the second server;

[0105] S509: The second server creates a second information table based on the information in the first information table in the creation information table instruction;

[0106] S510: The second server establishes a connection with the client based on the second information table.

[0107] Therefore, based on Figure 5 The method for processing temporary table information shown in the figure compares the address of the database that established a connection with the client this time with the address of the database that established a connection with the client last time to determine whether a primary-backup switch has occurred. When it is determined that a primary-backup switch has occurred, an information table is established in the database that is established this time through the information table in the server that established the connection last time, and a connection with the client is established through the information table. In this way, the client can access the information table on the backup after the primary-backup switch of the database occurs, so as to avoid errors caused by the client being unable to access the information content in the information table on the database after establishing a connection after the primary-backup database switch occurs, thereby improving the stability of the database cluster operation and ensuring the efficiency of database work.

[0108] Figure 6 Schematic diagram of a device for processing temporary table information in an embodiment of the present invention. Figure 6 As shown, an embodiment of the present invention provides a device for processing temporary table information, the device comprising:

[0109] A first receiving module 61 is used to receive a connection establishment request sent by a client, where the connection establishment request is a request to establish a connection between the client and a database in the database cluster;

[0110] A determination module 62 is used to determine a first database connected to the client and an address corresponding to the first database from the database cluster, and to determine a second database and an address corresponding to the second database from the database cluster, wherein the second database is the database in the database cluster that was connected to the client last time;

[0111] A sending module 63, configured to send an instruction to obtain an information table to a first server if the address corresponding to the first database is different from the address corresponding to the second database, wherein the second database is deployed on the first server;

[0112] The second receiving module 64 is used to receive the first information table sent by the first server, and send an instruction to establish an information table to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

[0113] Optionally, in one embodiment of the present invention, it also includes: a first sending unit, used to determine the second database from the database cluster, and after the address corresponding to the second database, if the address corresponding to the first database is the same as the address corresponding to the second database, send a connection establishment indication message to the first server, so that the first server establishes a connection between the client and the first database based on the first information table.

[0114] Optionally, in one embodiment of the present invention, the determination module includes: an acquisition unit, used to obtain a processing capability index corresponding to each database in the database cluster; and a first determination unit, used to determine a first database from the database cluster based on the processing capability index corresponding to each database.

[0115] Optionally, in one embodiment of the present invention, the determination module also includes: a second determination unit, used to determine the second database that was last connected to the client, and determine the processing capability index corresponding to the second database; a third determination unit, used to determine the first database from the database cluster when the processing capability index corresponding to the second database is less than the processing capability threshold, wherein the processing capability index corresponding to the first database is greater than or equal to the processing capability threshold; and a fourth determination unit, used to determine that the second database is the first database when the processing capability index corresponding to the second database is greater than or equal to the processing capability threshold.

[0116] Optionally, in one embodiment of the present invention, it also includes: a fifth determination unit, used to determine the table type of the first information table after receiving the first information table sent by the first server and before sending an instruction to establish the information table to the second server; a deletion unit, used to send a delete table instruction to the second server, so that the second server deletes the historical information table corresponding to the table type in the first database, wherein the delete table instruction carries the table type.

[0117] Optionally, in one embodiment of the present invention, it also includes: a query unit, used to query the write status of the first database in the second server before the first database establishes the second information table in the first database based on the information in the first information table; a second sending unit, used to send a status setting instruction to the second server when the write status is a non-writable state, wherein the status setting instruction is used to enable the second server to set the write status of the first database to a writable state.

[0118] Figure 7 FIG. 1 is a schematic diagram of another device for processing temporary table information in an embodiment of the present invention. Figure 7 As shown, an embodiment of the present invention further provides a device for processing temporary table information, the device comprising:

[0119] The receiving module 71 is used to receive an instruction to establish an information table sent by the scheduling server, where the instruction to establish an information table carries a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by the client, determining that the address corresponding to the first database is different from the address corresponding to the second database, and obtaining the first information table; the second database is the database in the database cluster that established a connection with the client last time;

[0120] A first establishing module 72, used to establish a second information table based on the first information table;

[0121] The second establishing module 73 is used to establish a connection between the client and the first database based on the second information table.

[0122] Optionally, in one embodiment of the present invention, the first establishment module includes: a determination unit for determining the table type of the first information table; a search unit for searching for a blank third information table corresponding to the table type from the first database based on the table type; and an acquisition unit for acquiring information in the first information table and refreshing the information to the third information table to obtain the second information table.

[0123] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for processing temporary table information when executing the computer program.

[0124] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for processing the temporary table information is implemented.

[0125] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method for processing temporary table information is implemented.

[0126] Figure 8 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as Figure 8 As shown, the electronic device includes: a processor (processor) 801, a memory (memory) 802 and a bus 803.

[0127] The processor 801 and the memory 802 communicate with each other via a bus 803 .

[0128] The processor 801 is used to call the program instructions in the memory 802 to execute the methods provided by the above-mentioned method embodiments.

[0129] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0131] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0133] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for processing temporary table information, characterized in that: include: Receiving a connection establishment request sent by a client, wherein the connection establishment request is a request for establishing a connection between the client and a database in a database cluster; Determine, from the database cluster, a first database that establishes a connection with the client, and an address corresponding to the first database; and determining a second database from the database cluster and an address corresponding to the second database; wherein the second database is a database in the database cluster that last established a connection with the client; If the address corresponding to the first database is different from the address corresponding to the second database, sending an instruction to obtain the information table to the first server; wherein the second database is deployed on the first server; Receive the first information table sent by the first server, and send an instruction to establish an information table to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

2. The method according to claim 1, characterized in that After determining the second database from the database cluster and the address corresponding to the second database, the method further includes: If the address corresponding to the first database is the same as the address corresponding to the second database, connection establishment indication information is sent to the first server, so that the first server establishes a connection between the client and the first database based on the first information table.

3. The method according to claim 1, characterized in that The determining, from the database cluster, of a first database to establish a connection with the client comprises: Obtaining a processing capability index corresponding to each database in the database cluster; The first database is determined from the database cluster according to the processing capability index corresponding to each database.

4. The method according to claim 1, characterized in that The determining, from the database cluster, of a first database to establish a connection with the client comprises: Determine the second database that the client last connected to, and determine a processing capability index corresponding to the second database; In a case where the processing capability index corresponding to the second database is less than a processing capability threshold, determining the first database from the database cluster, wherein the processing capability index corresponding to the first database is greater than or equal to the processing capability threshold; When the processing capability index corresponding to the second database is greater than or equal to a processing capability threshold, the second database is determined to be the first database.

5. The method according to claim 1, characterized in that After receiving the first information table sent by the first server and before sending the instruction to create the information table to the second server, the method further includes: Determining a table type of the first information table; Sending a delete table instruction to the second server so that the second server deletes the historical information table corresponding to the table type in the first database, wherein the delete table instruction carries the table type.

6. The method according to claim 1, characterized in that Before the first database establishes a second information table in the first database based on the information in the first information table, the method further includes: querying the write status of the first database in the second server; When the write status is a non-writable status, a status setting instruction is sent to the second server, wherein the status setting instruction is used to enable the second server to set the write status of the first database to a writable status.

7. A method for processing temporary table information, characterized in that: include: Receive an instruction to establish an information table sent by a scheduling server, wherein the instruction to establish an information table carries a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by a client, determining that an address corresponding to the first database is different from an address corresponding to a second database, and obtaining the first information table; the second database is a database in the database cluster that last established a connection with the client; Based on the first information table, establish a second information table; Based on the second information table, a connection is established between the client and the first database.

8. The method according to claim 1, characterized in that Based on the first information table, a second information table is established, including: Determining a table type of the first information table; Based on the table type, searching the first database for a blank third information table corresponding to the table type; The information in the first information table is obtained, and the information is refreshed into the third information table to obtain the second information table.

9. A device for processing temporary table information, characterized in that: include: A first receiving module is used to receive a connection establishment request sent by a client, wherein the connection establishment request is a request for establishing a connection between the client and a database in the database cluster; a determination module, configured to determine a first database connected to the client and an address corresponding to the first database from the database cluster, and to determine a second database and an address corresponding to the second database from the database cluster, wherein the second database is the database in the database cluster that last established a connection with the client; a sending module, configured to send an instruction to obtain an information table to a first server if the address corresponding to the first database is different from the address corresponding to the second database, wherein the second database is deployed on the first server; A second receiving module is used to receive the first information table sent by the first server, and send an instruction to establish an information table to the second server, so that the second server establishes a second information table in the first database based on the first information table carried by the instruction to establish the information table, and establishes a connection between the client and the first database based on the second information table; wherein the first database is deployed on the second server.

10. A device for processing temporary table information, characterized in that: include: A receiving module, configured to receive an instruction to establish an information table sent by a scheduling server, wherein the instruction to establish an information table carries a first information table; wherein the instruction to establish an information table is sent by the scheduling server after receiving a connection establishment request sent by a client, determining that an address corresponding to the first database is different from an address corresponding to a second database, and obtaining the first information table; the second database is a database in the database cluster that last established a connection with the client; A first establishing module, used for establishing a second information table based on the first information table; The second establishing module is used to establish a connection between the client and the first database based on the second information table.

11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.