Data storage method and apparatus, and electronic device

By independently maintaining database metadata on the server side and creating a new second data table to store incremental data, the problem of suspension of write operations when metadata changes is solved, and real-time validation of metadata and continuity of write operations are achieved.

WO2024174715A1PCT designated stage expired Publication Date: 2024-08-29BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/141526
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-21
Filing Date
2023-12-25
Publication Date
2024-08-29

AI Technical Summary

Technical Problem

When metadata changes, the existing technology needs to temporarily stop writing new data, which affects the writing operation of the database and thus affects the business.

Method used

By independently maintaining the metadata of the database on the server side, and creating a new second data table when the metadata changes, the incremental data is written into the persistent storage space to avoid updating the metadata in the data table. Make the changed metadata take effect in real time without affecting the writing operation.

Benefits of technology

It reduces the storage space requirements for metadata, enables the changed metadata to take effect in real time, and avoids the impact on database writing operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023141526_29082024_PF_FP_ABST
    Figure CN2023141526_29082024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are a data storage method and apparatus, and an electronic device. The data storage method comprises: in response to a change in metadata which is independently maintained by a serving end and corresponds to a data table in a database, setting a second data table to be in an unmodifiable state, and writing incremental data in the second data table into a first data table in a persistent storage space on the serving end; and creating a new second data table corresponding to the changed metadata, and recording newly acquired incremental data in the second data table, such that the changed metadata can take effect in real time while greatly reducing a storage space for the metadata, thus not affecting a write operation on data.
Need to check novelty before this filing date? Find Prior Art

Description

Data storage method, device and electronic device Technical Field

[0001] The present application belongs to the field of data storage technology, and specifically relates to a data storage method, device and electronic equipment. Background Art

[0002] User data stored in a database may include data and metadata. The metadata, referred to as data about the data, is used to interpret the data. If the data type of the user data is structured data, such as data recorded in a table structure, the metadata may include metadata used to explain the basic information of the table structure. After defining a table structure, the table structure can be adjusted using predefined modification statements, resulting in changes to the corresponding metadata. When metadata changes, different versions of the metadata need to be used in conjunction with different versions of the data: the newer version of the metadata may not be able to accurately interpret the older version of the data, and the older version of the metadata may not be able to accurately interpret the newer version of the data.

[0003] Regarding metadata changes, relevant technologies can perform metadata changes based on the original table structure, but it is necessary to temporarily stop writing new data and wait for the metadata change to be completed before continuing to write, which affects the write operation to the database and thus affects the business.

[0004] Summary of the Invention

[0005] In view of this, the present application provides a data storage method, device and electronic device for solving the problem that when metadata changes are made, it is necessary to temporarily stop writing new data, thereby affecting the write operation to the database.

[0006] Specifically, the present application is implemented through the following technical solutions.

[0007] In a first aspect, a data storage method is provided, which is applied to a server, where a database is deployed; the database includes several first data tables stored in a persistent storage space on the server; and a second data table stored in a cache space on the server; the second data table is used to store incremental data to be written into the first data table; the method includes: in response to a change in metadata corresponding to a data table in the database independently maintained by the server, setting the second data table to an unmodifiable state, and writing the incremental data in the second data table to the first data table in the persistent storage space on the server; creating a new second data table corresponding to the changed metadata, and recording the newly acquired incremental data into the second data table.

[0008] Optionally, the server includes a metadata manager, which is used to maintain metadata corresponding to the data table in the database and an identifier of the metadata; the first data table stores an identifier of the metadata corresponding to the first data table; and the second data table stores an identifier of the metadata corresponding to the second data table.

[0009] Optionally, the metadata manager maintains metadata in the form of key-value pairs; wherein the key in the key-value pair is an identifier of the metadata, and the value in the key-value pair is the metadata.

[0010] Optionally, the database is a database using an LSM-Tree storage engine.

[0011] Optionally, in response to a change in the metadata corresponding to the data table in the database independently maintained by the server, the second data table is set to an unmodifiable state, and before the incremental data in the second data table is written to the first data table in the persistent storage space on the server, the method further includes: determining whether any of the preset change conditions is met; if so, determining that the metadata corresponding to the data table in the database has changed; wherein the change condition includes at least one of the following: the metadata corresponding to the data table in the database maintained in the metadata manager has changed; the metadata corresponding to the acquired new incremental data is different from the metadata corresponding to the second data table.

