Method and device for determining timestamp mode of database management system

By dynamically adjusting the timestamp mode of the database management system, the problem of inapplicability of the timestamp mode after the application environment changes is solved, and the system performance and transaction implementation reliability are improved.

CN114328546BActive Publication Date: 2025-05-06HUAWEI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011062482.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-30
Publication Date
2025-05-06
Estimated Expiration
2040-09-30

AI Technical Summary

Technical Problem

After the application environment of the database management system changes, the timestamp pattern applied may no longer be applicable, resulting in system performance degradation and transaction implementation efficiency.

Method used

Provides a time stamp mode determination method for database management system, which determines the timestamp mode suitable for the current application environment by obtaining setting commands, and dynamically adjusts the target timestamp mode to match the changing application environment.

Benefits of technology

Ensure that the database management system always applies timestamp patterns that match the current application environment, reduce inappropriate timestamp patterns, and improve system performance and transaction implementation reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328546B_ABST
    Figure CN114328546B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for determining a timestamp mode of a database management system. In the method, a first setting command is first obtained, the first setting command includes timestamp information indicating a first timestamp mode, and the first timestamp mode matches the current application environment of the database management system; then, the first timestamp mode is set as the target timestamp mode applied by the database management system. Through the scheme provided by the embodiment of the present application, the database can support multiple forms of timestamp modes, and the target timestamp mode applied by the database management system matches the current application environment of the database management system, that is, the timestamp mode applied by the database management system is applicable to the database management system, thereby reducing the phenomenon that the database management system applies an inapplicable timestamp mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a method and device for determining a timestamp mode of a database management system. Background Art

[0002] A database is usually an organized and uniformly managed collection of large amounts of data, and it usually needs to have four properties: atomicity, consistency, isolation, and durability, which can be referred to as ACID properties. A database management system (DBMS) is a software that manages a database.

[0003] In order to ensure the ACID characteristics of the database, the database management system usually configures a log for the database, which is used to record the changes made by the transaction to the data in the database, and the database management system will assign corresponding timestamps to the transactions according to the timestamp mode of its own application. In this case, the data snapshot of the database at each timestamp can be determined by combining the timestamp of each transaction and the log, which facilitates data recovery and data rollback, etc., to ensure the ACID characteristics of the database.

[0004] Among them, the timestamp mode usually includes the logical timestamp mode, the physical timestamp mode and the hybrid timestamp mode, and the database usually applies one of the timestamp modes. For example, the database management system of the database operated by Oracle (i.e., Oracle database) usually applies the logical timestamp mode, the database management system of the database developed by Google (i.e., spanner database) usually applies the physical timestamp mode, and the database management system of the cockroach database (i.e., cockroach DB) usually applies the hybrid timestamp mode.

[0005] However, the application environment of the database management system may change, resulting in that the timestamp mode applied by the database management system is sometimes not applicable to the database. For example, if a database management system applies a logical timestamp mode, and the data in the database is stored in multiple nodes, the database management system will be configured with a corresponding counter, through which a logical timestamp is assigned to each node. However, as the database expands, the number of nodes gradually increases, and when the counter assigns a logical timestamp to a node, a delay often occurs, resulting in that the database management system is no longer applicable to the logical timestamp mode. Summary of the invention

[0006] In order to solve the problem in the prior art that a database management system applies an inappropriate timestamp mode, an embodiment of the present application provides a method and device for determining a timestamp mode of a database management system.

[0007] In a first aspect, an embodiment of the present application discloses a method for determining a timestamp mode of a database management system, comprising:

[0008] Obtaining a first setting command, the first setting command including timestamp information indicating a first timestamp mode, the first timestamp mode matching a current application environment of a database management system;

[0009] The first timestamp mode is set as the target timestamp mode applied by the database management system.

[0010] Through the solution provided in the embodiment of the present application, the database management system can apply a timestamp mode that matches the application environment, thereby reducing the phenomenon of the database management system applying an inappropriate timestamp mode.

[0011] In an optional design, the first setting command is a first structured query SQL statement, and the first SQL statement includes attribute information of the database;

[0012] The method further comprises:

[0013] The database is created according to the attribute information.

[0014] Through the above embodiment, the timestamp mode applicable to the database management system can be determined according to the first SQL statement, and a corresponding database can also be created.

[0015] An optional design also includes:

[0016] receiving a second SQL statement for creating a table object, wherein the second SQL statement corresponds to a create table object transaction;

[0017] Determining a first start timestamp of the create table object transaction according to the first timestamp mode;

[0018] The table object is created by executing the create table object transaction;

[0019] A first end timestamp of the create table object transaction is determined according to the first timestamp mode.

[0020] Through the above embodiment, after determining that the first timestamp mode is the target timestamp mode, in the process of creating a table object of the database, a corresponding timestamp can be assigned to the corresponding create table object transaction. Since the first timestamp mode matches the application environment of the database management system, through this embodiment, a suitable timestamp can be assigned to the create table object transaction, thereby ensuring the implementation of the create table object transaction.

[0021] An optional design also includes:

[0022] After the application environment of the database management system changes, obtaining a second setting command, the second setting command including timestamp information indicating a second timestamp mode, the second timestamp mode matching the changed application environment;

[0023] The target timestamp mode is adjusted from the first timestamp mode to the second timestamp mode.

[0024] Through the solution of the above embodiment, even if the application environment of the database management system changes, the solution can also adjust the target timestamp mode applied by the database management system so that the database management system applies a suitable timestamp mode.

[0025] In an optional design, adjusting the target timestamp mode from the first timestamp mode to the second timestamp mode includes:

[0026] storing the second timestamp pattern;

[0027] Restarting the database management system;

[0028] After the database management system is restarted, the stored second timestamp mode is set as the target timestamp mode.

[0029] An optional design also includes:

[0030] Before the restarting of the database management system, it is determined that the first timestamp mode is different from the second timestamp mode.

[0031] If it is determined that the first timestamp mode is the same as the second timestamp mode, the first timestamp mode can continue to be applied without restarting the database management system, thereby reducing the number of restarts of the database management system and ensuring smooth operation of the database management system.

[0032] An optional design also includes:

[0033] After setting the second timestamp mode as the target timestamp mode, receiving a third SQL statement;

[0034] Determine, according to the second timestamp mode, a second start timestamp of the transaction corresponding to the third SQL statement;

[0035] According to the second timestamp mode, a second end timestamp of the operation transaction is determined.

[0036] Through the above embodiment, after adjusting the target timestamp mode of the database management system to the second timestamp mode, corresponding timestamps can be allocated to the operation transactions of the database management system according to the second timestamp mode. Since the second timestamp mode matches the changed application environment of the database management system, through this embodiment, appropriate timestamps can be allocated to the operation transactions of the database management system, thereby ensuring the implementation of the operation transactions of the database management system.

[0037] An optional design also includes:

[0038] A first maximum timestamp allocated by the first timestamp mode is stored.

[0039] In an optional design, the first timestamp mode is a logical timestamp mode, and the method further includes:

[0040] again setting the target timestamp mode applied by the database management system to the first timestamp mode;

[0041] Based on the first maximum timestamp, a logical timestamp is assigned to the transaction of the database management system.

[0042] In an optional design, the first timestamp mode is a physical timestamp mode, and the method further includes:

[0043] again setting the target timestamp mode applied by the database management system to the first timestamp mode;

[0044] determining a target time for setting the target timestamp mode to the first timestamp mode again;

[0045] If the time indicated by the first maximum timestamp is earlier than the target time, a physical timestamp is allocated to the transaction of the database management system using the first timestamp mode.

[0046] In the above embodiment, when it is determined that the first maximum timestamp is earlier than the target time, a physical timestamp is allocated to the transaction of the database management system through the physical timestamp mode, thereby improving the accuracy of the timestamp.

[0047] An optional design also includes:

[0048] If the time indicated by the first maximum timestamp is not earlier than the target time, acquiring a third setting command, the third setting command including timestamp information indicating a third timestamp mode, the third timestamp mode being different from the first timestamp mode;

[0049] Setting the third timestamp mode as the target timestamp mode applied by the database management system;

[0050] or,

[0051] Pauses the allocation of timestamps and generates a prompt message.

[0052] In the above embodiment, after the database is switched to the physical timestamp mode and it is determined that the time device configured by the database management system for determining the physical time is inaccurate, the physical timestamp mode applied by the database management system can be switched to other timestamp modes, or the allocation of timestamps can be suspended to avoid the database management system applying an inaccurate physical timestamp mode.

[0053] In an optional design, obtaining the second setting command includes:

[0054] receiving a second setting command sent from the client;

[0055] or,

[0056] Determine the application environment of the database management system after the change; determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode, and the application environment of the database management system after the change; and generate the second setting command according to the determined second timestamp mode.

[0057] Through the above embodiments, the database management system can generate a corresponding second setting command for the database according to the change of the application environment, thereby ensuring that the database management system applies a timestamp mode that matches the changed application environment.

[0058] In a second aspect, an embodiment of the present application discloses a database management system, characterized in that it includes:

[0059] A first acquisition module, configured to acquire a first setting command, wherein the first setting command includes timestamp information indicating a first timestamp mode, and the first timestamp mode matches a current application environment of the database management system;

[0060] A first setting module is used to set the first timestamp mode as the target timestamp mode applied by the database management system

[0061] In an optional design, the first setting command is a first structured query SQL statement, and the first SQL statement includes attribute information of the database;

[0062] The database management system also includes:

[0063] The first creation module is used to create the database according to the attribute information.

[0064] An optional design also includes:

[0065] A first receiving module, configured to receive a second SQL statement for creating a table object, wherein the second SQL statement corresponds to a create table object transaction;

[0066] A second determining module, configured to determine a first start timestamp of the create table object transaction according to the first timestamp mode;

[0067] A second creation module, configured to create the table object by executing the create table object transaction;

[0068] The second determining module is further configured to determine a first end timestamp of the create table object transaction according to the first timestamp mode.

[0069] In an optional design, the first acquisition module is further used to, after the application environment of the database management system changes, acquire a second setting command, the second setting command including timestamp information indicating a second timestamp mode, the second timestamp mode matching the changed application environment;

[0070] The first setting module is further used to adjust the target timestamp mode from the first timestamp mode to the second timestamp mode.

[0071] In an optional design, the first setting module is specifically used to store the second timestamp mode, restart the database management system, and after completing the restart of the database management system, set the stored second timestamp mode as the target timestamp mode.

[0072] In an optional design, the first setting module is further used to determine, before restarting the database management system, that the first timestamp mode is different from the second timestamp mode.

[0073] An optional design also includes:

[0074] A second receiving module, configured to receive a third SQL statement after setting the second timestamp mode to the target timestamp mode;

[0075] A third determining module, configured to determine a second start timestamp of the operation transaction corresponding to the third SQL statement according to the second timestamp mode;

