CN116302823A - Database processing method, device, server and storage medium - Google Patents

Database processing method, device, server and storage medium Download PDF

Info

Publication number
CN116302823A
CN116302823A CN202310271968.7A CN202310271968A CN116302823A CN 116302823 A CN116302823 A CN 116302823A CN 202310271968 A CN202310271968 A CN 202310271968A CN 116302823 A CN116302823 A CN 116302823A
Authority
CN
China
Prior art keywords
database
sub
thread
databases
adopting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310271968.7A
Other languages
Chinese (zh)
Inventor
徐威
刘鸿羽
郭品威
瞿海杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310271968.7A priority Critical patent/CN116302823A/en
Publication of CN116302823A publication Critical patent/CN116302823A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3055Monitoring arrangements for monitoring the status of the computing system or of the computing system component, e.g. monitoring if the computing system is on, off, available, not available
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information
    • G06F11/328Computer systems status display
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application provides a database processing method, a database processing device, a server and a storage medium, and relates to the technical field of Internet of things, wherein the method comprises the following steps: adopting a main thread to poll each sub-thread to obtain detection results of databases corresponding to a plurality of sub-threads, wherein the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are used for concurrently detecting the running states of the databases corresponding to each sub-thread to generate detection results of the databases corresponding to each sub-thread; and updating the available state of the corresponding database based on the detection result of the corresponding database by adopting the main thread so as to execute corresponding transaction operation according to the available state of the database when receiving the transaction request. According to the method, the running states of the databases can be comprehensively detected by adopting the plurality of sub-threads, the blocking state cannot occur, the available states of the databases can be accurately positioned, corresponding transaction operations are executed according to the available states of the databases, and the transaction processing efficiency can be effectively improved.

Description