[0012] Optionally, the metadata is used to interpret the data entries written into the data table; the method further includes: in response to obtaining a data query request, querying the target data entry from the several first data tables, and querying the metadata corresponding to the target data entry from the metadata manager based on the identifier of the metadata corresponding to the first data table where the target data entry is located, so as to interpret the target data entry.

[0013] Optionally, the method further includes: in response to a data table merging request for the plurality of first data tables, merging the plurality of first data tables into a target first data table.

[0014] Optionally, merging the several first data tables into a target first data table includes: obtaining the latest metadata from the metadata manager as target metadata based on an identifier of the metadata stored in each of the several first data tables; and storing each data entry in the several first data tables to a corresponding position in the target first data table according to the target metadata.

[0015] In a second aspect, a data storage device is provided, which includes: a first execution module for setting the second data table to an unmodifiable state in response to a change in metadata corresponding to a data table in the database independently maintained by the server, and writing the incremental data in the second data table to the first data table in the persistent storage space on the server; a second execution module for creating a new second data table corresponding to the changed metadata, and recording the newly acquired incremental data in the second data table.

[0016] In a third aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in the first aspect are implemented.

[0017] In a fourth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the program.

[0018] The server independently maintains the metadata corresponding to the data table in the database, and no longer saves the metadata in the data table. When the metadata changes, there is no need to update the metadata in the data table. By creating a new second data table corresponding to the changed metadata, the incremental data obtained after the metadata changes is stored. In this way, the changed metadata can take effect in real time while greatly reducing the storage space of the metadata, without affecting the data writing operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] FIG1 is a flow chart of a data storage method according to an exemplary embodiment of the present application;

[0020] FIG2 is a schematic diagram of data storage on a server side for implementing a data storage method, shown in an exemplary embodiment of the present application;

[0021] FIG3 is a schematic diagram of data storage on a server side for implementing a data storage method, shown in an exemplary embodiment of the present application;

[0022] FIG4 is a schematic diagram of a flow chart of a first data table merging operation shown in an exemplary embodiment of the present application;

[0023] FIG5 is a schematic structural diagram of a data storage device according to an exemplary embodiment of the present application;

[0024] FIG6 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0025] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0026] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0027] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0028] User data stored in a database can include data and metadata. Metadata, also known as data about the data, is used to explain the data. For structured user data, such as data recorded in a table structure, the metadata can include metadata used to explain basic information about the table structure, also known as table metadata. This table metadata can include metadata used to explain the following two types of information: basic table information (such as compression algorithm, encryption algorithm, data block size used for storage, and number of attributes); and basic attribute information (also known as column information) (such as column type, column subscript, and column default value).

[0029] It should be noted that the metadata changes described in this specification are mainly changes to metadata related to attributes.

[0030] The data filled in the table structure defined by the metadata is the data in the user data. The data cannot exist independently and needs to rely on the corresponding metadata for interpretation.

[0031] After defining a table structure, you can adjust it using predefined modification statements. This is called performing a metadata change on the table structure. For example, adding an attribute, deleting an attribute, modifying an attribute type, and so on are called changes to the attribute's basic information. Metadata changes create a new table structure. When metadata changes, different versions of metadata need to be used with different versions of data, which can cause the following problems: The new version of metadata may not be able to accurately interpret the old version of the data. For example, after deleting and then adding an attribute to the table structure, if the old version of the data is not rewritten in time when the attribute is deleted and added, using the new version of metadata to interpret the old version of the data may result in incorrect attribute interpretation. The old version of metadata also cannot interpret the new version of the data. For example, if an attribute is added to the table structure, the old version of the metadata does not contain the basic information of the added attribute, so it cannot interpret the new version of the data.

