CN115309726A - Database instance access method and device - Google Patents

Database instance access method and device Download PDF

Info

Publication number
CN115309726A
CN115309726A CN202211178045.9A CN202211178045A CN115309726A CN 115309726 A CN115309726 A CN 115309726A CN 202211178045 A CN202211178045 A CN 202211178045A CN 115309726 A CN115309726 A CN 115309726A
Authority
CN
China
Prior art keywords
connector
target
connection
database instance
pool
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.)
Granted
Application number
CN202211178045.9A
Other languages
Chinese (zh)
Other versions
CN115309726B (en
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.)
Beijing Oceanbase Technology Co Ltd
Original Assignee
Beijing Oceanbase Technology Co 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 Beijing Oceanbase Technology Co Ltd filed Critical Beijing Oceanbase Technology Co Ltd
Priority to CN202211178045.9A priority Critical patent/CN115309726B/en
Publication of CN115309726A publication Critical patent/CN115309726A/en
Application granted granted Critical
Publication of CN115309726B publication Critical patent/CN115309726B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

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

Abstract

The embodiment of the specification provides a database instance access method and device, and the method comprises the step of receiving an access request aiming at a target database instance, wherein the access request comprises a target connection parameter connected with the target database instance. And searching the target connector matched with the target connection parameter from the connector pool. The connector pool stores a plurality of connectors corresponding to different connection parameters of a plurality of database instances, and each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters. In the event that there is a free connection in the target connector, the target database instance is accessed using the free connection.

Description