Database processing method, device, server and storage medium
Technical Field
The present disclosure relates to the field of internet of things, and in particular, to a database processing method, a database processing device, a server, and a storage medium.
Background
With the development of modern computer science and technology, databases have become the foundation and core of computer information systems, and databases are widely used in industries such as telecommunications and finance, so that the high availability of database applications is also attracting more and more attention.
In the prior art, there are a large variety of highly available patterns of relational databases, which include: a master database server and a slave database server, and the schema of the relational database comprises: a master multi-slave mode. The working principle of the master-slave mode mainly comprises the following steps: the master database server adopts a single-thread mode to sequentially detect the running states of a plurality of slave database servers. When one of the slave database servers is detected, if the database server is in an abnormal state such as slow query or sub-health, the master database server cannot continuously detect the database server behind the slave database, so that a blocking state situation occurs in the detection process, the detection is caused to be faulty, and the master database server cannot timely detect the running states of other slave database servers in a master multi-slave mode. Moreover, when the database server is in an abnormal state such as slow inquiry or sub-health, the database server cannot process the transaction, and transaction processing efficiency is directly affected.
Disclosure of Invention
The application provides a database processing method, a device, a server and a storage medium, which are used for solving the problems that detection is easy to cause faults when a database server adopts a single-thread mode to detect a database, the running state of the database server cannot be obtained in time, and the transaction processing efficiency is influenced.
In a first aspect, the present application provides a database processing method, including:
adopting a main thread to poll each sub-thread to obtain detection results of databases corresponding to a plurality of sub-threads, wherein the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are used for concurrently detecting the running states of the databases corresponding to each sub-thread to generate detection results of the databases corresponding to each sub-thread;
and updating the available state of the corresponding database based on the detection result of the corresponding database by adopting the main thread so as to execute corresponding transaction operation according to the available state of the database when receiving the transaction request.
Optionally, the updating, by the main thread, the availability status of the corresponding database based on the detection result of the corresponding database includes:
updating the available states of the corresponding databases in the database list in the memory by adopting the main thread based on the detection result of the corresponding databases, wherein the available states comprise: the database is available and the database is not available.
Optionally, the updating, by the main thread, the availability status of the corresponding database in the database list in the memory based on the detection result of the corresponding database includes:
if the detection result of the database corresponding to the sub-thread is that the database is in an abnormal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the unavailable state of the database by adopting the main thread;
or alternatively, the process may be performed,
if the detection result of the database corresponding to the sub-thread is that the database is in a normal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the available state of the database by adopting the main thread.
Optionally, the method further comprises:
receiving a transaction request of a user terminal, and determining a target database according to the transaction request;
acquiring the available state of the target database in the database list;
if the available state of the target database is that the database is unavailable, determining a standby database corresponding to the target database, and forwarding the transaction request to the standby database so that the standby database can execute corresponding transaction operation according to the transaction request.
Optionally, the determining a target database according to the transaction request includes:
analyzing the transaction request to obtain a client number corresponding to the transaction request;
and in the mapping relation between the preset client number and the database, determining the database corresponding to the preset client number matched with the corresponding client number as the target database.
Optionally, the method further comprises:
and if the available state of the target database is that the database is available, forwarding the transaction request to the target database so that the target database can execute corresponding transaction operation according to the transaction request.
Optionally, the determining the standby database corresponding to the target database includes:
and in the mapping relation between the preset first database and the second database, determining the second database corresponding to the preset first database matched with the target database as the standby database.
Optionally, the method further comprises:
polling a plurality of sub-threads by adopting a main thread at intervals of preset time;
if the current detection task of the sub thread is determined to be completed, acquiring a database detection result corresponding to the sub thread by adopting a main thread, and updating the available state of a corresponding database by adopting the main thread based on the database detection result corresponding to the sub thread;
or alternatively, the process may be performed,
if the fact that the current detection task of the sub-thread is not completed is determined, updating the available state of the database corresponding to the thread into the database timeout by adopting the main thread, and recording the timeout times; and if the timeout times are equal to the preset times, updating the available state of the database corresponding to the sub-thread into the unavailable state of the database by adopting the main thread.
In a second aspect, the present application provides a database processing apparatus, including:
the processing unit is used for adopting a main thread to poll each sub thread to obtain detection results of databases corresponding to a plurality of sub threads, the plurality of sub threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub threads are used for concurrently detecting the running states of the corresponding databases to generate the detection results of the corresponding databases;
and the updating unit is also used for updating the available state of the corresponding database by adopting the main thread based on the detection result of the corresponding database so as to execute corresponding transaction operation according to the available state of the database when the transaction request is received.
In a third aspect, the present application provides a server comprising: a processor, a memory, and a transceiver;
a processor, memory, and transceiver circuitry interconnect;
the memory stores computer-executable instructions;
a transceiver for transceiving data;
the processor executes computer-executable instructions stored in the memory to cause the processor to perform the method as described in the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium having stored therein computer-executable instructions for performing the method according to the first aspect when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the method of the first aspect.
According to the database processing method, device, server and storage medium, the main thread is adopted to poll detection results of the databases corresponding to the sub threads, the sub threads are in one-to-one correspondence with the databases, the sub threads are used for detecting running states of the corresponding databases to generate detection results of the corresponding databases, the main thread is adopted to update available states of the corresponding databases based on the detection results of the corresponding databases, and when a transaction request is received, corresponding transaction operation is executed according to the available states of the databases. The adoption of a plurality of sub-threads can comprehensively detect the running state of each database, the blocking state can not occur, the available state of each database can be accurately positioned, corresponding transaction operation is executed according to the available state of the database, and the transaction processing efficiency can be effectively improved. In addition, under the condition that the target database is unavailable, the unavailable database is automatically isolated, the standby database is adopted to replace the target database, and the standby database is used for executing corresponding transaction operation, so that the normal proceeding of subsequent transactions can be ensured.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic diagram of a network architecture of a database processing method provided in the present application;
FIG. 2 is a schematic flow chart of a database processing method provided in the present application;
FIG. 3 is a flowchart of another database processing method provided in the present application;
fig. 4 is a schematic structural diagram of a database processing device provided in the present application;
FIG. 5 is a block diagram of a server used to implement the database processing method of the present application.
Specific embodiments thereof have been shown by way of example in the drawings and will herein be described in more detail. These drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
For a clear understanding of the technical solutions of the present application, the prior art solutions will be described in detail first.
The working principle under the master multi-slave mode mainly comprises: the master database server adopts a single-thread mode to sequentially detect the running states of a plurality of slave database servers. When one of the slave database servers is detected, if the database server is in an abnormal state such as slow query or sub-health, wherein the sub-health is that the database has more or less health problems, some performance problems often occur, the slow query is that the throughput is small, the network speed is slow, the data volume of the query is too large, and at the moment, the master database server can not continuously detect the database server behind the slave database, so that a blocking state situation occurs in the detection process, the detection is failed, and the master database server can not timely detect the running states of other slave database servers in a master-multi-slave mode. Moreover, when the database server is in an abnormal state such as slow inquiry or sub-health, the database server cannot process the transaction, and transaction processing efficiency is directly affected.
Therefore, aiming at the problems that in the prior art, the database server adopts a single thread mode to detect the database, so that the detection is easy to cause faults, the running state of the database server cannot be obtained in time, and the transaction processing efficiency is influenced, the inventor finds out in the research that the main thread is adopted to poll the detection results of the databases corresponding to all the sub-threads, the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, the plurality of sub-threads are used for detecting the running states of the corresponding databases in parallel to generate the detection results of the corresponding databases, the main thread is adopted to update the available states of the corresponding databases based on the detection results of the corresponding databases, the corresponding transaction operation is executed according to the available states of the databases when the transaction request is received, the plurality of sub-threads can comprehensively detect the running states of the databases without occurrence of blocking states, the corresponding transaction operation is executed according to the available states of the databases, and the transaction processing efficiency can be effectively improved.
The inventor proposes the technical solution of the embodiments of the present application based on the inventive findings described above. The following describes a network architecture and an application scenario of the database processing method provided in the embodiments of the present application.
As shown in fig. 1, the network architecture corresponding to the database processing method provided in the embodiment of the present application includes: the method comprises the steps that a master database server 1 and 3 slave database servers 2, a master database service network starts a master thread and 3 sub-threads, the 3 sub-threads are in one-to-one correspondence with the 3 slave databases, and the 3 sub-threads concurrently detect the running states of the corresponding slave databases so as to generate detection results of the corresponding slave databases. The main database server 1 adopts the main thread to poll each sub-thread to obtain the detection results of the corresponding sub-database of the plurality of sub-threads, and the main database server 1 adopts the main thread to update the available state of the corresponding sub-database based on the detection results of the corresponding sub-database, so as to realize that when a transaction request is received, corresponding transaction operation is executed according to the available state of the sub-database. The running state of each database can be comprehensively detected by adopting the plurality of sub-threads, so that the available state of each database can be accurately positioned, corresponding transaction operation is executed according to the available state of the database, and the transaction processing efficiency can be effectively improved.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Fig. 2 is a flow chart of a database processing method provided in the present application, where the method is applied to a server.
In step 201, a main thread is adopted to poll each sub-thread to obtain detection results of databases corresponding to a plurality of sub-threads, the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are used for concurrently detecting running states of the databases corresponding to the sub-threads so as to generate detection results of the databases corresponding to the sub-threads.
In this embodiment, a main thread and a plurality of sub threads are started, the plurality of sub threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub threads are used for concurrently detecting the running states of the databases corresponding to the sub threads, so as to generate the detection results of the databases corresponding to the sub threads. And adopting the main thread to poll the plurality of sub-threads, thereby obtaining detection results of databases corresponding to the plurality of sub-threads.
Step 202, updating the available state of the corresponding database by adopting the main thread based on the detection result of the corresponding database, so as to execute corresponding transaction operation according to the available state of the database when receiving the transaction request.
In this embodiment, the main thread is adopted to update the available state of the corresponding database based on the detection result of the database corresponding to each sub-thread, where the available state of the database includes that the database is available and the database is unavailable, so that when a transaction request is received, corresponding transaction operations are executed according to the available state of the database. Specifically, if the available state of a certain database is available, determining that the database can execute corresponding transaction operation; if the availability status of a certain database is unavailable, determining that the database cannot execute corresponding transaction operation.
In this embodiment, a main thread is adopted to poll detection results of databases corresponding to each sub-thread, a plurality of sub-threads are in one-to-one correspondence with a plurality of databases, the plurality of sub-threads are used for concurrently detecting operation states of the corresponding databases to generate detection results of the corresponding databases, the main thread is adopted to update available states of the corresponding databases based on the detection results of the corresponding databases, when a transaction request is received, corresponding transaction operations are executed according to the available states of the databases, the plurality of sub-threads are adopted to comprehensively detect the operation states of the databases, blocking states are not generated, the available states of the databases can be accurately positioned, corresponding transaction operations are executed according to the available states of the databases, and transaction processing efficiency can be effectively improved.
Fig. 3 is a flow chart of another database processing method provided in the present application, where the method is applied to a server, as shown in fig. 3, and the method includes:
step 301, polling each sub-thread by using a main thread to obtain detection results of databases corresponding to the plurality of sub-threads, wherein the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are used for concurrently detecting running states of the databases corresponding to the sub-threads so as to generate detection results of the databases corresponding to the sub-threads.
In this embodiment, the step 301 and the step 201 have the same technical features, and the detailed description will refer to the step 201, and will not be repeated here.
Step 302, updating, by using the main thread, an available state of a corresponding database in the database list in the memory based on a detection result of the corresponding database, so as to implement, when a transaction request is received, performing a corresponding transaction operation according to the available state of the database, where the available state includes: the database is available and the database is not available.
In this embodiment, a database list is set in a memory, an available state of each database is recorded in the database list, a main thread is adopted to update an available state of corresponding data in the database list in the memory based on detection results of databases corresponding to a plurality of sub-threads, wherein the available state includes that the database is available and the database is unavailable, specifically, if the available state of a certain database is available, it is determined that the database can execute a corresponding transaction operation, and the database executes a corresponding transaction operation; if the available state of a certain database is unavailable, determining that the database cannot execute corresponding transaction operation, and executing corresponding transaction operation by the standby database corresponding to the database.
In one possible implementation, updating, with the main thread, an availability status of a corresponding database in the database list in the memory based on a detection result of the corresponding database includes:
if the detection result of the database corresponding to the sub-thread is that the database is in an abnormal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the unavailable state of the database by adopting the main thread; or if the detection result of the database corresponding to the sub-thread is that the database is in a normal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the available state of the database by adopting the main thread.
In this embodiment, if the detection result of the database corresponding to the sub-thread is that the database is in an abnormal state, where the abnormal state includes a slow query and a sub-health state, which indicates that the database cannot execute the corresponding transaction operation, the main thread is adopted to update the available state of the database corresponding to the sub-thread in the database list in the memory to be unavailable, and in the case that the database is unavailable, the other databases, that is, the standby database, replace the database to execute the corresponding transaction operation.
Or if the detection result of the database corresponding to the sub-thread is that the database is in a normal state, indicating that the database can execute corresponding transaction operation, and updating the available state of the database corresponding to the sub-thread in the database list in the memory into the available state of the database by adopting the main thread.
Optionally, determining a standby database corresponding to the target database includes:
and determining a second database corresponding to the preset first database matched with the target database as a standby database in the mapping relation between the preset first database and the second database.
In this embodiment, a mapping relationship between a preset first database and a second database is obtained, and in the mapping relationship between the preset first database and the second database, a second database corresponding to the preset first database that is to be matched with the target database is determined as a standby database corresponding to the target database, so that the normal operation of the transaction is not affected, and the standby database replaces the target database to execute a corresponding transaction operation.
In one possible implementation, the method further includes:
receiving a transaction request of a user terminal, and determining a target database according to the transaction request; acquiring the available state of a target database in a database list; if the available state of the target database is that the database is unavailable, determining a standby database corresponding to the target database, and forwarding the transaction request to the standby database so that the standby database can execute corresponding transaction operation according to the transaction request.
In this embodiment, a user triggers a transaction request through a user terminal, receives the transaction request triggered by the user terminal, further determines a target database corresponding to the transaction request, the database is determined according to a client number in the transaction request, a corresponding database is allocated to the client number in advance, the database performs related transaction operations for the user corresponding to the client number, each database is preconfigured with a standby database, the standby databases can also perform related transaction operations, high availability of the databases can be maintained, the target database and the standby databases can be switched with each other, and in case of a failure in one database, the database is switched to the standby database to maintain a mechanism of uninterrupted transaction, thereby effectively improving transaction efficiency.
Optionally, the method further comprises:
if the available state of the target database is that the database is available, forwarding the transaction request to the target database so that the target database can execute corresponding transaction operation according to the transaction request.
In this embodiment, if the availability status of the target database is that the database is available, it is indicated that the target database is capable of processing the transaction, and the standby database is not required to process the transaction request of the user terminal is forwarded to the target database, and the target database performs a corresponding transaction operation according to the transaction request.
Optionally, determining the target database according to the transaction request includes:
analyzing the transaction request to obtain a client number corresponding to the transaction request; and determining the database corresponding to the preset client number matched with the corresponding client number as a target database in the mapping relation between the preset client number and the database.
In this embodiment, the target database is determined based on the client number, the transaction request is parsed, the client number corresponding to the transaction request and the mapping relationship between the preset client number and the database are obtained, and in the mapping relationship between the preset client number and the database, the database corresponding to the preset client number matched with the corresponding client number is determined as the target database. The mapping relation between the preset client number and the database is configured according to the advance, specifically, a configuration request is received, and the configuration request comprises: the client number to be configured, according to the configuration request, calculating a hash value corresponding to the client number to be configured; in the mapping relation between the preset hash value and the database, determining the database corresponding to the preset hash value matched with the hash value corresponding to the client number to be configured as a target database of the client number to be configured, wherein the client number to be configured is used as the preset client number, so that the mapping relation between the preset client number and the target database is obtained.
In one possible implementation, the method further includes:
polling a plurality of sub-threads by adopting a main thread at intervals of preset time; if the current detection task of the sub thread is determined to be completed, acquiring a database detection result corresponding to the sub thread by adopting a main thread, and updating the available state of a corresponding database by adopting the main thread based on the database detection result corresponding to the sub thread; or if the current detection task of the sub-thread is not completed, updating the available state of the database corresponding to the thread into the database timeout by adopting the main thread and recording the timeout times; and if the timeout times are equal to the preset times, updating the available state of the database corresponding to the sub-thread into the unavailable state of the database by adopting the main thread.
In this embodiment, the preset time may be set according to actual needs, for example, 1s is set, the interval 1s uses a main thread to poll a plurality of sub-threads, determine whether the current probing task of the sub-thread is completed, if it is determined that the current probing task of the sub-thread is completed, acquire a database probing result corresponding to the sub-thread by using the main thread, and update an available state of a corresponding database by using the main thread based on the corresponding database probing result of the sub-thread, specifically, update an available state of a corresponding database in a database list in a memory by using the main thread based on the corresponding database probing result of the sub-thread, where the available state includes: the database is available and the database is not available.
Or if the current detection task of the sub-thread is not completed, updating the available state of the database corresponding to the sub-thread into the database timeout by adopting the main thread and recording the timeout times, and specifically updating the available state of the database corresponding to the sub-thread in the database list in the memory into the database timeout by adopting the main thread and recording the timeout times. The preset times can be set according to actual needs, for example, the preset times are set to 2 times, if the timeout times are equal to the preset times, namely, the timeout times are equal to 2 times, the fact that detection results are not obtained for 2 times is indicated, in order to ensure normal proceeding of subsequent transactions, a main thread is adopted to update the available state of a database corresponding to the sub-thread into the unavailable state of the database, corresponding transaction operation is further executed by a standby database corresponding to the database, and the unavailable database is automatically isolated, so that normal proceeding of the subsequent transactions is ensured. The sub-thread is ready, and the main thread acquires the detection result, so that the efficiency can be improved.
According to the method and the device, the running states of the databases can be comprehensively detected by the plurality of sub-threads, so that the available states of the databases can be accurately positioned, corresponding transaction operations are executed according to the available states of the databases, and the transaction processing efficiency can be effectively improved. And under the condition that the target database is unavailable, the unavailable database is automatically isolated, the standby database is adopted to replace the target database, and the standby database is used for executing corresponding transaction operation, so that the normal proceeding of subsequent transactions can be ensured.
Fig. 4 is a schematic structural diagram of a database processing device provided in the present application, and as shown in fig. 4, a database processing device 400 provided in this embodiment includes a processing unit 401 and an updating unit 402.
The processing unit 401 is configured to poll each sub-thread with a main thread to obtain detection results of databases corresponding to the plurality of sub-threads, where the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are configured to concurrently detect running states of the databases corresponding to each other to generate detection results of the databases corresponding to each other. The updating unit 402 is further configured to update, with the main thread, an availability status of the corresponding database based on a detection result of the corresponding database, so as to perform a corresponding transaction operation according to the availability status of the database when the transaction request is received.
Optionally, the updating unit is further configured to update, by using the main thread, an available state of a corresponding database in the database list in the memory based on a detection result of the corresponding database, where the available state includes: the database is available and the database is not available.
Optionally, the updating unit is further configured to update, by using the main thread, an available state of the database corresponding to the sub thread in the database list in the memory to be unavailable if the detection result of the database corresponding to the sub thread indicates that the database is in an abnormal state; or if the detection result of the database corresponding to the sub-thread is that the database is in a normal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the available state of the database by adopting the main thread.
Optionally, the processing unit is further configured to receive a transaction request of the user terminal, and determine a target database according to the transaction request; acquiring the available state of a target database in a database list; if the available state of the target database is that the database is unavailable, determining a standby database corresponding to the target database, and forwarding the transaction request to the standby database so that the standby database can execute corresponding transaction operation according to the transaction request.
Optionally, the processing unit is further configured to parse the transaction request, and obtain a client number corresponding to the transaction request; and determining the database corresponding to the preset client number matched with the corresponding client number as a target database in the mapping relation between the preset client number and the database.
Optionally, the processing unit is further configured to forward the transaction request to the target database if the availability status of the target database is that the database is available, so that the target database performs a corresponding transaction operation according to the transaction request.
Optionally, the processing unit is further configured to determine, in a mapping relationship between the preset first database and the second database, the second database corresponding to the preset first database that matches the target database as the standby database.
Optionally, the processing unit is further configured to poll the multiple sub-threads with the main thread at preset intervals. The updating unit is further used for acquiring a database detection result corresponding to the child thread by adopting the main thread if the current detection task of the child thread is determined to be completed, and updating the available state of the corresponding database by adopting the main thread based on the database detection result corresponding to the child thread; or if the current detection task of the sub-thread is not completed, updating the available state of the database corresponding to the thread into the database timeout by adopting the main thread and recording the timeout times; and if the timeout times are equal to the preset times, updating the available state of the database corresponding to the sub-thread into the unavailable state of the database by adopting the main thread.
Fig. 5 is a block diagram of a server for implementing the database processing method of the present application, and as shown in fig. 5, the server 500 includes: a memory 501, a processor 502 and a transceiver 503.
Processor 502, memory 501 and transceiver 503 are electrically interconnected;
a transceiver 503 for transmitting and receiving data;
memory 501 stores computer-executable instructions;
processor 502 executes computer-executable instructions stored in memory 501, causing processor 502 to perform the methods provided by any of the embodiments described above.
The application also provides a service processing system, which comprises: downstream applications, upstream applications, storage systems, and servers implementing the methods as described above.
In an exemplary embodiment, there is also provided a computer-readable storage medium having stored therein computer-executable instructions for performing the method of any one of the above embodiments by a processor.
In an exemplary embodiment, a computer program product is also provided, comprising a computer program for executing the method of any of the above embodiments by a processor.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (12)