[0076] The third determination module is used to determine a second end timestamp of the operation transaction according to the second timestamp mode.

[0077] An optional design also includes:

[0078] A storage module is used to store the first maximum timestamp allocated by the first timestamp mode.

[0079] In an optional design, the first timestamp mode is a logical timestamp mode, and the first setting module is also used to set the target timestamp mode applied by the database management system to the first timestamp mode again, and assign logical timestamps to the transactions of the database management system based on the first maximum timestamp.

[0080] In an optional design, the first timestamp mode is a physical timestamp mode, and the first setting module is further used to set the target timestamp mode applied by the database management system to the first timestamp mode again; determine the target time for setting the target timestamp mode to the first timestamp mode again; if the time indicated by the first maximum timestamp is earlier than the target time, assign a physical timestamp to the transaction of the database management system through the first timestamp mode.

[0081] In an optional design, the first acquisition module is further used to, if the time indicated by the first maximum timestamp is not earlier than the target time, acquire a third setting command, the third setting command including timestamp information indicating a third timestamp mode, the third timestamp mode being different from the first timestamp mode;

[0082] The first setting module is further used to set the third timestamp mode as the target timestamp mode applied by the database management system;

[0083] or,

[0084] The first setting module is also used to suspend allocating timestamps and generate prompt information.

[0085] In an optional design, the first acquisition module is specifically used to receive a second setting command sent from the client;

[0086] or,

[0087] The first acquisition module is specifically used to determine the application environment of the database management system after the change; determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode, and the application environment of the database management system after the change; and generate the second setting command according to the determined second timestamp mode.

[0088] In a third aspect, an embodiment of the present application discloses a database server, including:

[0089] at least one processor, a non-transitory computer readable medium storing executable code, and a database management system according to the second aspect;

[0090] Wherein, when the executable code is executed by the at least one processor, it is configured to implement the function of the database management system.

[0091] In a fourth aspect, an embodiment of the present application discloses a cluster database system, including:

[0092] A hardware layer, a virtual machine monitor VMM running on the hardware layer, and at least one virtual machine;

[0093] The at least one virtual machine implements the method described in the first aspect by running an executable program based on the VMM and the hardware resources provided by the hardware layer.

[0094] In a fifth aspect, an embodiment of the present application discloses a database system, including:

[0095] A database server, and a client device connected to the database server via a communication network;

[0096] A client operating system is running on the client device, and an application of the client device is running on the client operating system;

[0097] The database server runs an operating system of the database server, and the database server also includes the database management system as described in the second aspect.

[0098] In a sixth aspect, an embodiment of the present application provides a readable storage medium, which is used to store instructions. When the instructions are executed, the method described in the first aspect is implemented.

[0099] In a seventh aspect, an embodiment of the present application provides a computer program product comprising instructions, and when the computer program product is run on an electronic device, the electronic device can implement all or part of the steps in the embodiment corresponding to the first aspect.

[0100] Through the solution provided in the embodiment of the present application, it is possible to obtain a first setting command, and determine the target timestamp mode applied by the database management system according to the instruction of the first setting command, wherein the target timestamp mode is the first timestamp mode indicated by the first setting command, and the first timestamp mode matches the current application environment of the database management system.

[0101] In the prior art, a database management system usually applies a timestamp mode, and even if the application environment of the database management system changes, the timestamp mode applied by the database management system usually does not change. In this case, as the application environment of the database management system changes, the timestamp mode applied by the database management system often becomes inapplicable.

[0102] However, through the solution provided in the embodiment of the present application, the database management system can set the timestamp mode applied by the database management system according to the first setting command. In this case, the timestamp mode applied by the database management system is no longer fixed, but can support multiple forms of timestamp modes, and the target timestamp mode applied by the database management system matches the current application environment of the database management system, that is, the first timestamp mode is applicable to the database, thereby reducing the phenomenon of the database management system applying an inapplicable timestamp mode.

[0103] Furthermore, in the solution provided in the embodiment of the present application, if the application environment of the database management system changes, the target timestamp mode of the database can be adjusted from the first timestamp mode to the second timestamp mode through a second setting command, wherein the second timestamp mode matches the changed application environment. Therefore, after the application environment of the database management system changes, through the solution provided in the embodiment of the present application, the target timestamp mode applied by the database management system can be adjusted so that the database management system applies a suitable timestamp mode. BRIEF DESCRIPTION OF THE DRAWINGS

[0104] Figure 1A It is a structural diagram of a stand-alone database system;

[0105] Figure 1B A schematic diagram of the structure of a cluster database system using a shared disk architecture;

[0106] Figure 1C It is a schematic diagram of the structure of a cluster database system using a shared-nothing architecture;

[0107] Figure 2 It is a structural diagram of a database server;

[0108] Figure 3A schematic diagram of the workflow of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0109] Figure 4 Another schematic diagram of the working process of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0110] Figure 5 Another schematic diagram of the working process of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0111] Figure 6 Another schematic diagram of the working process of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0112] Figure 7 Another schematic diagram of the working process of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0113] Figure 8 Another schematic diagram of the working process of a method for determining a timestamp mode of a database management system disclosed in an embodiment of the present application;

[0114] Fig. 9 A schematic diagram of the structure of a database management system disclosed in an embodiment of the present application;

[0115] Fig.10 A schematic diagram of the structure of a cluster database system disclosed in an embodiment of the present application;

[0116] Fig.11 A schematic diagram of the structure of a database system disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0117] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0118] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0119] In the following, the terms "first" and "second" are used for description purposes only. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0120] The method, database management system and database server provided in the embodiments of the present application can be applied to a stand-alone database system or a cluster database system. A database system is a relatively ideal data processing system developed to meet the needs of data processing. A database system generally consists of the following three parts: (1) Database (DB), which refers to a collection of organized and shareable data stored in a computer for a long time. The data in the database is organized, described and stored according to a certain mathematical model, has low redundancy, high data independence and easy scalability, and can be shared by various users. (2) Hardware, including data storage devices required to store data, such as memory and / or disk. (3) Software, including a database management system (DBMS). DBMS is the core software of the database system. It is a system software used to scientifically organize and store data, and efficiently acquire and maintain data. The database engine is the core content of the DBMS.

[0121] Specifically, Figures 1A-1C As shown, Figure 1A The diagram of a stand-alone database system includes a database management system and a data store. The database management system is used to provide services such as querying and modifying the database, and the database management system stores data in the data store. In a stand-alone database system, the database management system and the data store are usually located on a single server, such as a symmetric multi-processor (SMP) server. The SMP server includes multiple processors, and all processors share resources such as buses, memory, and I / O systems. The functions of the database management system can be implemented by one or more processors executing programs in memory.