Database instance access method and device
Technical Field
One or more embodiments of the present disclosure relate to the field of databases, and in particular, to a method and an apparatus for accessing a database instance.
Background
In a distributed database, a large number of database instances are usually created, for example, one database instance is created for each tenant. A database instance is here understood to be a database server in which one or more databases may be created, in each of which one or more data tables may be created, in which private data may be stored.
For the database instances, the external system usually sends management or query commands to the database instances frequently, or accesses the database instances frequently. However, if a connection is established for each access of each database instance, the size of the established connection may be very large, thereby increasing the management cost of the connection.
Disclosure of Invention
One or more embodiments of the present specification describe a method and an apparatus for accessing a database instance, which may use an established idle connection to access the database instance, thereby reducing the number of connections and further reducing the management cost of the connections.
In a first aspect, a method for accessing a database instance is provided, including:
receiving an access request for a target database instance; the access request comprises a target connection parameter connected with the target database instance;
searching a target connector matched with the target connection parameter from a connector pool; the connector pool is stored with a plurality of connectors corresponding to different connection parameters of a plurality of database instances; each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters;
in the event there is a free connection in the target connector, accessing the target database instance using the free connection.
In a second aspect, an apparatus for accessing a database instance is provided, including:
a receiving unit, configured to receive an access request for a target database instance; the access request comprises a target connection parameter connected with the target database instance;
the searching unit is used for searching a target connector matched with the target connection parameter from a connector pool; the connector pool is stored with a plurality of connectors corresponding to different connection parameters of a plurality of database instances; each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters;
a using unit, configured to access the target database instance using an idle connection if the idle connection exists in the target connector.
In a third aspect, there is provided a computer storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect.
In a fourth aspect, there is provided a computing device comprising a memory having stored therein executable code and a processor that, when executing the executable code, implements the method of the first aspect.
In the method and the apparatus for accessing a database instance provided in one or more embodiments of the present specification, when accessing a database instance, a connector pool is first searched for a connector matching the database instance. The database instance is then accessed using the free connection in the connector. That is to say, the scheme can use the established idle connection to access the database instance, so that the number of connections can be reduced, and further, the database instance can be accessed under the condition of saving management cost.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present specification, the drawings used in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the description below are only some embodiments of the present specification, and it is obvious for those skilled in the art that other drawings may be obtained according to these drawings without creative efforts.
FIG. 1 is a schematic diagram illustrating an implementation scenario of an embodiment disclosed herein;
FIG. 2 illustrates a flow diagram of a method for accessing a database instance, according to one embodiment;
FIG. 3 illustrates a flow diagram of a method for accessing an instance of a database, according to another embodiment;
FIG. 4 shows a schematic diagram of an access device for a database instance, according to one embodiment.
Detailed Description
The scheme provided by the specification is described in the following with reference to the attached drawings.
As mentioned above, a large number of database instances are usually created in a distributed database, and if a connection is established for each access of each database instance, the size of the established connection is very large, thereby increasing the management cost of the connection. For this purpose, the following two improvements are proposed:
first, pooling the connections of database instances, i.e., establishing different connection pools when accessing the same database instance based on different connection parameters. This results in multiple connection pools being established for the same database instance. Thus, when the number of database instances is large, the size of the established connection pool is also large.
In addition, since the connection pool itself does not contain the information of the database instance to which it belongs, a mapping relationship between the database instance and the connection pool needs to be established, so that the corresponding connection pool can be correctly released when the database instance is deleted. The number of managed database instances is usually not fixed, and may change with management and control services (such as adding a database instance and deleting a database instance), so that it is necessary to continuously manage and maintain a connection pool, which is costly.
Second, a cache management mechanism is used to manage all connections to the database instances. And preferentially acquiring the available connection from the cache according to the access request, if the available connection is acquired, directly using the connection, and if the available connection is not acquired, newly establishing the connection. Invalid connections are periodically checked and cleared by a timing mechanism. The disadvantage of this scheme is that the granularity of the cache is too small, which is not convenient for uniform management and monitoring of the connection according to the dimension of the database instance.
It can be seen that both of the above solutions have corresponding disadvantages, and for this reason, the inventors of the present application propose to manage all connections of a single database instance by establishing connectors, then organize the connectors of each database instance into a connector pool, and manage and reuse the stored connections of the database instances based on a secondary cache management mechanism. Specifically, when accessing a database instance, a matching connector is first searched from a connector pool according to a connection parameter connected to the database instance. The database instance is then accessed using the free connections in the connector.
It should be noted that, compared with the first solution, the present solution may avoid maintaining a large number of connection pools, so as to manage the connection of the database instances in a more convenient manner. Compared with the second scheme, the connection of the database instances is cached in a reasonable granularity, so that the connection of the database instances is managed and monitored uniformly according to the dimension of the database instances.
This scheme will be described in detail below.
Fig. 1 is a schematic view of an implementation scenario of an embodiment disclosed in this specification. In FIG. 1, an external system maintains a pool of connectors that store respective connectors for N database instances. The connector of the database instance 1 comprises a connector 1 and a connector 3, in other words, the connector 1 and the connector 3 belong to the database instance 1, and the connector 1 corresponds to a connection parameter a, wherein a plurality of connections established with the database instance 1 based on the connection parameter a are stored. The connector 3 corresponds to a connection parameter c in which several connections established with the database instance 1 based on the connection parameter c are stored. Further, the connector of database instance 2 includes connector 2, and the connector of database instance N includes connector N-1 and connector N, and so on.
Optionally, the connector further stores identity information of the database instance. In one example, the identity information may be, for example, a unique identification of the database instance.
In addition, each connector in the connector pool may be stored as a queue, and the external system manages each connector based on a Least Recently Used (LRU) mechanism.
In fig. 1, when an external system needs to access a database instance, a matching connector is first searched from a connector pool according to connection parameters connected to the database instance. The database instance is then accessed using the free connection in the connector. For example, when the database instance 1 needs to be accessed, assuming that the current connection parameter is the connection parameter c, the found matching connector is the connector 3. Database instance 1 is then accessed using the free connections in connector 3.
If the matched connector cannot be found or no idle connection exists in the found connector, a new connection is established with the database instance based on the current connection parameters, and the database instance 1 is accessed by using the new connection, which will be described in detail later.
It should be noted that the external system may be a management and control system for managing the multiple database instances, or may be a business system. It will be appreciated that where the external system is a governing system, the connection in each connector is that of the governing system with the database instance. In the case where the external system is a business system, the connection in each connector is the business system's connection to the database instance.
It should also be noted that fig. 1 is only an exemplary illustration, and in practical applications, each database instance may include more or less connectors, which is not limited in the present specification.
FIG. 2 illustrates a flow diagram of a method for accessing a database instance, according to one embodiment. It is to be appreciated that the method can be performed by any system, device, platform, cluster of devices having computing and processing capabilities. As shown in fig. 2, the access method includes at least the following steps.
Step 202, an access request for a target database instance is received, where the access request includes target connection parameters for connecting with the target database instance.
The access request may be sent by a front-end page of the governing system, or may be sent by an upper-layer application of the governing system.
In one example, when the management and control system establishes a connection with a database instance based on JDBC (an important core technology in the java ee standard, which provides a method for connecting and accessing a database, querying and updating the database), the target connection parameters are also generally referred to as a five-tuple, which may include an IP address and a port of the target database instance, an account and a password of a user under a tenant corresponding to the target database instance, and a database name of a database in the target database instance.
It should be noted that the contents of the five-tuple of the database instance are used in combination, and if one of them (for example, the database name) changes, a new five-tuple is formed, so that different connection parameters can be obtained. In this scheme, connections established based on the same connection parameters are stored in the same connector.
And step 204, searching a target connector matched with the target connection parameter from the connector pool.
In one example, the target connector may be looked up based only on the target connection parameters. For example, the target connection parameter is compared with the connection parameter corresponding to each connector in the connector pool, and if the target connection parameter is consistent with any connection parameter, the connector corresponding to the connection parameter is used as the target connector.
For example, referring to fig. 1, assuming that the target database instance is database instance 1 and the target connection parameter is connection parameter c, the connection parameter c may be compared with the connection parameters corresponding to the connectors in the connector pool, and since the connection parameter c is successfully matched with the connection parameters corresponding to the connector 3, the found target connector is connector 3.
In another example, the target connector may also be found in conjunction with the target connection parameters and the identity information of the target database instance. For example, each connector in the connector pool is recorded by a key _ value pair, where the key value is the connection parameter and the identity information of the database instance, and the value is the connector. Then, a target value may be formed based on the target connection parameter and the identity information of the target database instance, and then the target connector is determined by comparing the target value with the key value of each key _ value pair in the connector pool and recording the value of the key value corresponding to the matched key value.
Further, in one example, each connector in the connector pool is stored as a connector queue.
In the case where each connector in the connector pool is stored as a connector queue, the above-mentioned searched target connector may be moved to the head of the connector queue to ensure that the frequently used connector can be arranged at the front of the queue.
In step 206, in the event that there is an idle connection in the target connector, the target database instance is accessed using the idle connection.
As mentioned above, each connector described in this specification may store several connections established based on corresponding connection parameters, so after finding the target connector, a free connection may be selected from them to access the target database instance.
It should be noted that, in the case where there is no idle connection in the target connector, it may be determined whether the number of connections of the target connector is less than a first number threshold (also referred to as a maximum number of connections). In the event that the number of connections of the target connector is not less than the first number threshold, waiting for an idle connection. In the event the number of connections of the target connector is less than a first number threshold, a target connection is established with the target database instance based on the target connection parameters and the target database instance is accessed using the target connection.
Thereafter, the target connection may be added to the target connector and the number of connections of the target connector may be increased by 1.
It should be understood that the above is a description of the case where the target connector is found from the connector pool. In the case that the target connector cannot be found, a target connection with the target database instance may be established directly based on the target connection parameters and used to access the target database instance.
Thereafter, for a target database instance, a new connector corresponding to the target connection parameters is created and added to the connector pool, as well as the established target connection.
Of course, in practical applications, in the case that the target connector cannot be found, a new connector corresponding to the target connection parameter may be created for the target database instance, and the new connector may be added to the connector pool. Thereafter, a target connection is established with the target database instance based on the target connection parameters, the target connection is added to the connector, and the target database instance is accessed using the target connection.
In one example, there is no maximum limit on the number of connectors in the connector pool described above, so that new connectors can be added directly to the connector pool.
In another example, the number of connectors in the connector pool is maximally limited, and each connector in the connector pool may be stored as a connector queue, the adding a new connector to the connector pool comprising: it is determined whether the number of connectors in the connector pool is less than a second number threshold (also referred to as a maximum number of connectors). In the event that the number of connectors in the connector pool is less than the second number threshold, adding the new connector to the head of queue of connectors. In the case where the number of connectors is not less than the second number threshold, the connector at the end of the connector queue is deleted, and a new connector is added to the head of the connector queue.
It should be noted that, in the embodiment of the present specification, after the target connector is found, the target connector is moved to the head of the connector queue, and when the number of connectors in the connector pool reaches the maximum number of connectors, the connectors are deleted from the tail of the connector queue, so that it can be ensured that frequently used connectors are always stored in the connector pool, that is, the present solution adopts an LRU mechanism to manage the connectors of each database instance.
Finally, as mentioned above, each connector in the connector pool may also have stored therein identity information of the database instance to which it belongs. Such as a unique identification of the database instance to which it belongs.
It should be noted that, by storing the identity information of the database instance in the connector, it is convenient to release the connectors belonging to the database instance in an associated manner when a database instance is deleted. The release method specifically comprises the following steps:
target identity information for the deleted database instance is determined. And traversing the connector pool, and determining each connector with the identity information matched with the target identity information as each connector of the deleted database example. The connectors of the deleted database instance are released.
It should be noted that in the present solution, by including the identity information of the database instance to which the connector belongs, a problem that a mapping relationship between the database instance and the connection pool needs to be additionally established in a conventional technology, and thus the management cost is increased can be avoided.
In summary, according to the access method for the database instance provided in the embodiments of the present specification, when accessing the database instance, the matched connector of the database instance is first searched from the connector pool according to the connection parameter of the database instance. The database instance is then accessed using the free connection in the connector. That is to say, the scheme can use the established idle connection to access the database instance, so that the number of connections can be reduced, and further, the database instance can be accessed under the condition of saving management cost.
The present invention will be further described with reference to specific examples.
FIG. 3 illustrates a flow diagram of a method for accessing an instance of a database, according to another embodiment. As shown in fig. 3, the access method may include at least the following steps.
Step 302, receiving an access request for a target database instance, wherein the access request comprises a target connection parameter connected with the target database instance.
Step 304, searching the target connector matched with the target connection parameter from the connector pool.
Step 306, judging whether the target connector is found, if so, executing step 308; otherwise, go to step 320.
Step 308, determine if there is a free connection in the target connector. If yes, go to step 310; otherwise, go to step 312.
Here, in the case where the target connector is found, the target connector may be moved to the head of the connector queue.
At step 310, the target database instance is accessed using the free connection.
Step 312, determining whether the connection number of the target connector is smaller than a first number threshold, if not, executing step 314, otherwise, jumping to step 316.
Step 314, wait for an idle connection.
Step 316, based on the target connection parameters, establishes a target connection with the target database instance and adds the target connection to the target connector.
At step 318, the target database instance is accessed using the target connection.
At step 320, a new connector is created for the target database instance.
Step 322, determining whether the number of connectors in the connector pool is less than a second number threshold, if so, executing step 324, otherwise, skipping to step 326.
At step 324, the new connector is added to the connector pool.
Specifically, the new connector is added to the head of the connector queue.
At step 326, the connector at the end of the connector queue is deleted and the new connector is added to the head of the connector queue.
Step 328 establishes a target connection with the target database instance based on the target connection parameters and adds the target connection to the new connector.
At step 330, the target database instance is accessed using the target connection.
In summary, in the embodiment of the present specification, several connectors of each database instance may be stored and managed based on a queue, so that management efficiency of the connectors may be greatly improved, and thus access efficiency of the database instances may be improved.
Corresponding to the above method for accessing a database instance, an embodiment of the present specification further provides an apparatus for accessing a database instance, as shown in fig. 4, the apparatus may include:
a receiving unit 402, configured to receive an access request for a target database instance, where the access request includes a target connection parameter connected to the target database instance.
The target connection parameters comprise an IP address, a port, a user account, a user password and a database name of the target database instance.
A searching unit 404, configured to search for a target connector matching the target connection parameter from the connector pool. The connector pool stores a plurality of connectors corresponding to different connection parameters of a plurality of database instances, and each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters.
The management and control system is used for managing a plurality of database instances under the condition that the device is arranged in the management and control system, and the connection is the connection between the management and control system and the database instances;
in the case where the device is installed in a business system, the connection is a connection between the business system and a database instance.
A using unit 406, configured to access the target database instance using the idle connection if there is an idle connection in the target connector.
Optionally, each connector in the connector pool is stored as a connector queue, and the apparatus further includes:
and a moving unit 408 for moving the target connector to the head of the connector queue.
Optionally, the apparatus further comprises:
a judging unit 410, configured to judge whether the number of connections of the target connector is less than a first number threshold in a case where there is no idle connection in the target connector;
a first establishing unit 412, configured to establish a target connection with the target database instance based on the target connection parameter and access the target database instance using the target connection if the number of connections is less than the first number threshold.
Optionally, the apparatus further comprises:
a first adding unit 414, configured to add the target connection to the target connector and add 1 to the number of connections of the target connector.
Optionally, the apparatus further comprises:
a second establishing unit 416, configured to establish, if the target connector is not found, a target connection with the target database instance based on the target connection parameter, and access the target database instance using the target connection.
Optionally, the apparatus further comprises:
a creating unit 418 for creating a new connector corresponding to the target connection parameter for the target database instance and adding the new connector to the connector pool;
a second adding unit 420 for adding the target connection to the new connector.
Wherein each connector in the connector pool is stored as a connector queue;
the second adding unit 420 is specifically configured to:
judging whether the number of connectors in the connector pool is smaller than a second number threshold value or not;
in the event that the number of connectors is less than the second number threshold, adding the new connector to the head of the connector queue;
in the case where the number of connectors is not less than the second number threshold, the connector at the end of the connector queue is deleted, and a new connector is added to the head of the connector queue.
Optionally, each connector further stores identity information of an associated database instance, and the apparatus further includes:
a determining unit 422, further configured to determine target identity information of the deleted database instance;
a traversing unit 424, configured to traverse the connector pool, and determine, as each connector of the deleted database instance, each connector whose identity information matches the target identity information;
a releasing unit 426, configured to release each connector of the deleted database instance.
The functions of the functional modules of the device in the foregoing embodiments of the present specification may be implemented through the steps of the foregoing method embodiments, and therefore, detailed working processes of the device provided in an embodiment of the present specification are not described herein again.
An embodiment of the present disclosure provides an access apparatus for a database instance, which may use an established idle connection to access the database instance, so as to reduce the number of connections and further reduce the management cost of the connections.
According to an embodiment of another aspect, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described in connection with fig. 2 or fig. 3.
According to an embodiment of yet another aspect, there is also provided a computing device comprising a memory and a processor, the memory having stored therein executable code, the processor, when executing the executable code, implementing the method described in connection with fig. 2 or fig. 3.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The steps of a method or algorithm described in connection with the disclosure herein may be embodied in hardware or may be embodied in software instructions executed by a processor. The software instructions may consist of corresponding software modules that may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. Additionally, the ASIC may reside in a server. Of course, the processor and the storage medium may reside as discrete components in a server.
Those skilled in the art will recognize that, in one or more of the examples described above, the functions described in this invention may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
The foregoing description of specific embodiments has been presented for purposes of illustration and description. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The above-mentioned embodiments, objects, technical solutions and advantages of the present specification are further described in detail, it should be understood that the above-mentioned embodiments are only specific embodiments of the present specification and are not intended to limit the scope of the present specification, and any modifications, equivalent substitutions, improvements and the like made on the basis of the technical solutions of the present specification should be included in the scope of the present specification.

Claims (22)

1. A method of accessing a database instance, comprising:
receiving an access request for a target database instance; the access request comprises a target connection parameter connected with the target database instance;
searching a target connector matched with the target connection parameter from a connector pool; the connector pool is stored with a plurality of connectors corresponding to different connection parameters of a plurality of database instances; each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters;
in the event there is a free connection in the target connector, accessing the target database instance using the free connection.
2. The method of claim 1, wherein each connector in the connector pool is stored as a connector queue; the method further comprises the following steps:
moving the target connector to a head of the connector queue.
3. The method of claim 1, further comprising:
under the condition that no idle connection exists in the target connector, judging whether the connection number of the target connector is smaller than a first number threshold value or not;
if the number of connections is less than a first number threshold, establishing a target connection with the target database instance based on the target connection parameters and accessing the target database instance using the target connection.
4. The method of claim 3, further comprising:
adding the target connection to the target connector and adding 1 to the number of connections of the target connector.
5. The method of claim 1, further comprising:
and if the target connector is not found, establishing target connection with the target database instance based on the target connection parameters, and accessing the target database instance by using the target connection.
6. The method of claim 5, further comprising:
creating a new connector corresponding to the target connection parameters for the target database instance and adding the new connector to the connector pool;
adding the target connection to the new connector.
7. The method of claim 6, wherein each connector in the connector pool is stored as a connector queue;
the adding the new connector to the connector pool comprises:
judging whether the number of connectors in the connector pool is smaller than a second number threshold value;
adding the new connector to a head of the connector queue if the number of connectors is less than a second number threshold;
and deleting the connector at the tail of the connector queue and adding the new connector to the head of the connector queue under the condition that the number of the connectors is not less than a second number threshold.
8. The method of claim 1, wherein each connector further stores therein identity information of the belonging database instance; the method further comprises the following steps:
determining target identity information of the deleted database instance;
traversing the connector pool, and determining each connector with identity information matched with the target identity information as each connector of the deleted database example;
releasing the connectors of the deleted database instance.
9. The method of claim 1, wherein the target connection parameters include an IP address, a port, a user account, a user password, and a database name of the target database instance.
10. The method of claim 1, wherein,
the method is performed by a governing system for managing the plurality of database instances; the connection is the connection between the management and control system and a database instance; alternatively, the first and second liquid crystal display panels may be,
the method is executed by a service system, and the connection is the connection between the service system and a database instance.
11. An access device for a database instance, comprising:
a receiving unit, configured to receive an access request for a target database instance; the access request comprises a target connection parameter connected with the target database instance;
the searching unit is used for searching a target connector matched with the target connection parameter from a connector pool; the connector pool is stored with a plurality of connectors corresponding to different connection parameters of a plurality of database instances; each connector stores a plurality of connections established with the database instance based on the corresponding connection parameters;
a using unit, configured to access the target database instance using an idle connection if the idle connection exists in the target connector.
12. The apparatus of claim 11, wherein each connector in the pool of connectors is stored as a connector queue; the device further comprises:
a moving unit for moving the target connector to a head of the connector queue.
13. The apparatus of claim 11, further comprising:
a determination unit configured to determine whether a connection number of the target connector is smaller than a first number threshold in a case where there is no idle connection in the target connector;
a first establishing unit, configured to establish a target connection with the target database instance based on the target connection parameter and access the target database instance using the target connection if the number of connections is less than a first number threshold.
14. The apparatus of claim 13, further comprising:
a first adding unit configured to add the target connection to the target connector and add 1 to the number of connections of the target connector.
15. The apparatus of claim 11, further comprising:
and the second establishing unit is used for establishing target connection with the target database instance based on the target connection parameters if the target connector is not found, and accessing the target database instance by using the target connection.
16. The apparatus of claim 15, further comprising:
a creating unit, configured to create, for the target database instance, a new connector corresponding to the target connection parameter, and add the new connector to the connector pool;
a second adding unit for adding the target connection to the new connector.
17. The apparatus of claim 16, wherein each connector in the pool of connectors is stored as a connector queue;
the second adding unit is specifically configured to:
judging whether the number of connectors in the connector pool is smaller than a second number threshold value;
adding the new connector to a head of the connector queue if the number of connectors is less than a second number threshold;
and in the case that the number of the connectors is not less than a second number threshold, deleting the connector at the tail of the connector queue, and adding the new connector to the head of the connector queue.
18. The apparatus of claim 11, wherein each connector further stores therein identity information of the database instance; the device further comprises:
the determining unit is further used for determining the target identity information of the deleted database instance;
a traversing unit, configured to traverse the connector pool, determine, from the connector pool, each connector whose identity information matches the target identity information, and use the determined connector as each connector of the deleted database instance;
and the releasing unit is used for releasing each connector of the deleted database instance.
19. The apparatus of claim 11, wherein the target connection parameters comprise an IP address, a port, a user account, a user password, and a database name of the target database instance.
20. The apparatus of claim 11, wherein,
the device is arranged in a management and control system, and the management and control system is used for managing the database instances; the connection is the connection between the management and control system and a database instance; alternatively, the first and second electrodes may be,
the device is arranged in a service system, and the connection is the connection between the service system and a database instance.
21. A computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed in a computer, causes the computer to carry out the method of any one of claims 1-10.
22. A computing device comprising a memory and a processor, wherein the memory has stored therein executable code that when executed by the processor implements the method of any of claims 1-10.
CN202211178045.9A 2022-09-27 2022-09-27 Database instance access method and device Active CN115309726B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211178045.9A CN115309726B (en) 2022-09-27 2022-09-27 Database instance access method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211178045.9A CN115309726B (en) 2022-09-27 2022-09-27 Database instance access method and device