[0032] Regarding metadata changes, related technologies mainly adopt the following two methods: 1. Copy (COPY) method: Create a new table structure that is not visible to users with the new version of metadata, query the data in the original table structure and rewrite it into the new table structure, and replace the original table structure with the new table structure after the data is written. At the same time, the original table structure is deleted and the old version of the metadata is replaced with the new version of the metadata. The disadvantage of this solution is that for tables with large amounts of data, querying and writing data will take a lot of time. Before the data is written, the data will exist in both the original table structure and the new table structure, resulting in multiple redundant copies of data and increasing the demand for storage space; 2. Replace (INPLACE) method: Metadata changes are made based on the original table structure. Since the corresponding metadata is also stored in the data table used to store data, it is necessary to temporarily stop writing new data when making metadata changes. Wait until the metadata change is completed before continuing to write, which affects the write operation to the database and thus affects the business.

[0033] In view of this, this specification proposes a data storage method, in which a database is deployed on a server; the database includes several first data tables stored in a persistent storage space on the server; and a second data table stored in a cache space on the server; the second data table is used to store incremental data to be written to the first data table; and metadata corresponding to the data tables in the database is also independently maintained in the server.

[0034] During implementation, in response to a change in the metadata corresponding to the data table in the database independently maintained by the server, the second data table is set to an unmodifiable state, and the incremental data in the second data table is written to the first data table in the persistent storage space on the server; a new second data table corresponding to the changed metadata is created, and the newly acquired incremental data is recorded in the second data table.

[0035] In the above technical solution, the metadata corresponding to the data table in the database is independently maintained by the server, and the metadata is no longer saved in the data table. When the metadata changes, there is no need to update the metadata in the data table. By creating a new second data table corresponding to the changed metadata, the incremental data obtained after the metadata changes is stored, thereby greatly reducing the storage space of the metadata and enabling the changed metadata to take effect in real time without affecting the data writing operation.

[0036] In order to enable people skilled in the art to better understand the technical solutions in the present application, 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.

[0037] Please refer to Figure 1, which illustrates a data storage method provided in an embodiment of the present application. This method is applied to a server, where a database is deployed; the database includes several first data tables stored in a persistent storage space on the server; and second data tables stored in a cache space on the server; the second data tables are used to store incremental data to be written to the first data tables.

[0038] The server may be a server or server cluster for providing services to users, which is not specifically limited here.

[0039] The database deployed on the server can be diverse, for example, a key-value store database, a column store database, a document database, a graph database, etc. In one embodiment, the database deployed on the server in this specification is a database using a Log Structured Merge-Tree (LSM-Tree) storage engine.

[0040] As shown in FIG2 , the data stored in the database includes two parts, namely, a plurality of first data tables stored in the persistent storage space of the server and a second data table stored in the cache space of the server.

[0041] The persistent storage space of the server can specifically be a disk or a hard disk. The first data table in the persistent storage space of the server can be an internal ordered file, which can also be called a sorted string table (SSTable). The data stored in the first data table can be called baseline data. The baseline data can include a number of data entries, and the number of data entries can be interpreted by metadata corresponding to the version of the first data table.

[0042] The server's persistent storage space can store several first data tables, each corresponding to a version of metadata. Different first data tables can correspond to different versions of metadata, or they can correspond to the same version of metadata. As shown in Figure 2, the persistent storage space includes first data table 1, first data table 2, and first data table 3. First data table 1 and first data table 2 correspond to metadata of the same version A1, and first data table 3 corresponds to metadata of version A2.

[0043] The server's cache space can specifically be the server's memory. A second data table, also referred to as a memory table (MemTable), is stored in the server's cache space. The data stored in this second data table can be referred to as incremental data. Each incremental data entry can be a newly added data entry, which can be interpreted by metadata corresponding to the version of the second data table. As shown in FIG2 , the metadata version corresponding to the second data table is A2.

[0044] The server also independently maintains metadata corresponding to the database's data tables, which may include version management for the metadata. The metadata is used to interpret the data entries written to the data tables, and different versions of the metadata are used to interpret the data entries written to the corresponding data tables. The server can maintain metadata in a variety of ways, which are not specifically limited in this specification. For example, taking the metadata manager shown in Figure 2 as an example, the server includes a metadata manager, which is used to maintain metadata corresponding to the data tables in the database. After the server obtains the user's modification statement for the metadata, the metadata manager modifies the metadata and performs version management.

[0045] In the server as described above, the steps of the data storage method are as follows.

[0046] S110. In response to a change in metadata corresponding to a data table in the database independently maintained by the server, the second data table is set to an unmodifiable state, and incremental data in the second data table is written to the first data table in the persistent storage space on the server.

[0047] When the server obtains the incremental data, it can write the incremental data into the second data table in the cache. At this time, the second data table is in a modifiable state and can be called a modifiable second data table.

[0048] In the process of acquiring incremental data, the server can monitor whether the metadata corresponding to the data table in the database has changed.

[0049] If the server determines that the metadata corresponding to the data table in the database has not changed, then when the incremental data in the current second data table reaches the preset data volume threshold, the second data table can be set to an unmodifiable state, becoming an unmodifiable second data table as shown in Figure 2, and then the incremental data in the unmodifiable second data table is written to the persistent storage space of the server to become baseline data.

[0050] If the server determines that the metadata corresponding to the data table in the database has changed, the second data table will be set to an unmodifiable state regardless of whether the incremental data in the second data table currently reaches the preset data volume threshold, and the incremental data in the unmodifiable second data table will be written to the server's persistent storage space as baseline data.

[0051] There are many ways to write the incremental data in the second data table to the persistent storage space of the server. For example, the entire second data table can be imported from the cache space into the persistent storage space to become a new first data table, and the new first data table corresponds to the same version of metadata as the second data table. Alternatively, the incremental data in the second data table can be written to a first data table in the persistent storage space that has the same version of metadata as the second data table. In one embodiment, it is possible to first query whether there is a first data table with the same version of metadata as the second data table in the persistent storage space; if not, a new first data table with the same version of metadata as the second data table is created in the persistent storage space, and then the incremental data in the second data table is written to the new first data table; if so, it is possible to query whether the baseline data in the first data table with the same version of metadata reaches a preset threshold; if not, the incremental data in the second data table is merged into the first data table with the same version of metadata; if the threshold is reached, a new first data table with the same version of metadata as the second data table is created in the persistent storage space, and then the incremental data in the second data table is written to the new first data table.

[0052] There are various ways for the server to determine whether the metadata corresponding to the data table in the database has changed. The server may preset multiple change conditions and determine whether any of the preset change conditions is met to determine whether the metadata corresponding to the data table in the database has changed; if so, it is determined that the metadata corresponding to the data table in the database has changed; wherein the change condition can be set according to actual needs and may include at least one of the following: the metadata corresponding to the data table in the database maintained in the metadata manager has changed; for example, the server may obtain a user's modification statement for the metadata; or obtain a modification statement for the attribute of the metadata; or, it may be a metadata change message obtained after the metadata manager completes the modification of the metadata, which may include an identifier of the changed metadata, etc.; the metadata corresponding to the obtained new incremental data is different from the metadata corresponding to the second data table; for example, the version of the metadata corresponding to the obtained new incremental data is different from the version of the metadata corresponding to the second data table; Alternatively, the identifier of the metadata corresponding to the newly acquired incremental data is different from the identifier of the metadata stored in the second data table; or, the metadata corresponding to the newly acquired incremental data is different from the basic information of any attribute in the metadata corresponding to the second data table; or, the number of attributes corresponding to the data entries included in the newly acquired incremental data is different from the number of attributes corresponding to the data entries in the incremental data stored in the second data table, etc.

[0053] It should be noted that the server determines whether the metadata corresponding to the data table in the database has changed. This can be for any change in the metadata; or it can be for changes only to metadata related to the attributes in the metadata; or it can be for changes only to metadata related to certain information about the attributes in the metadata. The certain information about the attributes can be set according to actual needs, such as the number of attributes, the order of attributes, etc. If only the metadata related to the attributes in the metadata has changed, then after determining that the metadata corresponding to the data table in the database has changed, the server also needs to determine whether this change is for metadata related to the attributes; if so, the second data table is set to an unmodifiable state, and the incremental data in the second data table is written to the first data table in the persistent storage space on the server; if not, the process continues as if the metadata has not changed.

[0054] S120: Create a new second data table corresponding to the changed metadata, and record the newly acquired incremental data in the second data table.

[0055] When the server sets the second data table to an unmodifiable state and writes the incremental data in the second data table to the first data table in the persistent storage space on the server, the server recreates a new second data table in the cache space. The new second data table corresponds to the changed metadata, that is, the new second data table corresponds to the version corresponding to the changed metadata. For example, after writing the incremental data in the second data table shown in Figure 2 to the first data table in the persistent storage space on the server, the version of the metadata corresponding to the new second data table created by the server in the cache space can be A3 or A1.

[0056] To facilitate metadata management, the metadata manager configures corresponding identifiers for different versions of metadata. The metadata manager maintains metadata corresponding to data tables in the database and the metadata's corresponding identifiers. The identifier configured by the metadata manager for each metadata can be a unique identifier. Specifically, each metadata identifier can be derived based on its corresponding version number, for example, by concatenating a table unique identifier and the metadata version number.

[0057] When the server obtains the user's modification statement for metadata, the metadata manager can modify the metadata and determine whether a new identifier needs to be configured.

[0058] It should be noted that the metadata manager can also provide concurrent locks to prevent concurrent modification problems caused by multiple threads operating on the same key-value pair; in addition, frequently accessed key-value pairs can be cached in the cache space to reduce disk reads and writes caused by metadata access.

[0059] Accordingly, to indicate the correspondence between each data table and metadata, the first data table may store an identifier for the metadata corresponding to the first data table; and the second data table may store an identifier for the metadata corresponding to the second data table. As shown in Figure 3, the identifier aA1 is stored in the first data table 1 and the second data table 2, indicating that the metadata of the first data table 1 and the first data table 2 correspond to version A1; the identifier aA2 is stored in the first data table 3, indicating that the metadata of the first data table 3 corresponds to version A2; and the identifier aA2 is stored in the second data table, indicating that the metadata of the second data table corresponds to version A2.

[0060] The server can query the metadata manager for metadata corresponding to each data table according to the identifier of the metadata stored in each data table.

[0061] The metadata manager can maintain metadata corresponding to the data table in the database and the identifier of the metadata in a variety of ways, which are not specifically limited in this specification. For example, metadata can be maintained in the form of key-value pairs, that is, a key-value storage engine is used to store metadata, and the key-value pair can be expressed as "metadata identifier, metadata"; wherein the key in the key-value pair is the identifier of the metadata, and the value in the key-value pair is the metadata; a corresponding relationship table between each metadata and identifier can also be maintained in the metadata manager. As shown in Figure 3, the key-value pairs maintained by the metadata manager may include "key = aA1, value = metadata B1" and "key = aA2, value = metadata B2". Then, the server can query the metadata B1 corresponding to aA1, that is, the metadata of version A1, from the metadata manager based on the identifier aA1 stored in the data table; and query the metadata B2 corresponding to aA2, that is, the metadata of version A2, from the metadata manager based on the identifier aA2 stored in the data table.

[0062] In the embodiment of the present application, the server independently maintains the metadata corresponding to the data table in the database, and no longer saves the metadata in the data table. When the metadata changes, there is no need to suspend the write operation to update the metadata in the data table. By creating a new second data table corresponding to the changed metadata, the incremental data obtained after the metadata changes is stored. In this way, the changed metadata can take effect in real time while greatly reducing the storage space of the metadata, without affecting the data write operation.

[0063] Based on the above embodiment, when it is necessary to query data from a database, a data query request may be sent to a server. The method further includes: in response to receiving the data query request, the server may query the plurality of first data tables to determine whether a target data entry corresponding to the data query request exists; if so, read the identifier of the target data entry and metadata corresponding to the first data table from the first data table where the target data entry resides, and query the metadata manager for metadata corresponding to the target data entry based on the identifier of the metadata corresponding to the first data table where the target data entry resides, so as to interpret the target data entry. A query result obtained based on the target data entry and the corresponding metadata may be provided to the user, for example, a table structure populated with the target data entry.

[0064] It should be noted that, in response to obtaining a data query request, the server may first query in the second data table whether there is a target data entry corresponding to the data query request before querying from the several first data tables whether there is a target data entry corresponding to the data query request; if not, then query from the several first data tables whether there is a target data entry corresponding to the data query request; if so, then read the target data entry and the identifier of the metadata corresponding to the second data table from the second data table, and query the metadata corresponding to the target data entry from the metadata manager based on the identifier of the metadata corresponding to the second data table, so as to interpret the target data entry.

[0065] The metadata manager can greatly reduce the storage space of metadata and accurately query the metadata of each version corresponding to the data entry, so that each data entry can be accurately interpreted.

[0066] Based on the above embodiment, in order to reduce the storage space requirements caused by the increasing number of first data tables in the persistent storage space and the amount of data stored therein, a merge operation can be periodically performed on the multiple first data tables in the persistent storage space. In response to a data table merge request for the multiple first data tables, the server merges the multiple first data tables into a target first data table. The merge operation process can be as follows.

[0067] The server determines several first data tables that need to be merged based on the data table merge request. The first data tables that need to be merged can be some specified first data tables among all the first data tables in the persistent storage space, or can be several first data tables that are most recently generated in the persistent storage space.

[0068] After determining the first data tables that need to be merged, the server traverses all the first data tables to be merged, reads the metadata identifiers stored in each first data table, and then obtains the latest metadata from the metadata manager based on the metadata identifiers stored in each first data table as the target metadata. The latest metadata can refer to the latest metadata among the metadata corresponding to the metadata identifiers stored in the first data tables, or can refer to the latest metadata among all versions of metadata in the metadata manager. For example, as shown in FIG4 , if the first data tables to be merged include first data table 1, first data table 2, and first data table 3, wherein the metadata stored in first data table 1 and second data table 2 are identified as aA1, and the metadata stored in first data table 3 are identified as aA2, the metadata corresponding to aA1 queried from the metadata manager is metadata of version A1, and the metadata corresponding to aA2 is metadata of version A2. If the latest metadata in the metadata manager is version A2, the metadata of version A2 is used as the target metadata, and the identifier of the metadata stored in the generated target first data table is aA2, as shown in Figure 4; if the latest metadata in the metadata manager is version A3, the metadata of version A3 is used as the target metadata, and the identifier of the metadata stored in the generated target first data table is aA3.

[0069] After the server determines the target metadata, it can store each data entry in the plurality of first data tables in a corresponding location in the target first data table according to the target metadata. As shown in FIG4 , the server can first read the data stored in each first data table according to the metadata corresponding to each first data table, wherein the data stored in each first data table includes a plurality of data entries; then, the data in the data entries read from each first data table can be projected according to the target metadata, and adjusted to data that conforms to the target metadata, that is, adjusted to data that can be interpreted by the target metadata; after the data adjustment is completed, the adjusted data can be written to the generated target first data table according to a preset sorting rule, and an identifier corresponding to the target metadata can be saved in the target first data table.

[0070] The data read from each first data table is adjusted according to the target metadata. The specific adjustment method may include: if any attribute existing in the metadata corresponding to the first data table does not exist in the target metadata, the data corresponding to the any attribute in each data entry of the data read from the first data table is discarded; if any attribute in the target metadata does not exist in the metadata corresponding to the first data table, the position of the data corresponding to the any attribute is added to each data entry read from the first data table and filled with a default value corresponding to the any attribute; if the basic information of any attribute in the metadata corresponding to the first data table is different from that in the target metadata, the data corresponding to the any attribute in each data entry of the data read from the first data table is adjusted according to the basic information of the any attribute in the target metadata.

[0071] It should be noted that as the metadata is constantly changed, the metadata stored in the metadata manager will become more and more. For this reason, the metadata manager can also provide a set of periodic metadata recycling mechanisms, that is, regular cleaning. For example, it can be determined whether to clean up based on the correspondence between each metadata and the first data table and the life cycle of the metadata. The identifiers of the metadata stored in all the first data tables in the persistent storage space can be traversed regularly, and the metadata corresponding to the identifiers of the metadata that do not exist in the metadata manager during the traversal process can be cleaned up. The metadata that needs to be cleaned up can also be required to meet the condition that the existence time has exceeded the preset life cycle.

[0072] By merging several first data tables in the persistent storage space, part of the storage space can be released, reducing the storage pressure on the persistent storage space. In addition, the data in the several first data tables can be adjusted to data that conforms to the latest metadata through the merging operation, thereby realizing data integration.