1. A database processing method, the method comprising:
adopting a main thread to poll each sub-thread to obtain detection results of databases corresponding to a plurality of sub-threads, wherein the plurality of sub-threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub-threads are used for concurrently detecting the running states of the databases corresponding to each sub-thread to generate detection results of the databases corresponding to each sub-thread;
and updating the available state of the corresponding database based on the detection result of the corresponding database by adopting the main thread so as to execute corresponding transaction operation according to the available state of the database when receiving the transaction request.
2. The method of claim 1, wherein the employing the main thread to update the availability status of the corresponding database based on the probe results of the corresponding database comprises:
updating the available states of the corresponding databases in the database list in the memory by adopting the main thread based on the detection result of the corresponding databases, wherein the available states comprise: the database is available and the database is not available.
3. The method of claim 2, wherein the updating, with the main thread, the availability status of the corresponding database in the database list in the memory based on the detection result of the corresponding database, comprises:
if the detection result of the database corresponding to the sub-thread is that the database is in an abnormal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the unavailable state of the database by adopting the main thread;
or alternatively, the process may be performed,
if the detection result of the database corresponding to the sub-thread is that the database is in a normal state, updating the available state of the database corresponding to the sub-thread in the database list in the memory into the available state of the database by adopting the main thread.
4. The method as recited in claim 2, further comprising:
receiving a transaction request of a user terminal, and determining a target database according to the transaction request;
acquiring the available state of the target database in the database list;
if the available state of the target database is that the database is unavailable, determining a standby database corresponding to the target database, and forwarding the transaction request to the standby database so that the standby database can execute corresponding transaction operation according to the transaction request.
5. The method of claim 4, wherein said determining a target database from said transaction request comprises:
analyzing the transaction request to obtain a client number corresponding to the transaction request;
and in the mapping relation between the preset client number and the database, determining the database corresponding to the preset client number matched with the corresponding client number as the target database.
6. The method as recited in claim 4, further comprising:
and if the available state of the target database is that the database is available, forwarding the transaction request to the target database so that the target database can execute corresponding transaction operation according to the transaction request.
7. The method of claim 4, wherein the determining the backup database corresponding to the target database comprises:
and in the mapping relation between the preset first database and the second database, determining the second database corresponding to the preset first database matched with the target database as the standby database.
8. The method according to any one of claims 1 to 7, further comprising:
polling a plurality of sub-threads by adopting a main thread at intervals of preset time;
if the current detection task of the sub thread is determined to be completed, acquiring a database detection result corresponding to the sub thread by adopting a main thread, and updating the available state of a corresponding database by adopting the main thread based on the database detection result corresponding to the sub thread;
or alternatively, the process may be performed,
if the fact that the current detection task of the sub-thread is not completed is determined, updating the available state of the database corresponding to the thread into the database timeout by adopting the main thread, and recording the timeout times; and if the timeout times are equal to the preset times, updating the available state of the database corresponding to the sub-thread into the unavailable state of the database by adopting the main thread.
9. A database processing apparatus, the apparatus comprising:
the processing unit is used for adopting a main thread to poll each sub thread to obtain detection results of databases corresponding to a plurality of sub threads, the plurality of sub threads are in one-to-one correspondence with the plurality of databases, and the plurality of sub threads are used for concurrently detecting the running states of the corresponding databases to generate the detection results of the corresponding databases;
and the updating unit is also used for updating the available state of the corresponding database by adopting the main thread based on the detection result of the corresponding database so as to execute corresponding transaction operation according to the available state of the database when the transaction request is received.
10. A server, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory to implement the method of any one of claims 1 to 8.
11. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1 to 8.
12. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1 to 8.
CN202310271968.7A 2023-03-16 2023-03-16 Database processing method, device, server and storage medium Pending CN116302823A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310271968.7A CN116302823A (en) 2023-03-16 2023-03-16 Database processing method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310271968.7A CN116302823A (en) 2023-03-16 2023-03-16 Database processing method, device, server and storage medium