[0122] Figure 1B This is a schematic diagram of a cluster database system using a shared-storage architecture, including multiple nodes (such as Figure 1BIn the embodiment of the present invention, there are nodes 1-N in the cluster database system, each of which is deployed with a database management system to provide users with services such as query and modification of the database. Multiple database management systems store shared data in a shared data storage device, and perform read and write operations on the data in the data storage device through a switch. The shared data storage device can be a shared disk array. The nodes in the cluster database system can be physical machines, such as database servers, or virtual machines running on abstract hardware resources. If the node is a physical machine, the switch is a storage area network (SAN) switch, an Ethernet switch, a fiber switch or other physical switching devices. If the node is a virtual machine, the switch is a virtual switch.

[0123] Figure 1C This is a diagram of a cluster database system that uses a shared-nothing architecture. Each node has its own exclusive hardware resources (such as data storage), operating system, and database, and the nodes communicate through the network. In this system, data will be distributed to each node according to the database model and application characteristics. The query task will be divided into several parts and executed in parallel on all nodes. The nodes will coordinate calculations with each other to provide database services as a whole. All communication functions are implemented on a high-bandwidth network interconnection system. Figure 1B Like the cluster database system with a shared-nothing architecture described above, the nodes here can be either physical machines or virtual machines.

[0124] In all embodiments of the present application, the data storage of the database system includes but is not limited to a solid state disk (SSD), a disk array, or other types of non-transitory computer-readable media. Figures 1A-1C Although the database is not shown in the figure, it should be understood that the database is stored in the data storage. A person skilled in the art can understand that a database system may include Figures 1A-1C Fewer or more components than those shown in the figure, or including Figures 1A-1C The components shown in the figure are different components. Figures 1A-1C Only components more relevant to the implementation disclosed in the embodiments of the present application are shown. Figure 1B and 1C Four nodes have been described in the above description, but those skilled in the art can understand that a cluster database system can include any number of nodes. The database management system functions of each node can be implemented by a suitable combination of software, hardware and / or firmware running on each node.

[0125] For ease of understanding and description, as an example rather than a limitation, the following uses a node in a shared-nothing architecture cluster database system, namely a database server, as an example to illustrate the solution of the embodiment of the present application. However, those skilled in the art can clearly understand from the teachings of the embodiment of the present application that the method of the embodiment of the present application can also be applied to a cluster database system of a shared-storage architecture, a stand-alone database system, and any type of relational database system.

[0126] like Figure 2 As shown, an embodiment of the present application provides a database server 100, including: at least one processor 104, a non-transitory computer-readable medium (non-transitory computer-readable medium) 106 storing executable code, and a database management system 108. The executable code is configured to implement the components and functions of the database management system 108 when executed by at least one processor 104. The non-transitory computer-readable medium 106 may include one or more non-volatile memories, as an example, the non-volatile memory includes a semiconductor memory device, such as an erasable programmable read only memory (EPROM), an electrically erasable programmable read only memory (EEPROM) and a flash memory; a disk, such as an internal hard disk or a removable disk, a magneto-optical disk, and a compact disc read-only memory (CD-ROM) and a digital video disc read only memory (DVD-ROM).

[0127] In addition, the non-transitory computer-readable medium 106 may also include any device configured as a main memory. The at least one processor 104 may include any type of general computing circuit or dedicated logic circuit, such as a field programmable gate array (FPGA) or an application specific integrated circuit (ASIC). The at least one processor 104 may also be one or more processors coupled to one or more semiconductor substrates, such as a central processing unit (CPU).

[0128] The database management system 108 may be a relational database management system (RDBMS). The database management system 108 supports structured query language (SQL). Generally, SQL refers to a special programming language specifically used to manage data stored in a relational database. SQL may refer to various types of data-related languages, including, for example, data definition languages ​​and data manipulation languages, wherein the scope of SQL may include data insertion, query, update and deletion, schema creation and modification, and data access control. In addition, in some examples, SQL may include descriptions associated with various language elements, including clauses, expressions, predicates, queries, and statements. For example, clauses may refer to various components of statements and queries, and in some cases, clauses may be considered optional. In addition, expressions may be configured to generate scalar values ​​and / or tables including data columns and / or rows. In addition, predicates may be configured to specify conditions for adjusting the effects of statements and queries.

[0129] A query is a request to view, access and / or manipulate data stored in a database. The database management system 108 can receive a query in SQL format (referred to as an SQL query) from the database client 102. Generally, the database management system 108 generates a query result corresponding to the query by accessing relevant data from the database and manipulating the relevant data, and returns the query result to the database client 102. A database is a collection of data organized, described and stored according to a certain mathematical model. A database may include one or more database structures or formats, such as row storage and column storage. A database is usually stored in a data storage device, such as Figure 2The external data storage 120 in the non-transitory computer readable medium 106. When the database is stored in the non-transitory computer readable medium 106, the database management system 108 is an in-memory database management system.

[0130] Database client 102 may include any type of device or application configured to interact with database management system 108. In some examples, database client 102 includes one or more application servers.

[0131] The database management system 108 includes an SQL engine 110, an execution engine 122, and a storage engine 134. The SQL engine 110 generates a corresponding execution plan based on the SQL statement submitted by the client 102, such as a query, and the execution engine 122 operates according to the execution plan of the statement to generate the query result. The storage engine 134 is responsible for managing the data of the table and the actual content of the index on the file system, and also manages the cache, buffer, transaction, log and other data during the runtime. For example, the storage engine 134 can write the execution result of the execution engine 122 to the data storage 120 through physical I / O. The SQL engine 110 includes a parser 112 and an optimizer 114, wherein the parser 110 is used to perform grammatical and semantic analysis of the SQL statement, expand the view in the query, and divide it into small query blocks. The optimizer 114 generates a set of execution plans that may be used for the statement, estimates the cost of each execution plan, compares the cost of the plan, and finally selects an execution plan with the lowest cost.

[0132] In the application process, the database usually needs to have four characteristics: atomicity, consistency, isolation, and durability, which can be referred to as ACID characteristics. In addition, a transaction refers to the basic execution unit for operating on the database. A transaction may contain one or more SQL statements.

[0133] The atomicity in the ACID property of a database means that all operations in a transaction are either completed or not completed, and will not end at a certain stage in the middle. If an error occurs during the execution of a transaction, it will be restored to the state before the transaction started, as if the transaction had never been executed, that is, the transaction is indivisible and irreducible.

[0134] The consistency in the ACID feature means that the integrity of the database is not destroyed before the transaction starts and after the transaction ends.

[0135] Isolation in the ACID feature means that the database allows multiple concurrent transactions to read, write and modify data in the database at the same time. Isolation can prevent data inconsistency caused by cross-execution when multiple transactions are executed concurrently. In addition, isolation types can be divided into different levels, including: read uncommitted, read committed, repeatable read and serializable.

[0136] The persistence in the ACID property means that after a transaction is executed, the changes made to the data in the database by the transaction are permanent and will not be lost even if the system fails.

[0137] In order to ensure the ACID characteristics of the database, the database management system usually configures a log for the database, which is used to record the modifications made by the transaction to the data in the database, and the database management system will assign corresponding timestamps to each transaction in the database according to the timestamp mode of its own application, so as to record the data snapshots at each timestamp in the log. Combining the timestamps of each transaction and the log, the data snapshots at each timestamp can be determined, which is convenient for data recovery and data rollback, thereby ensuring the ACID characteristics of the database.

[0138] Among them, the timestamp mode applied by the database management system refers to the timestamp mode adopted by the database management system when assigning timestamps to transactions corresponding to the database. The timestamp modes applied by the database management system usually include three types: logical timestamp mode, physical timestamp mode and hybrid logical timestamp mode. Correspondingly, the timestamp determined by the logical timestamp mode is the logical timestamp, which can also be called a logical clock. The logical timestamp represents the sequence of events according to the count of the counter. Through this counter, it can be ensured that the logical timestamp of the entire database is monotonically increasing and is not easily affected by the physical time jump of the system. Therefore, for a database management system using the logical timestamp mode, the database management system usually sets a counter for the database.

[0139] As the amount of data that needs to be stored in the database increases, many databases are currently distributed databases, which often contain multiple nodes for storing data, that is, the data in the distributed database is stored in multiple nodes. In a feasible design, the database management system is usually configured with a counter function for one of the nodes of the distributed database, which node can be called a central node, and logical timestamps are allocated to other nodes through the central node, that is, the central node can be used to allocate a counter for logical timestamps.

[0140] The timestamp determined by the physical timestamp mode is the physical timestamp, which can also be called the physical clock. Among them, physical time refers to the time of the real physical world. If the timestamp mode adopted by the database management system is the physical timestamp mode, the database management system needs to be configured with a time device that can determine the physical time, such as the global positioning system (GPS) and the atomic clock, so as to determine the physical time through the GPS and the atomic clock, and further determine the physical timestamp of each transaction.

[0141] Therefore, for a database management system that uses a physical timestamp, it is necessary to configure a time device for determining the physical time for the database, and the accuracy of the time device often affects the accuracy of the acquired physical timestamp.

[0142] In addition, the timestamp determined by the hybrid timestamp mode is a hybrid timestamp. The hybrid timestamp can also be called a hybrid clock. The hybrid timestamp is composed of a physical timestamp and a logical timestamp.

[0143] Currently, a database management system usually only uses one of the timestamp modes. For example, the database management system of the database operated by Oracle (i.e., Oracle database) uses logical timestamps, the database management system of the database developed by Google (i.e., Spanner database) uses physical timestamps, and the database management system of the Cockroach database (i.e., Cockroach DB) uses hybrid timestamps.

[0144] According to the above introduction to various types of timestamp modes, different timestamp modes are applicable to different application environments. However, during the use of the database, the application environment of the database management system will change, resulting in the timestamp mode used by the database management system sometimes being unable to adapt to the changed application environment of the database management system, resulting in the phenomenon that the database management system applies an inappropriate timestamp mode.

[0145] Among them, for a database management system that uses a logical timestamp mode, as the database is used, the amount of data in the database tends to increase, and as the database is expanded, the number of nodes that need to be assigned logical timestamps increases, which will cause a delay in the central node when assigning logical timestamps to the nodes of the database. The central node with a counting function becomes a performance bottleneck that affects the database management system, reduces the efficiency of transaction implementation, and sometimes even provides erroneous logical timestamps, causing the database management system to no longer be applicable to the logical timestamp mode.

[0146] In addition, for databases using the physical timestamp mode, the database management system needs to be configured with a time device that determines the physical time. The accuracy of the time device will be affected by the jump of the system time, and the physical time determined by the time device has a certain error. If the time difference between two transactions is within the error range, in order to determine the order of the two transactions, it is often necessary to assign a physical timestamp to one of the transactions, and then assign a corresponding physical timestamp to the other transaction after waiting for a period of time. As a result, there is a delay when assigning physical timestamps to the two transactions, which further reduces the efficiency of transaction implementation, that is, the database management system is no longer applicable to the physical timestamp mode.

[0147] For example, if the error range of the time device of a database management system using the physical timestamp mode is set to 6 microseconds, and the time interval between transaction 1 and transaction 2 is between 6 microseconds, in order to distinguish the order of transaction 1 and transaction 2, a physical timestamp can be assigned to transaction 1 first, and then after waiting for 6 microseconds or longer, a corresponding physical timestamp can be assigned to transaction 2 to distinguish the order of transaction 1 and transaction 2 in implementation. Therefore, it takes a while to assign the corresponding physical timestamp to the transactions within the error range, resulting in reduced efficiency in transaction implementation.

[0148] The hybrid timestamp mode combines physical timestamps and logical timestamps. Compared with the physical timestamp mode, the hybrid timestamp mode can tolerate larger errors in physical time. However, if the error of the time device used by the database management system to determine the physical time is large, it will still affect the determination of the hybrid timestamp, resulting in the database management system no longer being applicable to the hybrid timestamp.

[0149] According to the above introduction, as the application environment of the database management system changes, the timestamp mode used by the database management system sometimes cannot adapt to the changed application environment of the database management system, resulting in the database management system applying an inappropriate timestamp mode. In addition, if the developer of the database management system sets an inappropriate timestamp mode for the database management system, it will also cause the database management system to apply an inappropriate timestamp mode.

[0150] Furthermore, if the database management system applies an inappropriate timestamp mode, it will often lead to failure to assign correct timestamps to database transactions, thereby affecting the implementation of transactions and reducing the reliability of transaction implementation.

[0151] Based on the database management system 108 described above, Figure 3 As shown, an embodiment of the present application provides a method for determining a timestamp mode of a database management system, comprising:

[0152] Step S11: Obtain a first setting command.

[0153] The first setting command includes timestamp information indicating a first timestamp mode, and the first timestamp mode matches the current application environment of the database management system.

[0154] In the embodiment of the present application, the first timestamp mode matches the current application environment of the database management system, which means that in the current application environment, the database management system applies the first timestamp mode.

[0155] Among them, the application environment can be reflected by the accuracy of the time device of the database management system to obtain the physical time, and / or the performance of the counter configured by the database management system. In different application environments, the timestamp mode applicable to the database management system is often different. In order to clarify the timestamp mode applicable to the database management system in different application environments, this application provides Table 1:

[0156] Table 1

[0157]

[0158] Referring to Table 1, the logical timestamp mode requires that the counter configured by the database management system has high performance. Even if the database is expanded, the counter will not have a large delay when allocating logical timestamps to each node in the database. In this case, if the performance of the counter is high in the current application environment and can meet the condition of small delay when allocating logical timestamps to each node in the database, it indicates that the logical timestamp mode matches the database management system in the current application environment, and accordingly, the first timestamp mode is the logical timestamp mode. If the performance of the node with the counter function is not high, a large delay will occur when allocating logical timestamps to each node in the database, which indicates that the logical timestamp mode does not match the database management system in the current application environment.

[0159] In addition, the physical timestamp mode requires that the time device of the database management system for determining the physical time has a high accuracy to ensure the accuracy of determining the physical time. Therefore, if the current application environment indicates that the time device has a high accuracy, it can be determined that the physical timestamp mode matches the database management system in the current application environment, and accordingly, the first timestamp mode is the physical timestamp mode. If the accuracy of the time device is low, the physical timestamp mode does not match the database management system in the current application environment.

[0160] Compared with the logical timestamp mode, the hybrid timestamp mode has slightly lower performance requirements for nodes with counter functions, and compared with the physical timestamp mode, the hybrid timestamp mode has slightly lower accuracy requirements for the time device. In this case, if the performance of the counter is medium and the accuracy of the time device is medium, it indicates that the hybrid timestamp mode matches the database management system in the current application environment, and accordingly, the first timestamp mode is the hybrid timestamp mode.

[0161] In the embodiment of the present application, the first setting command can be obtained in a variety of ways. In a feasible implementation, the database management system of the database can determine the timestamp mode applicable to the database management system in the current application environment according to the current application environment, and the timestamp mode is the first timestamp mode, and the first setting command is determined accordingly. Alternatively, the database management system of the database can also receive an SQL statement for indicating the first timestamp mode, and use the SQL statement as the first setting command.

[0162] If the first setting command is an SQL statement, the SQL statement may be of various types. For example, the SQL statement may be an SQL statement for creating a database, or may be an SQL statement for creating a table object in a database, adding, modifying, deleting, or querying the database, etc., which is not limited in the embodiments of the present application.

[0163] In addition, the first setting command includes relevant information of the first timestamp mode, and the relevant information may be a field corresponding to the first timestamp mode. In this case, a correspondence between different timestamp modes and fields may be set. After acquiring the first setting command, the first timestamp mode indicated by the first setting command may be determined according to the correspondence and the fields loaded in the first setting command.

[0164] Exemplarily, the field corresponding to the logical timestamp mode can be set to "LOGIC", the field corresponding to the physical timestamp mode can be set to "PHYSICAL", and the field corresponding to the hybrid logical timestamp mode can be set to "HLC". In this case, if the first setting command includes the "LOGIC" field, it can be determined that the first timestamp mode is the logical timestamp mode.

[0165] Of course, the relevant information of the first timestamp mode may also be other information that can distinguish different timestamp modes, which is not limited in this embodiment of the present application.

[0166] Step S12: setting the first timestamp mode as the target timestamp mode applied by the database management system.

[0167] In response to the first setting command, the database management system uses the first timestamp mode indicated by the first setting command as the target timestamp mode applied by the database management system. That is, after determining the target timestamp mode, the database management system assigns corresponding timestamps to transactions of the database management system through the target timestamp mode.

[0168] Among them, in the solution provided by the embodiment of the present application, after determining the first timestamp mode, the database management system can store the first timestamp mode and configure a target tag for the first timestamp mode. After storing the first timestamp mode, if it is necessary to assign a timestamp to a transaction of the database, the database management system can query the stored content to determine that the timestamp mode configured with the target tag is the target timestamp mode applied by the database management system, and then assign a corresponding timestamp to the transaction of the database management system according to the target timestamp mode.

[0169] In addition, the first timestamp mode may be a timestamp mode selected from a physical timestamp mode, a logical timestamp mode, and a hybrid timestamp mode. That is, in the solution provided in the embodiment of the present application, the database management system may support multiple forms of timestamp modes. If the first timestamp mode is a physical timestamp mode, a corresponding physical timestamp is assigned to the transaction of the database management system; if the first timestamp mode is a logical timestamp mode, a corresponding logical timestamp is assigned to the transaction of the database management system; if the first timestamp mode is a hybrid timestamp mode, a corresponding hybrid timestamp is assigned to the transaction of the database management system.

[0170] Through the timestamp mode determination method for a database management system provided in an embodiment of the present application, a first setting command can be obtained, and according to the instruction of the first setting command, a target timestamp mode applied by the database management system can be determined, wherein the target timestamp mode is the first timestamp mode indicated by the first setting command, and the first timestamp mode matches the current application environment of the database management system.

[0171] In the prior art, a database management system usually applies a timestamp mode, and even if the application environment of the database management system changes, the timestamp mode applied by the database management system usually does not change. In this case, as the application environment of the database management system changes, the timestamp mode applied by the database management system often becomes inapplicable.

[0172] However, through the solution provided in the embodiment of the present application, the database management system can set the timestamp mode applied by the database management system according to the first setting command. In this case, the timestamp mode applied by the database management system is no longer fixed, but can support multiple forms of timestamp modes, and the target timestamp mode applied by the database management system matches the current application environment of the database management system, that is, the first timestamp is applicable to the database management system, thereby reducing the phenomenon of the database management system applying an inapplicable timestamp mode.

[0173] Furthermore, since the solution provided in the embodiment of the present application can reduce the phenomenon of the database management system applying an inappropriate timestamp mode, the reliability of implementing transactions of the database management system can also be improved.

[0174] In the above embodiment, a method for determining a timestamp mode of a database management system is provided, through which a corresponding target timestamp mode can be set according to the instruction of a first setting command, wherein the first setting command can be in various forms.

[0175] Among them, in a feasible implementation, the first setting command may be an SQL statement, in which case, the first setting command may also have other uses. For example, the first setting command may be an SQL statement for indicating the creation of a database, so that after the corresponding database is created according to the first setting command, a corresponding timestamp is assigned to the transaction of the database management system according to the first timestamp indicated by the first setting command; or, the first setting command may also be an SQL statement for indicating the creation of a table object of a database, in which case, the table object in the database may be created according to the first setting command, and a corresponding timestamp is assigned to the transaction for creating the table object according to the first timestamp mode; in addition, the first setting command may also be an SQL statement for adding, modifying, deleting or querying data in the database, in which case, the database may be added, modified, deleted or queried accordingly according to the first setting command, and a corresponding timestamp is assigned to the transaction for adding, modifying, deleting or querying the database accordingly according to the first timestamp mode.

[0176] If the first setting command is a first SQL statement, and the first SQL statement includes the attribute information of the database, then the corresponding database can be created through the first setting command. The attribute information of the database includes at least the name of the database. Of course, the attribute information of the database may also include other information used to create the database, for example, the attribute information may also include the size of the database and the character font (such as Chinese or English) of the database, etc., which is not limited in the embodiment of the present application.

[0177] In this case, see Figure 4 As shown in the workflow diagram, the solution provided in the embodiment of the present application also includes the following steps:

[0178] Step S13: Create the database according to the attribute information.

[0179] exist Figure 4 In the schematic diagram shown, the operation of step S12 is performed first, that is, the first timestamp mode is set as the target timestamp mode applied by the database management system, and then the operation of step S13 is performed, that is, the operation of creating the database according to the attribute information of the data database indicated by the first setting command. In actual applications, there is no strict time sequence restriction between step S12 and step S13. For example, the database can be created first, and then the first timestamp mode can be set as the target timestamp mode, or step S12 and step S13 can be performed simultaneously, which is not limited in the embodiment of the present application.

[0180] After determining that the first timestamp mode is the target timestamp mode applied by the database management system, during the operation of the database management system, corresponding timestamps can be allocated to transactions of the database management system through the first timestamp mode.

[0181] For clarity on how timestamps are assigned to transactions, see Figure 5 The workflow diagram shown in the figure, the embodiment of the present application also discloses the following steps:

[0182] Step S14: Receive a second SQL statement for creating a table object.

[0183] The second SQL statement corresponds to a transaction for creating a table object, and the second SQL statement may include attribute information of the table object in the database. The attribute information of the table object generally includes the table name of the table object, the names of the various fields included in the table object, and the types of the various fields.

[0184] A database may include one or more table objects. In this case, the second SQL statement may be used to create one or more table objects in the database, and accordingly, the second SQL statement may include attribute information of one or more table objects.

[0185] Step S15: Determine a first start timestamp of the transaction for creating the table object according to the first timestamp mode.

[0186] After receiving the second SQL statement for creating a table object, the database management system needs to execute the create table object transaction corresponding to the second SQL statement to create the table object of the database. Since the first timestamp mode is the target timestamp mode applied by the database management system, it is necessary to assign a timestamp to the create table object transaction using the first timestamp mode.

[0187] In an embodiment of the present application, after determining the first timestamp mode, the database management system may store the first timestamp mode. When a timestamp needs to be assigned, the first timestamp mode applied by the database management system can be determined by querying the stored content, and then corresponding timestamps can be assigned to the transactions of the database management system according to the first timestamp mode.

[0188] Step S16: Create the table object by executing the create table object transaction.

[0189] After assigning the first start timestamp to the create table object transaction, the database management system may execute the create table object transaction to create one or more table objects of the database.

[0190] Step S17: Determine a first end timestamp of the create table object transaction according to the first timestamp mode.

[0191] That is, in the embodiment of the present application, after the creation of the table object is completed, a first end timestamp is assigned to the table object creation transaction.

[0192] Through the operations from step S14 to step S17, a corresponding table object can be created for the database according to the received second SQL statement, and a corresponding timestamp can be allocated to the table object creation transaction according to the first timestamp mode.

[0193] In the embodiment corresponding to step S14 to step S17, the second SQL statement is an SQL statement for creating a table object in the database. In addition, during the operation of the database management system, other types of SQL statements can also be obtained, and corresponding timestamps can be assigned to transactions corresponding to the other types of SQL statements according to the first timestamp mode. For example, after determining that the first timestamp mode is the target timestamp mode, the first timestamp mode can also be used to assign corresponding timestamps to transactions for adding, deleting or querying data in the database, which is not limited in the embodiment of the present application.

[0194] In addition, after the first timestamp is set as the target timestamp mode of the database, the application environment of the database management system may change, so that the database management system is no longer applicable to the first timestamp mode after running for a period of time. For example, if the first timestamp mode is a logical timestamp mode, but as the database runs, the amount of data contained in the database increases, and the database is expanded accordingly, which may cause a delay in allocating logical timestamps to the nodes of the database, then the database management system is no longer applicable to the logical timestamp mode.

[0195] To address this problem, see Figure 6 The workflow diagram shown in the figure, the embodiment of the present application also discloses the following steps:

[0196] Step S18: After the application environment of the database management system changes, obtain a second setting command.

[0197] The second setting command includes timestamp information indicating a second timestamp mode, and the second timestamp mode matches the changed application environment.

[0198] During the operation of the database, if the target timestamp mode currently applied by the database management system is no longer applicable, the second setting command can be obtained so as to adjust the target timestamp mode applied by the database management system according to the second setting command. In this case, since the second timestamp mode matches the changed application environment, the second timestamp mode is applicable to the database management system after the application environment of the database management system changes.

[0199] Step S19: Adjust the target timestamp mode from the first timestamp mode to the second timestamp mode.

[0200] The target timestamp mode is the timestamp mode used by the database management system. After the second timestamp mode is adjusted to the target timestamp mode, the database management system will assign corresponding timestamps to transactions of the database according to the second timestamp mode.

[0201] If the database management system previously stores a first timestamp mode and configures a target tag for the first timestamp mode, then in the process of adjusting the target timestamp mode from the first timestamp mode to the second timestamp mode, it is necessary to store the second timestamp mode and adjust the target tag to the second timestamp mode.

[0202] Through the operations from step S18 to step S19, the first timestamp mode applied by the database management system can be switched to the second timestamp mode. Therefore, even if the application environment of the database management system changes, the timestamp mode applied by the database management system can be switched, and the switched timestamp mode adapts to the current application environment, thereby reducing the phenomenon of the database management system applying an inappropriate timestamp mode.

[0203] Furthermore, since the solution for switching the timestamp mode provided in the above embodiment can reduce the phenomenon of the database management system applying an inappropriate timestamp mode, the reliability of the implementation of transactions in the database management system can also be improved.

[0204] In order to clarify the advantages of the solution provided in the embodiment of the present application, the solution provided in the embodiment of the present application is compared with several commonly used database management systems in the prior art, and the following Table 2 is provided based on the comparison results:

[0205] Table 2

[0206] Multiple timestamp modes Switch timestamp mode Oracle Not supported Not supported Spanner Not supported Not supported Cockroach Not supported Not supported This application plan support support

[0207] Among them, Table 2 shows that the existing database management systems compared with the database management system using the embodiment of the present application are: the database management system of Oracle database, the database management system of Spanner database and the database management system of Cockroach database, and the database management system of Oracle database, the database management system of Spanner database and the database management system of Cockroach database do not support multiple timestamp modes, and the database management systems of these three databases do not support switching of timestamp modes, that is, the timestamp modes applied by these three database management systems are fixed. Therefore, after the application environment of the database management system changes, the timestamp mode applied by the database management system is often no longer applicable.

[0208] The database management system using the embodiment of the present application supports multiple timestamp modes and supports switching the timestamp mode applied by the database management system. Therefore, compared with the database in the prior art, the solution of the embodiment of the present application can effectively reduce the phenomenon of the database management system applying an inappropriate timestamp mode and further improve the reliability of the implementation of transactions.

[0209] In the above embodiment, an operation of adjusting the second timestamp mode indicated by the second setting command to the target timestamp mode is provided, and the operation can be implemented by the following steps:

[0210] The first step is to store the second timestamp mode;

[0211] The second step is to restart the database management system, wherein during the restart of the database management system, data recovery is performed on the database to avoid data loss in the database;

[0212] The third step is to set the stored second timestamp mode as the target timestamp mode after the database management system is restarted.

[0213] Through the above steps, after determining the second setting command indicating the second timestamp mode, the database management system can be restarted, and after the database management system completes the restart, the timestamp mode applied by the database management system is switched to the second timestamp mode, thereby achieving the switching of the target timestamp mode of the database management system from the first timestamp mode to the second timestamp mode.

[0214] Furthermore, in the embodiment of the present application, the following steps are also included:

[0215] Before the restarting of the database management system, it is determined that the first timestamp mode is different from the second timestamp mode.

[0216] The first timestamp mode is often stored in a storage medium, which may be a data storage device. In this step, the first timestamp mode stored in the storage medium may be read, and then the first timestamp mode may be compared with the second timestamp mode. If the first timestamp mode is different from the second timestamp mode, the database management system may be restarted to adjust the target timestamp mode from the first timestamp mode to the second timestamp mode.

[0217] In addition, if the first timestamp mode is the same as the second timestamp mode, the first timestamp mode can continue to be applied to assign timestamps to transactions of the database management system without restarting the database management system, thereby reducing restart operations of the database management system.

[0218] Through the solution provided in the above embodiment, the target timestamp mode of the database management system can be switched to the second timestamp mode. After the switching is completed, the corresponding timestamps are assigned to the transactions through the second timestamp mode. In order to clarify the method of assigning timestamps through the second timestamp mode, see Figure 7 The workflow diagram shown in the embodiment of the present application also includes the following steps:

[0219] Step S21: After setting the second timestamp mode as the target timestamp mode, receiving a third SQL statement.

[0220] Among them, the third SQL statement can be used to operate the database. The operations performed on the database can be to create table objects in the database, add data in the database, delete data in the database, modify data in the database, and query data in the database, etc. The embodiment of the present application is not limited to this.

[0221] Step S22: Determine a second start timestamp of the transaction corresponding to the third SQL statement according to the second timestamp mode.

[0222] Since the second timestamp pattern is stored in a storage medium, in this step, the second timestamp pattern can be determined by reading the stored content, and then the second start timestamp can be determined by the second timestamp pattern.

[0223] Step S23: Determine a second end timestamp of the transaction corresponding to the third SQL statement according to the second timestamp mode.

[0224] Through the operations of step S21 to step S23, after the target timestamp mode applied by the database management system is switched from the first timestamp mode to the second timestamp mode, corresponding timestamps can be allocated to the transactions of the database management system through the second timestamp mode.

[0225] Furthermore, in the embodiment of the present application, the following steps are also included:

[0226] A first maximum timestamp allocated by the first timestamp mode is stored.

[0227] In the solution provided in the embodiment of the present application, after storing the first maximum timestamp, the first maximum timestamp may also be applied.

[0228] In this case, in the solution provided in the embodiment of the present application, the first timestamp mode is a logical timestamp mode, and further includes the following steps:

[0229] again setting the target timestamp mode applied by the database management system to the first timestamp mode;

[0230] Based on the first maximum timestamp, a logical timestamp is assigned to the transaction of the database management system.

[0231] Among them, if the first timestamp mode is a logical timestamp mode, the stored first maximum timestamp is a logical timestamp. In this case, if the target timestamp mode is adjusted to a logical timestamp mode again, it is necessary to assign a timestamp to the transaction based on the first maximum timestamp.

[0232] Alternatively, in the solution provided in the embodiment of the present application, the first timestamp mode is a physical timestamp mode, see Figure 8 The workflow diagram shown may also include the following steps:

[0233] Step S24, setting the target timestamp mode of the database management system application to the first timestamp mode again;

[0234] Step S25, determining to set the target timestamp mode to the target time of the first timestamp mode again;

[0235] Step S26: determine whether the time indicated by the first maximum timestamp is earlier than the target time; if so, execute step S27.

[0236] Step S27: If the time indicated by the first maximum timestamp is earlier than the target time, assign a physical timestamp to the transaction of the database management system using the first timestamp mode.

[0237] If the first timestamp mode is a physical timestamp mode, the stored first maximum timestamp is a physical timestamp. In this case, whether the time device used by the database management system to determine the physical time is accurate can be determined by comparing the first maximum timestamp with the target time.

[0238] In the application scenario of this database provided in the embodiment of the present application, in the initial stage, the database management system applies the physical timestamp mode, and subsequently the timestamp mode applied by the database management system is switched so that the database management system applies the logical timestamp mode or the mixed timestamp mode, and in step S24, the timestamp mode applied by the database management system is switched to the physical timestamp mode again. That is to say, after determining the first maximum timestamp, at least two timestamp mode switches have been experienced before the target time is determined. Therefore, the time indicated by the first maximum timestamp should be earlier than the target time. If it is determined through the comparison of step S26 that the time indicated by the first maximum timestamp is not earlier than the target time, it indicates that the time device configured by the database management system for determining the physical time is inaccurate. In this case, the timestamp assigned to the transaction may be an erroneous timestamp. Therefore, in the embodiment of the present application, when it is determined that the first maximum timestamp is earlier than the target time, the physical timestamp mode is used to assign a physical timestamp to the transaction of the database, thereby improving the accuracy of the timestamp.

[0239] Further, in the embodiment of the present application, if it is determined according to the operation of step S26 that the time indicated by the first maximum timestamp is not earlier than the target time, the following steps may also be performed:

[0240] Step S28: If the time indicated by the first maximum timestamp is not earlier than the target time, obtain a third setting command.

[0241] The third setting command includes timestamp information indicating a third timestamp mode, and the third timestamp mode is different from the first timestamp mode.

[0242] The time indicated by the first maximum timestamp is no earlier than the target time, including the two situations that the time indicated by the first maximum timestamp is equal to the target time, or the time indicated by the first maximum timestamp is later than the target time. Both situations indicate that the time device configured by the database management system for determining the physical time is inaccurate. If the database management system continues to adopt the physical timestamp mode, it will often assign wrong timestamps.

[0243] Therefore, when it is determined that the time indicated by the first maximum timestamp is not earlier than the target time, a third setting command may be acquired so as to switch the timestamp mode applied by the database management system through the third setting command.

[0244] Step S29: Set the third timestamp mode as the target timestamp mode applied by the database management system.

[0245] The third timestamp mode is different from the first timestamp mode to prevent the database management system from continuing to apply an inaccurate physical timestamp mode.

[0246] Through the embodiments corresponding to steps S24 to S29, after the database management system switches to the physical timestamp mode and determines that the time device configured by the database management system for determining the physical time is inaccurate, the physical timestamp mode applied by the database management system can be switched to other timestamp modes to avoid the database management system applying an inaccurate physical timestamp mode.

[0247] Alternatively, in another feasible implementation of the present application, if the first timestamp mode is a physical timestamp mode, and the time indicated by the first maximum timestamp is not earlier than the target time, the allocation of timestamps is suspended, and a prompt message is generated to prompt the maintenance personnel of the database management system to inspect the time device.

[0248] In order to clarify the role of storing the first maximum timestamp in the embodiment of the present application, different switching scenarios in the database management system application are disclosed below:

[0249] Switching scenario one: the first timestamp mode is a logical timestamp mode, and the second timestamp mode after switching is a hybrid timestamp mode or a physical timestamp mode. In this switching scenario, the maximum logical timestamp allocated by the first timestamp mode (i.e., the first maximum timestamp) will be stored.

[0250] After the target timestamp mode of the database management system is switched from the first timestamp mode to the second timestamp mode, the database management system continues to run, and during the running process, the second timestamp mode is used to assign corresponding timestamps to the transactions of the database management system. However, after running for a period of time, the application environment of the database management system may change again, causing the second timestamp mode to no longer be applicable.

[0251] If the second timestamp mode is no longer applicable, a new setting command is determined, and according to the new setting command, the target timestamp applied by the database management system is adjusted to a timestamp mode different from the second timestamp mode.

[0252] After the adjustment, if the target timestamp mode of the database management system application is set to the logical timestamp mode again, the logical timestamp mode needs to be used to allocate logical timestamps for the transactions of the database management system. In addition, in the process of allocating logical timestamps, it is necessary to increase the maximum logical timestamp allocated by the first timestamp mode, and determine the logical timestamp based on the result of the increase.

[0253] For example, in this switching scenario, the maximum logical timestamp assigned by the first timestamp mode to the last transaction before the switch is 5. After the target timestamp mode of the database management system application is set to the logical timestamp mode again, the logical timestamp of the transaction is assigned by the logical timestamp mode, and the logical timestamp assigned by the logical timestamp mode after the switch needs to be increased based on the logical timestamp of 5. For example, the first logical timestamp assigned by the logical timestamp mode after the switch may be 6.

[0254] Switching scenario two: the first timestamp mode is a physical timestamp mode, and the second timestamp mode after switching is a logical timestamp mode or a mixed timestamp mode. In this scenario, the maximum physical timestamp allocated by the first timestamp mode (i.e., the first maximum timestamp) needs to be stored.

[0255] After the target timestamp mode of the database is switched from the first timestamp mode to the second timestamp mode, the database management system continues to run, and during the running process, the second timestamp mode is used to assign corresponding timestamps to the transactions of the database management system. After running for a period of time, the application environment of the database management system changes again, causing the second timestamp mode to no longer be applicable.

[0256] If the second timestamp mode is no longer applicable, a new setting command is determined, and according to the new setting command, the target timestamp applied by the database management system is adjusted to a timestamp mode different from the second timestamp mode.

[0257] After the adjustment, the target timestamp mode of the database may be adjusted to the physical timestamp mode. In this case, it may be determined to set the target timestamp mode to the target time of the physical timestamp again, and compare the first maximum timestamp with the target time. If the comparison result shows that the first maximum timestamp is earlier than the target time, the database management system assigns a physical timestamp to the transaction through the physical timestamp mode.

[0258] Among them, since the target timestamp mode of the database management system is set to the physical timestamp mode again after the first maximum timestamp is obtained, the first timestamp should be earlier than the target time. If the comparison result shows that the first maximum timestamp is not earlier than the target time, it indicates that the time device used by the database management system to determine the physical time has failed, and the physical time determined by the time device is incorrect. In this case, the timestamp mode applied by the database management system can be switched to other timestamp modes, or, in order to avoid allocating wrong timestamps, the allocation of timestamps can be suspended. Furthermore, a prompt message can be generated to prompt the database maintenance personnel to repair the time device.

[0259] In addition, after determining that the first maximum timestamp is earlier than the target time, a physical timestamp is allocated to the transaction of the database management system through the physical timestamp mode, thereby improving the correctness of allocating timestamps.

[0260] For example, the first timestamp mode is set to the physical timestamp mode, and the first maximum timestamp is 11:30 on August 10. After the target timestamp mode of the database management system is switched to the second timestamp mode, in this switching scenario, the target timestamp mode of the database management system is adjusted to the physical timestamp mode again, and the target timestamp mode is set again to the target time of the physical timestamp mode as 11:20 on August 10. Then, the first maximum timestamp is later than the target time, which indicates that the accuracy of the time device used by the database management system to determine the time is poor. In this case, the timestamp mode applied by the database management system can be switched.

[0261] In an embodiment of the present application, an operation of obtaining a second setting command after the application environment of the database management system changes is provided, wherein the second setting command is used to instruct the target timestamp mode to switch to the second timestamp mode, and the second setting command can be obtained in multiple ways.

[0262] In one feasible implementation manner, obtaining the second setting command includes: receiving the second setting command sent by the client.

[0263] In this implementation, the second setting command may be an SQL statement. When the operation and maintenance personnel of the database determine that the application environment of the database management system has changed, they may input an SQL statement to the database management system through the client, so that the database management system switches the timestamp mode applied by the database management system according to the received SQL statement.

[0264] Alternatively, in another feasible implementation manner, obtaining the second setting command includes the following steps:

[0265] The first step is to determine the application environment of the database management system after the change;

[0266] The second step is to determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode and the application environment after the change of the database management system;

[0267] The third step is to generate the second setting command according to the determined second timestamp mode.

[0268] Through the above solution, the database management system can generate a corresponding second setting command for the database management system according to the change of the application environment, thereby ensuring that the database management system applies a timestamp mode that matches the changed application environment.

[0269] According to the above introduction to various timestamp modes, different timestamp modes are suitable for different application environments. In this case, a mapping relationship between different application environments and timestamp modes can be set, and according to the changed application environment and the mapping relationship of the database management system, a second timestamp mode suitable for the changed application environment is determined, and a third setting command indicating the second timestamp mode is generated.

[0270] In an example of a mapping relationship between an application environment and a timestamp mode, referring to Table 1, it can be set that in an application environment where the performance of the counter configured by the database management system is high and the delay in allocating logical timestamps to each node in the database is small, the corresponding timestamp mode is the logical timestamp mode. Accordingly, if the application environment after the change of the database management system conforms to this application environment, the second setting command includes timestamp information indicating the logical timestamp mode.

[0271] In addition, referring to Table 1, in the example of the mapping relationship, when the time device configured by the database management system for determining the physical time has a higher accuracy, the corresponding timestamp mode is the physical timestamp mode. Accordingly, if the application environment after the change of the database management system indicates that the accuracy of the time device is higher, the second timestamp mode can be determined to be the physical timestamp mode, and the corresponding second setting command includes timestamp information indicating the physical timestamp mode.

[0272] Compared with the logical timestamp mode, the hybrid timestamp mode has slightly lower performance requirements for nodes with counter functions, and compared with the physical timestamp mode, the hybrid timestamp mode has slightly lower accuracy requirements for the time device, and this mapping relationship can indicate that the timestamp mode corresponding to this application environment is the hybrid timestamp mode. Therefore, if the application environment after the database management system changes indicates that the performance of the nodes with counter functions configured by the database management system is medium, and the accuracy of the time device is medium, then it can be determined that the second timestamp mode is the hybrid timestamp mode, and the corresponding second setting command includes timestamp information indicating the hybrid timestamp mode.

[0273] Through the embodiments of the present application, a second timestamp mode applicable to the database management system can be determined according to the application environment of the database management system, and a corresponding second setting command can be obtained. According to the second setting command, the target timestamp mode applied by the database management system can be adjusted to the second timestamp mode, thereby ensuring that the database management system applies a timestamp mode that conforms to the current application environment and avoiding the database management system from applying an inappropriate timestamp mode.

[0274] According to various embodiments of the present application, it can be seen that through the solution provided by the embodiments of the present application, the database management system can support multiple forms of timestamp modes and support switching between different timestamp modes. During the switching process, the database management system often obtains multiple setting commands indicating different timestamp modes.

[0275] In order to determine the target timestamp mode applied by the database management system, in a feasible implementation method provided in an embodiment of the present application, after determining the target timestamp mode, the target timestamp mode is often stored, and a corresponding target tag is configured for the target timestamp mode. In this way, if a timestamp needs to be assigned to a transaction of the database, the target timestamp mode applied by the database management system can be determined by querying whether the stored timestamp mode has a target tag, and the corresponding timestamp is assigned to the transaction of the database management system according to the target timestamp mode.

[0276] Among them, the target tag may be a specific field, for example, the target tag may be a "current_timestamp_mode" field. Of course, the target tag may also be other fields, and the embodiment of the present application does not limit this.

[0277] In this case, after the first setting command is acquired, the first timestamp mode indicated by the setting command may be stored, and a target tag for characterizing a target timestamp mode may be allocated to the stored first timestamp mode.

[0278] In addition, in the process of setting the second timestamp mode indicated by the second setting command as the target timestamp mode, the second timestamp mode may be stored, the target tag may be set for the second timestamp mode, and the target tag of the first timestamp mode may be cancelled.

[0279] In another feasible implementation, the timestamp modes indicated by the various setting commands may be stored in a specific storage order, and the target timestamp mode among the stored timestamp modes may be determined according to the storage order.

[0280] Exemplarily, the first timestamp patterns may be stored in chronological order. In this case, the latest stored timestamp pattern may be determined as the target timestamp pattern.

[0281] Alternatively, in another feasible implementation, a specific storage space is set for the storage medium of the database management system, and after determining the target timestamp mode, the target timestamp mode is stored in the specific storage space. In this case, the target timestamp mode applied by the database management system can be determined by querying the specific storage space.

[0282] In order to clarify the solution provided by the embodiment of the present application, the solution provided by the embodiment of the present application is introduced below based on the scenario in which the database management system is running.

[0283] In scenario 1, see Figure 1A-Figure 1C and Figure 2 The database management system determines that a first setting command for creating a database is required, and the first setting command includes attribute information of the database to be created, such as the name of the database, etc. In addition, the first setting command also includes timestamp information indicating a first timestamp mode. For example, if the database management system applies a physical timestamp mode, the first setting command includes relevant information of the physical timestamp mode.

[0284] The first setting command may be an SQL statement transmitted by the client, and the database created this time is the database required by the client.

[0285] After determining the first setting command, the database management system creates a corresponding database in the data storage according to the attribute information included in the first setting command. In addition, the database management system stores the first timestamp mode in the data storage according to the instruction of the first setting command, and assigns a target tag to the first timestamp mode, so as to characterize the first timestamp mode as a target timestamp mode applied by the database management system through the target tag.

[0286] Exemplarily, Table 3 may be set in the data memory:

[0287] Table 3

[0288]

[0289]

[0290] In the example corresponding to Table 3, the first timestamp mode is a logical timestamp (i.e., "LOGIC" in the above table), the field value corresponding to the "current_timestamp_mode" field is "LOGIC", and the type of the field is text. Since the third setting command has not been obtained, there is no need to switch the target timestamp mode of the database, the field value corresponding to the "next_timepstamp_mode" field is also "LOGIC", and the type of the field is text.

[0291] In addition, in Table 3, the "logic_max_value" field, the "physical_max_value" field, and the "hlc_max_value" field respectively indicate the maximum timestamp corresponding to the logical timestamp mode, the maximum timestamp corresponding to the physical timestamp mode, and the maximum timestamp corresponding to the hybrid timestamp mode. Since in this scenario, there is no need to switch the timestamp mode applied by the database management system, there is no need to record the first maximum timestamp allocated by the first timestamp mode for the time being.

[0292] Through this scenario, the creation of a database can be achieved, and the first timestamp mode is set as the target timestamp mode applied by the database management system.

[0293] In scenario 2, a table object needs to be created in the database.

[0294] The database management system may receive a second SQL statement for creating a table object, wherein the second SQL statement includes attribute information of the table object in the database, and the transaction corresponding to the second SQL statement may be called a create table object transaction.

[0295] In this scenario, the database management system reads the data storage device, and determines that the target timestamp mode currently applied by the database is the first timestamp mode according to the timestamp mode in which the target tag is configured. Then, the database management system assigns a first start timestamp to the create table object transaction according to the first timestamp mode. In addition, the database management system executes the create table object transaction, and performs corresponding read and write operations on the data storage device to create a table object corresponding to the attribute information of the table object contained in the second SQL statement, and determines the first end timestamp of the create table object transaction according to the first timestamp mode.

[0296] Through this scenario, a corresponding table object can be created in the database, and a corresponding timestamp can be assigned to the table object creation transaction through the first timestamp mode.

[0297] In scenario three, after the database is created, if the data in the database needs to be processed, such as adding, modifying, deleting or querying data, the database management system can often receive corresponding SQL statements.

[0298] In this case, after receiving the SQL statement, the database management system determines the transaction corresponding to the SQL statement and executes it. In addition, the database management system can also determine the target timestamp mode applied by the database management system by reading the data storage device, and assign a corresponding timestamp to the transaction corresponding to the SQL statement through the target timestamp mode.

[0299] Through this scenario, data in the database can be added, modified, deleted or queried, and during the transaction implementation process, a corresponding timestamp is assigned to the transaction through the first timestamp mode.

[0300] In scenario 4, the application environment of the database management system may change, for example, the accuracy of the time device used to determine the physical time configured in the database may decrease, or as the database expands, a large delay may occur when allocating logical timestamps to the database. As the application environment changes, the first timestamp mode currently applied by the database may no longer be applicable, and the target timestamp mode applied by the database management system may need to be switched from the first timestamp mode to the second timestamp mode.

[0301] In this case, after the application environment of the database management system changes, the database management system may obtain a second setting command, wherein the second setting command includes timestamp information indicating a second timestamp mode, and the second timestamp mode matches the changed application environment.

[0302] In a feasible implementation, the database management system may receive a second setting command transmitted by the client. In this case, the second setting command may be an SQL statement transmitted by the client, and the SQL statement includes relevant information of the second timestamp mode.

[0303] In another feasible implementation, the database management system may determine a second timestamp mode applicable to the database after the application environment changes according to the application environment after the database management system changes and the relationship between the application environment and the timestamp mode, and generate a corresponding second setting command accordingly.

[0304] After acquiring the second setting command, the database management module stores the second timestamp mode indicated by the second setting command and sets a corresponding target tag for the second timestamp. If a target tag is previously set for the first timestamp mode, the target tag of the first timestamp mode also needs to be cancelled to indicate that the target timestamp mode applied by the database management system is the second timestamp mode.

[0305] Exemplarily, if Table 3 is stored in the data storage, the database manager may modify Table 3 into the following Table 4 by reading and writing the data storage:

[0306] Table 4

[0307]

[0308] In the example corresponding to Table 4, the first timestamp mode is the logical timestamp mode (i.e., "LOGIC" in the above table), then the field value corresponding to the "current_timestamp_mode" field is "LOGIC", and the type of the field is text. In addition, in this example, the second timestamp mode is the physical timestamp mode (i.e., "PHYSICAL" in the above table), then the field value corresponding to the "next_timepstamp_mode" is "PHYSICAL", and the type of the field is also text.

[0309] After modifying Table 3 to Table 4, the database management system is restarted, and after restarting, data recovery is performed on the database. In addition, the database management system reads and writes the first maximum timestamp allocated by the first timestamp mode to the data storage, thereby obtaining Table 5:

[0310] Table 5

[0311]

[0312] Among them, in the example corresponding to Table 5, the second timestamp mode is the physical timestamp mode, and the second timestamp mode is the target timestamp mode applied by the database management system. In this case, the field value corresponding to the "current_timestamp_mode" field is "PHYSICAL", and the type of the field is text text. In addition, since other setting commands for switching the timestamp mode have not yet been determined, that is, there is no need to switch the target timestamp mode applied by the database management system from the second timestamp mode to other timestamp modes for the time being, therefore, the field value corresponding to "next_timepstamp_mode" can be "PHYSICAL".

[0313] In addition, the first maximum timestamp corresponding to the first timestamp mode needs to be stored in Table 5. In this example, the first timestamp mode is a logical timestamp mode, and the first timestamp is 12000, so the field value "12000" can be filled in the "logic_max_value" field in Table 5.

[0314] Through this scenario, the second timestamp mode can be adjusted to the target timestamp mode applied by the database management system, and the first maximum timestamp allocated by the first timestamp mode can also be stored so that the database management system applies a timestamp mode that matches the changed application environment.

[0315] In scenario five, operations need to be performed on the database, for example, data in the database needs to be queried, modified, added, or deleted.

[0316] In this scenario, the database management system may receive an SQL statement for performing corresponding operations on the database. By parsing the SQL statement, the database management system may determine the transaction to be executed this time, and implement the transaction corresponding to the SQL statement by reading and writing data in the data storage.

[0317] In addition, during the transaction implementation process, the database management system can determine that the target timestamp mode applied by the database management system is the second timestamp mode in the current application environment by querying the data storage device, and assign corresponding timestamps to the transactions through the second timestamp mode.

[0318] Through this scenario, various transactions can be implemented, and timestamps can be assigned to the transactions by switching to the second timestamp mode, so that the database management system after the application environment changes can assign more accurate timestamps to ensure the implementation of transactions.

[0319] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0320] Corresponding to the above method embodiment, the present application embodiment discloses a database management system. Fig. 9 As shown in the structural schematic diagram, the data management system includes: a first acquisition module 200 and a first setting module 300.

[0321] The first acquisition module 200 is used to acquire a first setting command, the first setting command includes timestamp information indicating a first timestamp mode, and the first timestamp mode matches the current application environment of the database management system;

[0322] The first setting module 300 is used to set the first timestamp mode as a target timestamp mode applied by the database management system.

[0323] The database management system provided by the embodiment of the present application can obtain a first setting command and determine the target timestamp mode applied by the database management system according to the instruction of the first setting command, wherein the target timestamp mode is the first timestamp mode indicated by the first setting command, and the first timestamp mode matches the current application environment of the database management system.

[0324] In this case, the database management system can support multiple forms of timestamp modes, and the target timestamp mode applied by the database management system matches the current application environment of the database management system, that is, the first timestamp is applicable to the database management system, thereby reducing the phenomenon that the database management system applies an inapplicable timestamp mode.

[0325] In the database management system provided in the embodiment of the present application, the first setting command may be in various forms. In one feasible implementation, the first setting command may be a SQL statement. For example, the first setting command may be a SQL statement for instructing to create a database.

[0326] In this case, the first setting command is a first SQL statement, and the first SQL statement includes attribute information of the database.

[0327] Accordingly, in order to realize the creation of a database, the database management system further includes:

[0328] The first creation module is used to create the database according to the attribute information.

[0329] Furthermore, in the database management system provided in the embodiment of the present application, it also includes:

[0330] A first receiving module, configured to receive a second SQL statement for creating a table object, wherein the second SQL statement corresponds to a create table object transaction;

[0331] A second determining module, configured to determine a first start timestamp of the create table object transaction according to the first timestamp mode;

[0332] A second creation module, configured to create the table object by executing the create table object transaction;

[0333] The second determining module is further configured to determine a first end timestamp of the create table object transaction according to the first timestamp mode.

[0334] Through the solution of the embodiment of the present application, a corresponding table object can be created for the database according to the received second SQL statement, and a corresponding timestamp can be assigned to the table object creation transaction according to the first timestamp mode.

[0335] Further, in the database management system provided in the embodiment of the present application, the first acquisition module is further used to, after the application environment of the database management system changes, acquire a second setting command, the second setting command includes timestamp information indicating a second timestamp mode, and the second timestamp mode matches the changed application environment;

[0336] The first setting module is further used to adjust the target timestamp mode from the first timestamp mode to the second timestamp mode.

[0337] During the operation of the database, if the target timestamp mode currently applied by the database management system is no longer applicable, the second setting command can be obtained so as to adjust the target timestamp mode applied by the database management system according to the second setting command. In this case, since the second timestamp mode matches the changed application environment, the second timestamp mode is applicable to the database management system after the application environment of the database management system changes.