[0073] It should be noted that a single table structure can be divided into multiple partitions, with different partitions corresponding to their respective first data tables, second data tables, and metadata. Depending on how the partitions are divided, different partitions can correspond to different metadata or the same metadata. If different partitions correspond to the same metadata, the same key-value pairs can be used in the metadata manager, significantly reducing metadata duplication and storage requirements.

[0074] Corresponding to the aforementioned embodiments of the data storage method, the present application also provides embodiments of a data storage device.

[0075] As shown in FIG5 , the data storage device includes: a first execution module 501 and a second execution module 502 .

[0076] The first execution module 501 is used to set the second data table to an unmodifiable state in response to a change in the metadata corresponding to the data table in the database independently maintained by the server, and write the incremental data in the second data table to the first data table in the persistent storage space on the server; the second execution module 502 is used to create a new second data table corresponding to the changed metadata, and record the newly acquired incremental data in the second data table.

[0077] Optionally, the server includes a metadata manager, which is used to maintain metadata corresponding to the data table in the database and an identifier of the metadata; the first data table stores an identifier of the metadata corresponding to the first data table; and the second data table stores an identifier of the metadata corresponding to the second data table.

[0078] Optionally, the metadata manager maintains metadata in the form of key-value pairs; wherein the key in the key-value pair is an identifier of the metadata, and the value in the key-value pair is the metadata.

[0079] Optionally, the database is a database using an LSM-Tree storage engine.

[0080] Optionally, the first execution module 501 is also used to: determine whether any of the preset change conditions is met; if so, determine that the metadata corresponding to the data table in the database has changed; wherein the change condition includes at least one of the following: the metadata corresponding to the data table in the database maintained in the metadata manager has changed; the metadata corresponding to the new incremental data obtained is different from the metadata corresponding to the second data table.

[0081] In the embodiment of the present application, the server independently maintains the metadata corresponding to the data table in the database, and no longer saves the metadata in the data table. When the metadata changes, there is no need to suspend the write operation to update the metadata in the data table. By creating a new second data table corresponding to the changed metadata, the incremental data obtained after the metadata changes is stored. In this way, the changed metadata can take effect in real time while greatly reducing the storage space of the metadata, without affecting the data write operation.

[0082] Optionally, the metadata is used to interpret the data entries written into the data table; the first execution module 501 is also used to: in response to obtaining a data query request, query the target data entry from the several first data tables, and query the metadata corresponding to the target data entry from the metadata manager according to the identifier of the metadata corresponding to the first data table where the target data entry is located, so as to interpret the target data entry.

[0083] The metadata manager can greatly reduce the storage space of metadata and accurately query the metadata of each version corresponding to the data entry, so that each data entry can be accurately interpreted.

[0084] Optionally, the first execution module 501 is further configured to: in response to a data table merging request for the plurality of first data tables, merge the plurality of first data tables into a target first data table.

[0085] Optionally, the first execution module 501 is further configured to: acquire the latest metadata from the metadata manager according to an identifier of the metadata stored in each of the plurality of first data tables as target metadata;

[0086] According to the target metadata, each data entry in the plurality of first data tables is stored in a corresponding position in the target first data table.

[0087] By merging several first data tables in the persistent storage space, part of the storage space can be released, reducing the storage pressure on the persistent storage space. In addition, the data in the several first data tables can be adjusted to data that conforms to the latest metadata through the merging operation, thereby realizing data integration.

[0088] The embodiments of the data storage device of the present application can be applied to electronic devices. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the electronic device in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for execution. From the hardware level, as shown in Figure 6, it is a hardware structure diagram of the electronic device in which the data storage device of the present application is located. In addition to the processor, memory, network interface, and non-volatile memory shown in Figure 6, the electronic device in which the device is located in the embodiment can generally include other hardware according to the actual function of the electronic device, which will not be described in detail.

[0089] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0090] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0091] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of the data storage method described above are implemented and the same technical effects can be achieved. To avoid repetition, they will not be described here.

[0092] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0093] Embodiments of the subject matter and functional operations described in this specification may be implemented in the following: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. Embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier to be executed by a data processing device or to control the operation of the data processing device. Alternatively or additionally, the program instructions may be encoded on an artificially generated propagation signal, such as a machine-generated electrical, optical, or electromagnetic signal, which is generated to encode information and transmit it to a suitable receiver device for execution by the data processing device. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them.