Publications (1)

Publication Number Publication Date
CN116302823A true CN116302823A (en) 2023-06-23

Family

ID=86795616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310271968.7A Pending CN116302823A (en) 2023-03-16 2023-03-16 Database processing method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN116302823A (en)

Similar Documents

Publication Publication Date Title
Gainaru et al. Fault prediction under the microscope: A closer look into HPC systems
US7475387B2 (en) Problem determination using system run-time behavior analysis
CN107480014B (en) High-availability equipment switching method and device
WO2017177941A1 (en) Active/standby database switching method and apparatus
US10452515B2 (en) Automated root cause detection using data flow analysis
CN109308227B (en) Fault detection control method and related equipment
CN108038039B (en) Method for recording log and micro-service system
CN112613993B (en) Transaction data processing method and device, computer equipment and storage medium
CN109586989B (en) State checking method, device and cluster system
JP2015097047A (en) Determination device, determination program, and determination method
US10860411B2 (en) Automatically detecting time-of-fault bugs in cloud systems
CN116302823A (en) Database processing method, device, server and storage medium
CN111444039A (en) Cache data rollback method and cache data rollback device
CN115237641A (en) Fault detection method and device, electronic equipment and readable medium
CN116166737A (en) Resource topological graph generation method and device, electronic equipment and readable storage medium
CN114116253A (en) Message processing method and system for message queue
CN110609822B (en) Data stream processing method, device and computer program product
CN112596867A (en) Suspension transaction processing method and distributed database system
CN117424843B (en) Management method, management device and ATE test system
CN112506915B (en) Application data management system, processing method and device and server
CN117407207B (en) Memory fault processing method and device, electronic equipment and storage medium
WO2017096791A1 (en) Diagnosis test message processing method and device
CN112860492B (en) Automatic regression testing method and system suitable for core system
CN111552637B (en) Database state detection method and device, electronic equipment and storage medium thereof
US10754834B1 (en) System and method for operational continuity of backup operations to a deduplicated storage

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination