CN115629920A - Data request exception handling method and device and computer readable storage medium - Google Patents

Data request exception handling method and device and computer readable storage medium Download PDF

Info

Publication number
CN115629920A
CN115629920A CN202211237852.3A CN202211237852A CN115629920A CN 115629920 A CN115629920 A CN 115629920A CN 202211237852 A CN202211237852 A CN 202211237852A CN 115629920 A CN115629920 A CN 115629920A
Authority
CN
China
Prior art keywords
data source
request
connection
client request
database connection
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
CN202211237852.3A
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.)
Postal Savings Bank of China Ltd
Original Assignee
Postal Savings Bank of China Ltd
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 Postal Savings Bank of China Ltd filed Critical Postal Savings Bank of China Ltd
Publication of CN115629920A publication Critical patent/CN115629920A/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/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/202Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where processing functionality is redundant
    • 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/25Integrating or interfacing systems involving database management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an exception handling method and device for a data request and a computer readable storage medium. Wherein, the method comprises the following steps: responding to a client request, and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source; acquiring database connection information from a target database connection pool corresponding to a target data source; initiating a connection request to a target data source according to the database connection information, and acquiring feedback information of the connection request; and when the feedback information indicates that the connection fails, writing the client request into an assistant thread of the target database connection pool so as to process the client request by using the assistant thread. The invention solves the technical problem that the service of the whole database is abnormal due to the fact that a single database is easy to jam in the related technology.

Description

Data request exception handling method and device and computer readable storage medium
Technical Field
The present invention relates to the field of computers, and in particular, to an exception handling method for a data request, an exception handling apparatus for the data request, and a computer-readable storage medium.
Background
In conventional database-centric transaction systems, database connections are a critical, limited, expensive resource. Therefore, for multi-thread service, a method of connecting pools by using a database is generally used, and multiple uses are realized by one-time creation.
A common implementation of a database connection pool is to employ a producer/consumer model. The service typically establishes a certain number of connections as an initial pool of connections upon startup as specified by the parameters. The operation of the service getting the connection can be regarded as a consumer connection and the operation of releasing the connection can be regarded as a producer generating the connection. In a common implementation, a general consumer acquires a connection in a blocking waiting manner, and if the connection is not waited for due to timeout, an error exit is reported.
In a scenario with multiple data sources, a service generally starts a group of working threads, and a connection pool is started for each data source, and the number of the working threads is generally much larger than that of the connection pools. The worker thread can obtain a certain connection in the designated thread pool according to the business logic requirement. In an actual transaction scenario, a typical transaction is bound to a data source. I.e., transactions made on data source a cannot be processed using data source B.
Fig. 1 is a schematic diagram of a processing scenario of two data sources according to the prior art, as shown in fig. 1, each connection pool (i.e., connection pool 1, connection pool 2) binds one data source (i.e., DB1, DB 2) in an application service.
The mainstream problem about the distributed multi-data source database connection pool in the market at present mainly adopts a solution of connection pool middleware. The connection pool middleware generally starts a group of data connections for each data source, adds a connection monitoring mechanism for each connection, and monitors the connection state of the data source through timing monitoring or event triggering monitoring; and shielding the data source in time when the data source abnormity is detected. The middleware of the connection pool provides a uniform database operation interface for the outside, and is convenient for application, acquisition and connection release. Fig. 2 is a block diagram of a middleware process of a connection pool in the prior art, which adds a connection pool manager to the process of fig. 1 for monitoring the status of data sources and shielding abnormal data sources in time.
However, the above conventional database connection pool has the following problems in a multi-data source scenario: 1) The method is sensitive to the scene of unbalanced transaction, and if the transaction of a certain database is excessive, the working thread is always occupied, so that the processing response of other databases is influenced; 2) The method is sensitive to abnormal transactions, and if a deadlock table exists in a certain data source and is used by application transactions, the transactions possibly block the whole working thread group, so that service cannot be provided to the outside; 3) The single database exception is sensitive, and if a certain database is abnormally serviced, the request processing is slow, which can seriously affect the performance of the whole system.
Fig. 3 is a schematic diagram of an abnormal scenario of two data sources according to the prior art, in fig. 3, an application service directly connects two data sources DB1 and DB2, when DB1 processes slowly, a worker thread takes a long time when processing a DB1 request, other threads that do not get a connection block waiting for an available connection, when the number of concurrent requests of DB1 exceeds the number of worker threads, the whole worker thread group is blocked, and the request of the DB2 data source cannot be accessed, which affects the external service of the whole system.
From the above analysis, the scheme of adopting the connection pool middleware does not essentially solve the defects of the distributed multi-data source data connection pool. Firstly, monitoring that an abnormal data source has certain hysteresis, and completely blocking all requests before being shielded by the abnormal data source under the condition of large transaction amount; second, the criteria for exception monitoring are difficult to set, since the data source may be only a critical table that has been deadlocked causing an application exception, but the monitoring is difficult to detect and mask.
The above information disclosed in this background section is only for enhancement of understanding of the background of the technology described herein and, therefore, it may contain information that does not form the prior art that is already known in this country to a person of ordinary skill in the art.
Disclosure of Invention
The embodiment of the invention provides an exception handling method and device for a data request and a computer readable storage medium, which at least solve the technical problem that in the related technology, a single database is easy to be stuck to cause exception of the service of the whole database.
According to an aspect of the embodiments of the present invention, there is provided a method for processing an exception of a data request, including: responding to a client request, and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source; acquiring database connection information from a target database connection pool corresponding to the target data source; initiating a connection request to the target data source according to the database connection information, and acquiring feedback information of the connection request; and when the feedback information shows that the connection fails, writing the client request into an auxiliary thread of the target database connection pool so as to process the client request by utilizing the auxiliary thread.
Optionally, before responding to a client request and determining a target data source according to application logic corresponding to the client request, the method further includes: creating an auxiliary thread group for each of a plurality of data sources including the target data source while respectively creating a database connection pool for the plurality of data sources; a database connection and request queue is created for each helper thread in the set of helper threads.
Optionally, the obtaining of database connection information from a target database connection pool corresponding to the target data source includes: and acquiring the database connection information from a database connection pool corresponding to the target data source in a non-blocking mode.
Optionally, the method further comprises: and when the feedback information shows that the connection is successful, processing the client request through the target data source.
Optionally, writing the client request to an assist thread of the target database connection pool, so as to process the client request by using the assist thread, including: writing the client request into a processing queue of an auxiliary thread of the target database connection pool; acquiring the client request from the processing queue by using the target database connection pool; and calling a callback interface to process the client request.
Optionally, the method further comprises: and generating error reporting information when the feedback information indicates connection failure.
According to an aspect of the embodiments of the present invention, there is provided an exception handling apparatus for a data request, including: the determining module is used for responding to a client request and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source; the acquisition module is used for acquiring database connection information from a target database connection pool corresponding to the target data source; the connection initiating module is used for initiating a connection request to the target data source according to the database connection information and acquiring feedback information of the connection request; and the writing module is used for writing the client request into an auxiliary thread of the target database connection pool when the feedback information shows that the connection fails, so that the client request is processed by the auxiliary thread.
Optionally, the apparatus further comprises: the system comprises a first establishing module, a second establishing module and a third establishing module, wherein the first establishing module is used for establishing an auxiliary thread group for each data source in a plurality of data sources while respectively establishing a database connection pool for the data sources comprising a target data source before responding to a client request and determining the target data source according to application logic corresponding to the client request; a second creation module to create a database connection and request queue for each helper thread in the helper thread group.
Optionally, the obtaining module includes: and the first acquisition unit is used for acquiring the database connection information from the database connection pool corresponding to the target data source in a non-blocking mode.
Optionally, the apparatus further comprises: and the processing request module is used for processing the client request through the target data source when the feedback information shows that the connection is successful.
Optionally, the writing module includes: the writing unit is used for writing the client request into a processing queue of an auxiliary thread of the target database connection pool; a second obtaining unit, configured to obtain the client request from the processing queue by using the target database connection pool; and calling a callback interface to process the client request.
Optionally, the apparatus further comprises: and the error reporting module is used for generating error reporting information when the feedback information shows that the connection fails.
According to an aspect of the embodiments of the present invention, there is provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, a device on which the computer-readable storage medium is located is controlled to execute the exception handling method for a data request in any one of the above.
According to an aspect of the embodiments of the present invention, there is provided a processor, where the processor is configured to execute a program, where the program executes an exception handling method for a data request according to any one of the foregoing methods when running.
In the embodiment of the invention, a client request is responded, and a target data source is determined according to application logic corresponding to the client request, wherein the target data source is a currently processed data source; acquiring database connection information from a target database connection pool corresponding to a target data source; initiating a connection request to a target data source according to the database connection information, and acquiring feedback information of the connection request; and when the feedback information indicates that the connection fails, writing the client request into an assistant thread of the target database connection pool so as to process the client request by using the assistant thread. By the data request exception handling method provided by the embodiment of the invention, the purpose of processing the client request by using the auxiliary thread when the target data source connection fails after the target data source is determined is achieved, so that the technical effect of improving the transmission efficiency is realized, and the technical problem of the whole database service exception caused by the fact that a single database is easy to block in the related technology is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention and do not constitute a limitation of the invention. In the drawings:
FIG. 1 is a schematic diagram of a processing scenario of two data sources according to the prior art;
FIG. 2 is a block diagram of prior art connection pool middleware processing;
FIG. 3 is a schematic diagram of an exception scenario according to two data sources in the prior art;
FIG. 4 is a flow diagram of a method of exception handling for a data request according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a preferred data request exception handling method according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating another preferred method of exception handling for data requests, according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating an exception handling apparatus for a data request according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in other sequences than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with an embodiment of the present invention, there is provided an embodiment of a method for exception handling of a data request, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 4 is a flowchart of an exception handling method for a data request according to an embodiment of the present invention, and as shown in fig. 4, the method includes the following steps:
step S402, responding to a client request, and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source;
optionally, after responding to the client request, the data source currently processed is determined according to the application logic in the client request.
Step S404, obtaining database connection information from a target database connection pool corresponding to a target data source, wherein the database connection information is certificate information of data obtained from the target data source;
in the above steps, the corresponding database connection information is obtained from the target database connection pool corresponding to the target data source, so as to obtain the database connection information to obtain the target data.
Step S406, initiating a connection request to a target data source according to the database connection information, and acquiring feedback information of the connection request;
in the above steps, after the database connection information is obtained from the target database connection pool corresponding to the data source, a connection request and feedback information of the connection request are initiated to the target data source according to the information of the database connection information, so as to monitor the connection condition.
And step S408, when the feedback information shows that the connection fails, writing the client request into an assistant thread of the target database connection pool so as to process the client request by using the assistant thread.
As can be seen from the above, in the embodiment of the present invention, first, in response to a client request, a target data source is determined according to an application logic corresponding to the client request, where the target data source is a currently processed data source; then, database connection information can be obtained from a target database connection pool corresponding to the target data source; initiating a connection request to a target data source according to the database connection information, and acquiring feedback information of the connection request; and finally, when the feedback information indicates that the connection fails, writing the client request into an assistant thread of the target database connection pool so as to process the client request by using the assistant thread. By the data request exception handling method provided by the embodiment of the invention, the purpose of processing the client request by using the auxiliary thread when the target data source connection fails after the target data source is determined is achieved, so that the technical effect of improving the transmission efficiency is realized, and the technical problem of the whole database service exception caused by the fact that a single database is easy to block in the related technology is solved.
As an optional embodiment, before responding to the client request, determining the target data source according to the application logic corresponding to the client request, the method further includes: creating an auxiliary thread group for each of a plurality of data sources while respectively creating database connection pools for the plurality of data sources including a target data source; a database connection and request queue is created for each helper thread in the helper thread group.
In the above optional embodiment, before the client determines the target data source, an auxiliary thread group is created for each data source in the multiple data sources, and a corresponding database connection and request queue are created for the data source, that is, a dedicated auxiliary thread group is allocated to each connection pool, the auxiliary thread group only includes a small number of threads, each thread monopolizes one database connection, the auxiliary thread group is associated with one request processing queue, the auxiliary thread circularly acquires a request from the queue and uses its own monopolized connection for actual service processing, the application code needs to write a callback interface for the auxiliary thread, and the auxiliary thread processes actual service logic through the callback interface, so that data transmission is more organized, and data transmission efficiency is improved.
As an optional embodiment, the obtaining the database connection information from the target database connection pool corresponding to the target data source includes: and acquiring database connection information from a database connection pool corresponding to the target data source in a non-blocking mode.
In the above optional embodiments, the manner when the database link information is obtained from the database connection pool corresponding to the target data source includes, but is not limited to: non-blocking. It should be noted that, when the database connection is obtained in a non-blocking manner, if the connection does not have a direct error reporting and the connection does not exist, the feedback of the data obtaining situation of the database is very intuitive, and the efficiency of data obtaining and system operation is improved.
As an alternative embodiment, the method further comprises: and when the feedback information indicates that the connection is successful, processing the client request through the target data source.
In the above optional embodiment, when the content in the feedback information indicates that the connection is successful, the request of the client is processed by the target data source, so as to reduce a redundant process of system operation and improve data transmission efficiency.
As an alternative embodiment, writing the client request to the helper thread of the target database connection pool to process the client request by using the helper thread, includes: writing the client request into a processing queue of an auxiliary thread of a target database connection pool; acquiring a client request from a processing queue by using a target database connection pool; and calling a callback interface to process the client request.
In the above optional embodiment, the client request is first written into the processing queue of the assist thread of the target database connection pool, then the client request is acquired from the processing queue by using the target database connection pool, and finally the callback interface is called to process the client request, so that the data transmission efficiency is improved, and the response feedback speed is enhanced.
As an alternative embodiment, the method further comprises: and generating error information when the feedback information indicates connection failure.
In the above optional embodiments, the exception handling method for a data request provided by the embodiments of the present invention provides two improvement measures:
1) And modifying the database connection in a non-blocking manner, namely when the database connection is acquired, if the connection does not exist, directly reporting an error and returning that the connection does not exist.
2) And allocating a special auxiliary thread group for each connection pool, wherein the auxiliary thread group only comprises a small number of threads, each thread monopolizes one database connection, the auxiliary thread group is associated with one request processing queue, the auxiliary thread circularly acquires requests from the queue and uses the monopolized connection of the auxiliary thread group for actual service processing, application codes need to write a callback interface for the auxiliary thread, and the auxiliary thread processes actual service logic through the callback interface.
Further, the processing logic modified by the method provided by the embodiment of the present invention is as follows:
1. the service creates a database connection pool, simultaneously creates a corresponding auxiliary thread group, and creates an exclusive database connection and a request queue associated with the thread group for each thread;
2. when a client requests, the working thread determines a currently processed data source according to the application logic;
3. obtaining database connection from a connection pool of a specified data source in a non-blocking manner;
4. if the connection acquisition is successful, the request is processed normally; if the connection acquisition fails, writing the request into a processing queue of the connection pool auxiliary thread;
5. and the auxiliary thread acquires the request from the queue and calls a callback interface to finish application processing.
FIG. 5 is a schematic diagram of a preferred data request exception handling method according to an embodiment of the present invention, as shown in FIG. 5, the connection mode after improvement is that the work thread group is connected with the connection pool in a non-blocking acquisition mode, which increases the fault tolerance rate of the system
Fig. 6 is a schematic diagram of another preferred method for processing an exception of a data request according to an embodiment of the present invention, as shown in fig. 6, when a single database is abnormal, assist transmission is performed by a database thread, when the database DB1 is slow to process, all work threads that have fetched DB1 database connection block processing, and threads that have not fetched DB1 connection directly report an error because they are non-blocking fetching, and then write the request into an auxiliary thread group queue of a DB1 data source, and exit quickly, so that a work thread group always has an idle work thread to process a request of DB2, and a single data source abnormality does not affect the targets of other data source applications, so as to increase transmission efficiency and fault tolerance of the system.
Therefore, the method provided by the embodiment of the invention realizes a management allocation mechanism of the multi-data source connection pool, and solves the problem that the whole service cannot be normally used due to the exception of a single data source. The method adopts a mechanism of non-blocking connection and auxiliary thread, considers both the connection acquisition efficiency and the data source response efficiency, effectively reduces the mutual influence of different data sources in the same service processing, and improves the quality of a database connection pool. The method is used in an actual service system, has good effect and also has the following advantages:
1) And a mechanism for non-blocking acquisition connection of the connection pool interface.
2) And establishing an auxiliary thread group and establishing a corresponding auxiliary thread group queue by the connection pool.
3) And the auxiliary thread adopts an exclusive database connection mode, can slowly digest the request on the specified database, and can effectively adapt to the condition that the database suddenly slows down.
Example 2
According to an aspect of the embodiments of the present invention, there is provided an apparatus for processing an exception of a data request, and fig. 7 is a schematic diagram of an apparatus for processing an exception of a data request according to an embodiment of the present invention, as shown in fig. 7, including: a determination module 71, an acquisition module 73, an originating connection module 75, and a write module 77. The exception handling apparatus for a data request is explained in detail below.
A determining module 71, configured to respond to a client request, determine a target data source according to application logic corresponding to the client request, where the target data source is a currently processed data source;
an obtaining module 73, configured to obtain database connection information from a target database connection pool corresponding to a target data source;
the connection initiating module 75 is configured to initiate a connection request to a target data source according to the database connection information, and obtain feedback information of the connection request;
and a writing module 77, configured to write the client request into an assist thread of the connection pool of the target database when the feedback information indicates that the connection fails, so as to process the client request by using the assist thread.
It should be noted here that the determining module 71, the obtaining module 73, the initiating connection module 75 and the writing module 77 correspond to steps S402 to S408 in embodiment 1, and a plurality of modules are the same as the corresponding steps in the implementation example and the application scenario, but are not limited to the disclosure in embodiment 1.
As can be seen from the above, in the embodiment of the present invention, the determining module 71 may first be utilized to respond to the client request, and determine the target data source according to the application logic corresponding to the client request, where the target data source is a currently processed data source; then, the obtaining module 73 is used for obtaining database connection information from a target database connection pool corresponding to the target data source; then, initiating a connection request to the target data source by using the connection initiating module 75 according to the database connection information, and acquiring feedback information of the connection request; finally, when the feedback information indicates that the connection fails, the write-in module 77 is used to write the client request into the helper thread of the connection pool of the target database, so as to process the client request by using the helper thread. By the data request exception handling device provided by the embodiment of the invention, the purpose of processing the client request by using the auxiliary thread when the target data source is failed to be connected after the target data source is determined is achieved, so that the technical effect of improving the transmission efficiency is realized, and the technical problem of service exception of the whole database caused by easy blocking of a single database in the related technology is solved.
Optionally, the apparatus further comprises: the system comprises a first establishing module, a second establishing module and a third establishing module, wherein the first establishing module is used for establishing an auxiliary thread group for each data source in a plurality of data sources while respectively establishing a database connection pool for the plurality of data sources comprising a target data source before responding to a client request and determining the target data source according to application logic corresponding to the client request; a second creation module to create a database connection and request queue for each helper thread in the helper thread group.
In the above optional embodiment, before the client determines the target data source, an auxiliary thread group is created for each data source in the multiple data sources, and a corresponding database connection and request queue are created for the data source, that is, a dedicated auxiliary thread group is allocated to each connection pool, the auxiliary thread group only includes a small number of threads, each thread monopolizes one database connection, the auxiliary thread group is associated with one request processing queue, the auxiliary thread circularly acquires a request from the queue and uses its own monopolized connection for actual service processing, the application code needs to write a callback interface for the auxiliary thread, and the auxiliary thread processes actual service logic through the callback interface, so that data transmission is more organized, and data transmission efficiency is improved.
Optionally, the obtaining module includes: the first obtaining unit is used for obtaining database connection information from a database connection pool corresponding to a target data source in a non-blocking mode.
In the above optional embodiments, the manner when the database link information is obtained from the database connection pool corresponding to the target data source includes, but is not limited to: non-blocking. It should be noted that, when the database connection is obtained in a non-blocking manner, if the connection does not have a direct error reporting and the connection does not exist, the feedback of the data obtaining situation of the database is very intuitive, and the efficiency of data obtaining and system operation is improved.
Optionally, the apparatus further comprises: and the processing request module is used for processing the client request through the target data source when the feedback information shows that the connection is successful.
In the above optional embodiment, first, when the content in the feedback information indicates that the connection is successful, the request of the client is processed by the target data source, so as to reduce a redundant flow of system operation and improve data transmission efficiency.
Optionally, a write module comprising: the writing unit is used for writing the client request into a processing queue of an auxiliary thread of a target database connection pool; the second acquisition unit is used for acquiring the client request from the processing queue by using the target database connection pool; and calling a callback interface to process the client request.
In the above optional embodiment, the client request is first written into the processing queue of the assist thread of the target database connection pool, then the target database connection pool is used to acquire the client request from the processing queue, and finally the callback interface is called to process the client request, so as to improve the data transmission efficiency and enhance the response feedback speed.
Optionally, the apparatus further comprises: and the error reporting module is used for generating error reporting information when the feedback information shows that the connection fails.
Example 3
According to an aspect of the embodiments of the present invention, there is provided a computer-readable storage medium, which includes a stored program, wherein when the program runs, a device in which the computer-readable storage medium is located is controlled to execute an exception handling method for a data request in any one of the above.
Example 4
According to an aspect of the embodiments of the present invention, there is provided a processor, configured to execute a program, where the program executes an exception handling method for a data request in any one of the above.
Example 5
According to an aspect of an embodiment of the present invention, there is provided an electronic apparatus including: a processor; and a computer readable storage medium for storing executable instructions for the processor; wherein the processor is configured to perform any of the exception handling methods of the data request via execution of the executable instructions.
It should be noted that for simplicity of description, the above-mentioned method embodiments are shown as a series of combinations of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art will appreciate that the embodiments described in this specification are presently preferred and that no acts or modules are required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or may not be executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be an indirect coupling or communication connection through some interfaces, units or modules, and may be electrical or in other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is substantially or partly contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method for exception handling of data requests, comprising:
responding to a client request, and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source;
acquiring database connection information from a target database connection pool corresponding to the target data source, wherein the database connection information is credential information of data acquired from the target data source;
initiating a connection request to the target data source according to the database connection information, and acquiring feedback information of the connection request;
and when the feedback information indicates that the connection fails, writing the client request into an assistant thread of the target database connection pool so as to process the client request by using the assistant thread.
2. The method of claim 1, wherein prior to determining a target data source in response to a client request according to application logic to which the client request corresponds, the method further comprises:
creating an auxiliary thread group for each of a plurality of data sources including the target data source while respectively creating a database connection pool for the plurality of data sources;
a database connection and request queue is created for each helper thread in the set of helper threads.
3. The method of claim 1, wherein obtaining database connection information from a target database connection pool corresponding to the target data source comprises:
and acquiring the database connection information from a database connection pool corresponding to the target data source in a non-blocking mode.
4. The method of claim 1, further comprising:
and when the feedback information shows that the connection is successful, processing the client request through the target data source.
5. The method of claim 1, wherein writing the client request to a helper thread of the target database connection pool for processing the client request with the helper thread comprises:
writing the client request into a processing queue of an auxiliary thread of the target database connection pool;
acquiring the client request from the processing queue by using the target database connection pool;
and calling a callback interface to process the client request.
6. The method according to any one of claims 1 to 5, further comprising:
and generating error reporting information when the feedback information indicates that the connection fails, wherein the error reporting information is prompt information for prompting that the connection fails.
7. An exception handling apparatus for a data request, comprising:
the determining module is used for responding to a client request and determining a target data source according to application logic corresponding to the client request, wherein the target data source is a currently processed data source;
the acquisition module is used for acquiring database connection information from a target database connection pool corresponding to the target data source;
the connection initiating module is used for initiating a connection request to the target data source according to the database connection information and acquiring feedback information of the connection request;
and the writing module is used for writing the client request into an auxiliary thread of the target database connection pool when the feedback information shows that the connection fails, so that the client request is processed by the auxiliary thread.
8. A computer-readable storage medium, comprising a stored program, wherein when the program is executed, a device on which the computer-readable storage medium is located is controlled to execute the data request exception handling method according to any one of claims 1 to 6.
9. A processor, configured to run a program, wherein the program runs to perform the exception handling method for a data request according to any one of claims 1 to 6.
10. An electronic device, comprising:
the processor; and
the computer-readable storage medium storing executable instructions for the processor;
wherein the processor is configured to perform the method of exception handling for a data request of any of claims 1 to 6 via execution of the executable instructions.
CN202211237852.3A 2022-09-27 2022-10-10 Data request exception handling method and device and computer readable storage medium Pending CN115629920A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211182989 2022-09-27
CN2022111829893 2022-09-27