Publications (2)

Publication Number Publication Date
CN115309726A true CN115309726A (en) 2022-11-08
CN115309726B CN115309726B (en) 2023-01-13

Family

ID=83865830

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211178045.9A Active CN115309726B (en) 2022-09-27 2022-09-27 Database instance access method and device

Country Status (1)

Country Link
CN (1) CN115309726B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
CN105956138A (en) * 2016-05-11 2016-09-21 北京百度网讯科技有限公司 Database connection control method and apparatus
US20170063936A1 (en) * 2015-08-27 2017-03-02 Datometry, Inc. Method and System for Workload Management for Data Management Systems
CN112866348A (en) * 2020-12-31 2021-05-28 金蝶软件(中国)有限公司 Database access method and device, computer equipment and storage medium
CN113568892A (en) * 2021-08-12 2021-10-29 威讯柏睿数据科技(北京)有限公司 Method and equipment for carrying out data query on data source based on memory calculation
CN114969189A (en) * 2022-06-07 2022-08-30 中国银行股份有限公司 Method and device for determining connection in database connection pool

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
US20170063936A1 (en) * 2015-08-27 2017-03-02 Datometry, Inc. Method and System for Workload Management for Data Management Systems
CN105956138A (en) * 2016-05-11 2016-09-21 北京百度网讯科技有限公司 Database connection control method and apparatus
CN112866348A (en) * 2020-12-31 2021-05-28 金蝶软件(中国)有限公司 Database access method and device, computer equipment and storage medium
CN113568892A (en) * 2021-08-12 2021-10-29 威讯柏睿数据科技(北京)有限公司 Method and equipment for carrying out data query on data source based on memory calculation
CN114969189A (en) * 2022-06-07 2022-08-30 中国银行股份有限公司 Method and device for determining connection in database connection pool