[0094] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform the corresponding functions by operating on input data and generating output. The processes and logic flows can also be performed by, and apparatus can be implemented as, special purpose logic circuitry, such as an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit).

[0095] Computers suitable for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, or the computer will be operably coupled to such mass storage devices to receive data from them or to transmit data to them, or both. However, a computer does not necessarily have such devices. In addition, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.

[0096] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and storage devices, including, for example, semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD ROM and DVD-ROM disks. The processor and memory can be supplemented by, or incorporated in, special purpose logic circuitry.

[0097] Although this specification includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of specific embodiments of specific inventions. Certain features described in multiple embodiments within this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may work in certain combinations as described above and even initially claimed as such, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of the sub-combination.

[0098] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.

[0099] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the particular order shown or sequential sequence to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0100] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A data storage method, characterized in that: Applied to a server, a database is deployed on the server; the database includes a plurality of first data tables stored in a persistent storage space on the server; and, a second data table stored in a cache space on the server; The second data table is used to store incremental data to be written into the first data table; the method comprises: In response to a change in metadata independently maintained by the server and corresponding to a data table in the database, setting the second data table to an unmodifiable state, and writing incremental data in the second data table to a first data table in a persistent storage space on the server; A new second data table corresponding to the changed metadata is created, and the newly acquired incremental data is recorded in the second data table.

2. The method according to claim 1, characterized in that: The server includes a metadata manager, which is used to maintain metadata corresponding to the data table in the database and an identifier of the metadata; The first data table stores an identifier of metadata corresponding to the first data table; The second data table stores an identifier of metadata corresponding to the second data table.

3. The method according to claim 2, characterized in that The metadata manager maintains metadata in the form of key-value pairs; wherein the key in the key-value pair is an identifier of the metadata, and the value in the key-value pair is the metadata.

4. The method according to claim 1, characterized in that: The database is a database using the LSM-Tree storage engine.

5. The method according to claim 2, characterized in that: In response to a change in metadata independently maintained by the server and corresponding to a data table in the database, setting the second data table to an unmodifiable state and before writing incremental data in the second data table to the first data table in the persistent storage space on the server, the method further includes: Determining whether any of the preset change conditions is satisfied; if yes, determining that the metadata corresponding to the data table in the database is changed; The change condition includes at least one of the following: The metadata corresponding to the data table in the database maintained in the metadata manager changes; The metadata corresponding to the acquired new incremental data is different from the metadata corresponding to the second data table.

6. The method according to claim 2, characterized in that The metadata is used to interpret the data entries written into the data table; the method further includes: In response to obtaining the data query request, query the target data entry from the plurality of first data tables, and The identifier of the metadata corresponding to the first data table where the target data entry is located is queried from the metadata manager to obtain the metadata corresponding to the target data entry, so as to interpret the target data entry.

7. The method according to claim 2, characterized in that: The method further comprises: In response to a data table merging request for the plurality of first data tables, the plurality of first data tables are merged into a target first data table.

8. The method according to claim 7, characterized in that The step of merging the plurality of first data tables into a target first data table includes: According to the identifier of the metadata stored in each of the plurality of first data tables, acquiring the latest metadata from the metadata manager as the target metadata; According to the target metadata, each data entry in the plurality of first data tables is stored in a corresponding position in the target first data table.

9. A data storage device, characterized in that: The device comprises: A first execution module, configured to, in response to a change in metadata independently maintained by the server and corresponding to a data table in the database, set the second data table to an unmodifiable state, and write incremental data in the second data table to the first data table in the persistent storage space on the server; The second execution module is used to create a new second data table corresponding to the changed metadata, and record the newly acquired incremental data in the second data table.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

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

Citation Information

Patent Citations

  • Distributed storage system and storage method thereof

    CN111506253A

  • Data playback method and device, computer equipment and storage medium

    CN113901057A

  • Metadata management method and device in storage system and storage system

    CN114625713A

  • Data storage method and device and electronic equipment

    CN116383195A

  • Disk usage growth prediction system

    US20200192572A1