[0338] Furthermore, in the database management system provided in the embodiment of the present application, the first setting module is specifically used to store the second timestamp mode, restart the database management system, and after completing the restart of the database management system, set the stored second timestamp mode as the target timestamp mode.

[0339] Furthermore, in the database management system provided in the embodiment of the present application, the first setting module is also used to determine, before restarting the database management system, that the first timestamp mode is different from the second timestamp mode.

[0340] In addition, if the first timestamp mode is the same as the second timestamp mode, the first timestamp mode can continue to be applied to assign timestamps to transactions of the database management system without restarting the database management system, thereby reducing restart operations of the database management system.

[0341] Furthermore, in the database management system provided in the embodiment of the present application, it also includes:

[0342] A second receiving module, configured to receive a third SQL statement after setting the second timestamp mode to the target timestamp mode;

[0343] A third determining module, configured to determine a second start timestamp of the operation transaction corresponding to the third SQL statement according to the second timestamp mode;

[0344] The third determination module is used to determine a second end timestamp of the operation transaction according to the second timestamp mode.

[0345] Through this embodiment, after the target timestamp mode applied by the database management system is switched from the first timestamp mode to the second timestamp mode, corresponding timestamps can be allocated to transactions of the database management system through the second timestamp mode.

[0346] Furthermore, in the database management system provided in the embodiment of the present application, it also includes:

[0347] A storage module is used to store the first maximum timestamp allocated by the first timestamp mode.

[0348] Among them, if the first timestamp mode is a logical timestamp mode, the first setting module is also used to set the target timestamp mode applied by the database management system to the first timestamp mode again, and assign logical timestamps to transactions of the database management system based on the first maximum timestamp.

[0349] In addition, if the first timestamp mode is a physical timestamp mode, the first setting module is also used to set the target timestamp mode applied by the database management system to the first timestamp mode again; determine the target time for setting the target timestamp mode to the first timestamp mode again; if the time indicated by the first maximum timestamp is earlier than the target time, assign a physical timestamp to the transaction of the database management system through the first timestamp mode.

[0350] Further, the first acquisition module is further configured to, if the time indicated by the first maximum timestamp is not earlier than the target time, acquire a third setting command, the third setting command including timestamp information indicating a third timestamp mode, the third timestamp mode being different from the first timestamp mode;

[0351] The first setting module is further used to set the third timestamp mode as the target timestamp mode applied by the database management system;

[0352] Alternatively, the first setting module is further used to suspend allocating timestamps and generate prompt information.

[0353] In addition, in the database management system provided in the embodiment of the present application, the first acquisition module is specifically used to receive a second setting command sent from the client;

[0354] Alternatively, the first acquisition module is specifically used to determine the application environment of the database management system after the change; determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode, and the application environment of the database management system after the change; and generate the second setting command according to the determined second timestamp mode.

[0355] Accordingly, an embodiment of the present application provides a database server, the database server comprising:

[0356] at least one processor, a non-transitory computer readable medium storing executable code, and a database management system;

[0357] Wherein, when the executable code is executed by the at least one processor, it is configured to implement the function of the database management system.

[0358] The database management system can be used to implement the Figures 3 to 8 In some or all of the steps in the corresponding embodiments, in a feasible design, the structure of the database management system can be as follows Fig. 9 shown.

[0359] See also Fig.10 The embodiment of the present application further provides a cluster database system 500, comprising: a hardware layer 1007 and a virtual machine monitor (VMM) 1001 running on the hardware layer 1007, and at least one virtual machine (VM) 1002. A virtual machine can serve as a data node of the cluster database system 500. Optionally, one of the virtual machines can also be designated as a coordination node.

[0360] Specifically, virtual machine 1002 is a virtual computer simulated on public hardware resources by virtual machine software, on which operating system and application programs can be installed, and network resources can be accessed by the virtual machine. For application programs running in the virtual machine, the virtual machine is like working in a real computer.

[0361] The hardware layer 1007 is a hardware platform for the virtualized environment to run, which can be abstracted from the hardware resources of one or more physical hosts. The hardware layer may include a variety of hardware, such as a processor 1004 (such as a CPU) and a memory 1005, and may also include a network card 1003 (such as an RDMA network card), high-speed / low-speed input / output (I / O) devices, and other devices with specific processing functions.

[0362] The virtual machine 1002 runs the executable program based on the VMM and the hardware resources provided by the hardware layer 1007 to achieve the above Figures 3 to 8 For the sake of brevity, some or all of the functions in the relevant embodiments will not be described in detail here.