Also Published As

Publication number Publication date
CN115309726B (en) 2023-01-13

Similar Documents

Publication Publication Date Title
CN106294190B (en) Storage space management method and device
US10296462B2 (en) Method to accelerate queries using dynamically generated alternate data formats in flash cache
US9116910B2 (en) Data de-duplication in a distributed network
CN109766318B (en) File reading method and device
US9047019B2 (en) Shared temporary storage management in a shared disk database cluster
US11182378B2 (en) System and method for committing and rolling back database requests
WO2024021453A1 (en) Object computing and storage system, data processing method, and client and storage medium
US8250176B2 (en) File sharing method and file sharing system
CN111737564A (en) Information query method, device, equipment and medium
CN109302448A (en) A kind of data processing method and device
US8549274B2 (en) Distributive cache accessing device and method for accelerating to boot remote diskless computers
CN110706148A (en) Face image processing method, device, equipment and storage medium
CN109165078B (en) Virtual distributed server and access method thereof
CN113901279A (en) Graph database retrieval method and device
CN115309726B (en) Database instance access method and device
US11853229B2 (en) Method and apparatus for updating cached information, device, and medium
CN101459599B (en) Method and system for implementing concurrent execution of cache data access and loading
CN111242621B (en) Transaction data storage method, device, equipment and storage medium
CN115292373B (en) Method and device for segmenting data block
CN116069810A (en) Data query method and device and terminal equipment
CN113656178B (en) Data processing method, device, equipment and readable storage medium
US9652393B1 (en) Managing shared memory in database server
CN109213760A (en) The storage of high load business and search method of non-relation data storage
CN111240810B (en) Transaction management method, device, equipment and storage medium
CN110389966B (en) Information processing method and device

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
GR01 Patent grant
GR01 Patent grant