Publications (1)

Publication Number Publication Date
CN115629920A true CN115629920A (en) 2023-01-20

Family

ID=84903989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211237852.3A Pending CN115629920A (en) 2022-09-27 2022-10-10 Data request exception handling method and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN115629920A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116383083A (en) * 2023-04-23 2023-07-04 中航信移动科技有限公司 Multi-interface connection-based abnormal data source determining method and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116383083A (en) * 2023-04-23 2023-07-04 中航信移动科技有限公司 Multi-interface connection-based abnormal data source determining method and storage medium
CN116383083B (en) * 2023-04-23 2024-01-12 中航信移动科技有限公司 Multi-interface connection-based abnormal data source determining method and storage medium

Similar Documents

Publication Publication Date Title
JP7142152B2 (en) Transaction processing method, device, equipment and computer program
US8484659B2 (en) Distributed processing of binary objects via message queues including a failover safeguard
US7080287B2 (en) First failure data capture
US5594861A (en) Method and apparatus for handling processing errors in telecommunications exchanges
WO2019179026A1 (en) Electronic device, method for automatically generating cluster access domain name, and storage medium
US7480816B1 (en) Failure chain detection and recovery in a group of cooperating systems
CN111580939B (en) Method and device for processing transactions in hierarchical and asynchronous mode
CN114253673A (en) Transaction processing method and transaction processing device of distributed system
CN113157411B (en) Celery-based reliable configurable task system and device
US11544245B2 (en) Transaction processing method, apparatus, and device and computer storage medium
CN109684048B (en) Method and device for processing transaction in transaction submitting system
CN115629920A (en) Data request exception handling method and device and computer readable storage medium
CN111538585B (en) Js-based server process scheduling method, system and device
US8103905B2 (en) Detecting and recovering from process failures
JP2005538460A (en) Data processing system and method (data processing system adapted to integrate heterogeneous processes)
US7467324B1 (en) Method and apparatus for continuing to provide processing on disk outages
US6487580B1 (en) Method and system for managing concurrently executable computer processes
CN115934272A (en) Online batch task processing method and device
CN106776052B (en) Shared resource access method and device
CN114331445A (en) API (application programming interface), method, storage medium and electronic equipment for accessing massive users
CN113961366A (en) Kernel function calling method of operating system and computer equipment
WO2024174306A1 (en) Transaction hosting method and apparatus based on shared storage database cluster
US8533331B1 (en) Method and apparatus for preventing concurrency violation among resources
CN105574020B (en) Database operation method and device
CN115344366B (en) Connection pool object switching method and device, electronic equipment and readable storage medium

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