[0363] Furthermore, the cluster database system 500 may also include a host machine (Host), which serves as a management layer to complete the management and allocation of hardware resources, present a virtual hardware platform to the virtual machine, and can be used to implement the scheduling and isolation of the virtual machine. The Host may be a virtual machine monitor VMM; it may also be a combination of a VMM and a privileged virtual machine. The virtual hardware platform provides various hardware resources to each virtual machine running on it, such as providing a virtual processor (such as VCPU), virtual memory, virtual disk, virtual network card, etc. The virtual disk may correspond to a file or a logical block device of the Host. The virtual machine runs on the virtual hardware platform prepared by the Host, and one or more virtual machines run on the Host. The VCPU of the virtual machine 1002 implements or executes the method steps described in the above-mentioned method embodiments of the present invention by executing the executable program stored in its corresponding virtual memory. For example, to implement the above Figures 3 to 8 Part or all of the functionality of the SQL engine and execution engine in related embodiments.

[0364] See also Fig.11 The embodiment of the present application also provides a database system, including: a database server 800, and a client device 900 connected to the database server via a communication network.

[0365] The client device 900 has an operating system 904 running on the hardware layer 906, and an application 902 running on the operating system 904; the database server 800 has an operating system 814 running on the hardware layer 816, and a database management system 812 running on the operating system 814. The application 902 is connected to the database management system 812 running on the database server 800 via a communication network and accesses or operates a database stored in a data storage 818, for example, querying, updating or deleting data in the database through SQL statements, or importing new data into the database.

[0366] The hardware layers 906 and 816 include basic hardware units required for the operation of the operating system and application programs, for example, a processor such as a CPU, memory, input / output devices, a network interface, etc.

[0367] The data storage 818 may be an external storage of the database server 800, such as a hard disk, a disk, a storage array, or a storage server, etc., which is communicatively connected to the database server 800. Alternatively, the data storage 818 may also be integrated inside the database server 800, and exchange data with the processor and I / O devices through a bus or other internal communication methods.

[0368] The memory of the database server 800 stores executable code, which is configured to implement the components and functions of the database management system 812 when executed by the processor. The database management system 812 can be specifically Fig. 9 The database management system 108 shown, related functions and implementation details can be referred to Figures 3 to 8 The relevant embodiments will not be described in detail here.

[0369] In a specific implementation, the present application also provides a computer-readable storage medium, which includes instructions. The computer-readable storage medium set in any device can implement the following when it is executed on a computer: Figures 3 to 8 The computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).

[0370] In addition, another embodiment of the present application further provides a computer program product comprising instructions, when the computer program product is run on an electronic device, the electronic device can implement the following steps: Figures 3 to 8 All or part of the steps in the corresponding embodiments.

[0371] It should be understood that in various embodiments of the present application, "executable program" should be broadly interpreted as including but not limited to: instructions, instruction sets, codes, code segments, subroutines, software modules, applications, software packages, threads, processes, functions, firmware, middleware, etc. The order of the sequence numbers of the method steps described in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0372] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in hardware, or a combination of computer software and hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application.

[0373] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the database server, data management system and database system described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0374] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0375] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0376] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0377] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

Claims

1. A method for determining a timestamp mode of a database management system, characterized in that: include: Obtaining a first setting command, the first setting command including timestamp information indicating a first timestamp mode, the first timestamp mode matching a current application environment of the database management system; Setting the first timestamp mode as the target timestamp mode applied by the database management system; After the application environment of the database management system changes, obtaining a second setting command, the second setting command including timestamp information indicating a second timestamp mode, the second timestamp mode matching the changed application environment; The target timestamp mode is adjusted from the first timestamp mode to the second timestamp mode.

2. The method according to claim 1, characterized in that The first setting command is a first structured query SQL statement, and the first SQL statement includes attribute information of the database; The method further comprises: The database is created according to the attribute information.

3. The method according to claim 1 or 2, characterized in that: Also includes: receiving a second SQL statement for creating a table object, wherein the second SQL statement corresponds to a create table object transaction; Determining a first start timestamp of the create table object transaction according to the first timestamp mode; The table object is created by executing the create table object transaction; A first end timestamp of the create table object transaction is determined according to the first timestamp mode.

4. The method according to claim 1, characterized in that: The step of adjusting the target timestamp mode from the first timestamp mode to the second timestamp mode includes: storing the second timestamp pattern; Restarting the database management system; After the database management system is restarted, the stored second timestamp mode is set as the target timestamp mode.

5. The method according to claim 4, characterized in that Also includes: Before the restarting of the database management system, it is determined that the first timestamp mode is different from the second timestamp mode.

6. The method according to claim 4 or 5, characterized in that: Also includes: After setting the second timestamp mode as the target timestamp mode, receiving a third SQL statement; Determine, according to the second timestamp mode, a second start timestamp of the transaction corresponding to the third SQL statement; A second end timestamp of the transaction corresponding to the third SQL statement is determined according to the second timestamp mode.

7. The method according to any one of claims 4 to 6, characterized in that: Also includes: A first maximum timestamp allocated by the first timestamp mode is stored.

8. The method according to claim 7, characterized in that The first timestamp mode is a logical timestamp mode, and the method further includes: again setting the target timestamp mode applied by the database management system to the first timestamp mode; Based on the first maximum timestamp, a logical timestamp is assigned to the transaction of the database management system.

9. The method according to claim 7, characterized in that: The first timestamp mode is a physical timestamp mode, and the method further includes: again setting the target timestamp mode applied by the database management system to the first timestamp mode; determining a target time for setting the target timestamp mode to the first timestamp mode again; If the time indicated by the first maximum timestamp is earlier than the target time, a physical timestamp is allocated to the transaction of the database management system using the first timestamp mode.

10. The method according to claim 9, characterized in that Also includes: If the time indicated by the first maximum timestamp is not earlier than the target time, acquiring a third setting command, the third setting command including timestamp information indicating a third timestamp mode, the third timestamp mode being different from the first timestamp mode; Setting the third timestamp mode as the target timestamp mode applied by the database management system; or, Pauses the allocation of timestamps and generates a prompt message.

11. The method according to claim 1, characterized in that: The obtaining of the second setting command comprises: receiving a second setting command sent from the client; or, Determine the application environment of the database management system after the change; determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode, and the application environment of the database management system after the change; and generate the second setting command according to the determined second timestamp mode.

12. A database management system, characterized in that: include: A first acquisition module, configured to acquire a first setting command, wherein the first setting command includes timestamp information indicating a first timestamp mode, and the first timestamp mode matches a current application environment of the database management system; A first setting module, used for setting the first timestamp mode as a target timestamp mode applied by the database management system; The first acquisition module is further used to acquire a second setting command after the application environment of the database management system changes, the second setting command including timestamp information indicating a second timestamp mode, and the second timestamp mode matches the changed application environment; The first setting module is further used to adjust the target timestamp mode from the first timestamp mode to the second timestamp mode.

13. The database management system according to claim 12, characterized in that: The first setting command is a first structured query SQL statement, and the first SQL statement includes attribute information of the database; The database management system also includes: The first creation module is used to create the database according to the attribute information.

14. The database management system according to claim 12 or 13, characterized in that: Also includes: A first receiving module, configured to receive a second SQL statement for creating a table object, wherein the second SQL statement corresponds to a create table object transaction; A second determining module, configured to determine a first start timestamp of the create table object transaction according to the first timestamp mode; A second creation module, configured to create the table object by executing the create table object transaction; The second determining module is further configured to determine a first end timestamp of the create table object transaction according to the first timestamp mode.

15. The database management system according to claim 12, characterized in that: The first setting module is specifically used to store the second timestamp mode, restart the database management system, and after completing the restart of the database management system, set the stored second timestamp mode as the target timestamp mode.

16. The database management system according to claim 15, characterized in that: The first setting module is further used for, before restarting the database management system, determining that the first timestamp mode is different from the second timestamp mode.

17. The database management system according to claim 15 or 16, characterized in that: Also includes: A second receiving module, configured to receive a third SQL statement after setting the second timestamp mode to the target timestamp mode; A third determining module, configured to determine a second start timestamp of the operation transaction corresponding to the third SQL statement according to the second timestamp mode; The third determination module is further configured to determine a second end timestamp of the operation transaction according to the second timestamp mode.

18. The database management system according to any one of claims 15 to 17, characterized in that: Also includes: A storage module is used to store the first maximum timestamp allocated by the first timestamp mode.

19. The database management system according to claim 18, characterized in that: The first timestamp mode is a logical timestamp mode, and the first setting module is further used to set the target timestamp mode of the database management system application to the first timestamp mode again, and allocate logical timestamps to transactions of the database management system based on the first maximum timestamp.

20. The database management system according to claim 18, characterized in that: The first timestamp mode is a physical timestamp mode, and the first setting module is further used to set the target timestamp mode applied by the database management system to the first timestamp mode again; determine the target time for setting the target timestamp mode to the first timestamp mode again; if the time indicated by the first maximum timestamp is earlier than the target time, assign a physical timestamp to the transaction of the database management system through the first timestamp mode.

21. The database management system according to claim 20, characterized in that: The first acquisition module is further configured to, if the time indicated by the first maximum timestamp is not earlier than the target time, acquire a third setting command, the third setting command including timestamp information indicating a third timestamp mode, the third timestamp mode being different from the first timestamp mode; The first setting module is further used to set the third timestamp mode as the target timestamp mode applied by the database management system; or, The first setting module is also used to suspend allocating timestamps and generate prompt information.

22. The database management system according to claim 12, characterized in that: The first acquisition module is specifically used to receive a second setting command sent from the client; or, The first acquisition module is specifically used to determine the application environment of the database management system after the change; determine the second timestamp mode according to the mapping relationship between the application environment and the timestamp mode, and the application environment of the database management system after the change; and generate the second setting command according to the determined second timestamp mode.

23. A database server, characterized in that: include: at least one processor, a non-transitory computer readable medium storing executable code, and a database management system as claimed in any one of claims 12 to 22; Wherein, when the executable code is executed by the at least one processor, it is configured to implement the function of the database management system.

24. A cluster database system, characterized in that: include: A hardware layer, a virtual machine monitor VMM running on the hardware layer, and at least one virtual machine; The at least one virtual machine implements the method according to any one of claims 1 to 11 by running an executable program based on the hardware resources provided by the VMM and the hardware layer.

25. A database system, characterized in that: include: A database server, and a client device connected to the database server via a communication network; A client operating system is running on the client device, and an application of the client device is running on the client operating system; The database server runs an operating system of the database server, and the database server also includes a database management system according to any one of claims 12 to 22.

26. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store instructions, and when the instructions are executed on a computer or a processor, the computer or the processor implements the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Rule-based autonomous database cloud service framework

    CN111263938A