Method for implementing shard seamless expansion on basis of replication
By adopting the replication-based Shard imperceptible expansion method in the CEPH object storage system, the problem of Shard inoperability during expansion is solved, user-insensitive expansion and data consistency are achieved, and user experience and read and write performance are improved.
Patent Information
- Application Number
- PCT/CN2023/142695
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-13
- Filing Date
- 2023-12-28
- Publication Date
- 2024-10-17
AI Technical Summary
In the CEPH object storage system, uploading, deleting, and metadata modification operations cannot be performed during Shard expansion, which affects the user experience, and the expansion time is long, affecting read and write performance.
Adopt the replication-based Shard senseless expansion method by creating new bucket instances, rebalancing data, using errorlog to record concurrent operation failures, performing full comparisons to ensure data consistency, allowing users to operate during the expansion process, synchronizing and consuming errorlogs in the background.
It allows users to delete, upload, and modify metadata records during the Shard expansion process, improving user experience, reducing errorlog records, ensuring data consistency, and improving read and write performance.
Smart Images

Figure CN2023142695_17102024_PF_FP_ABST
Abstract
Description
A Shard-less Expansion Method Based on Replication Technical Field
[0001] The present invention belongs to the field of computer storage technology, and in particular relates to a method for realizing Shard seamless expansion based on replication. Background Art
[0002] CEPH is currently the most widely used distributed storage system, capable of providing read and write services through parallel processing on multiple servers. CEPH boasts excellent scalability and reliability, and its applications include block storage (RBD, Rados Block Device), file storage (CephFS, Ceph file system), and object storage (RADOSGW, Reliable Autonomic Distributed Object Storage Gateway). CEPH's object storage uses a data and metadata separation approach when providing read and write services. Data is generally stored in the data storage pool, and metadata is stored in the index storage pool. When using object storage for data read and write, users upload or download data files to their corresponding buckets through REST API requests. Buckets store metadata (index data) in the bucket's shards. When a user stores too many objects in a bucket, the bucket's shards may become overloaded with indexes, impacting read and write performance. Shard expansion is necessary to reduce the number of metadata entries per shard.
[0003] Currently, CEPH supports two methods to modify the number of shards in a bucket: dynamic resharding and static resharding. Dynamic resharding means that after a user uploads an object to object storage, the object storage will first determine whether the number of metadata on the shard exceeds the preset maximum number of metadata before storing the metadata in the bucket. If it does, the reshard task will be added to the queue, and then resharding will be triggered by a background scheduled task to reduce the number of metadata on the shard. Static resharding, on the other hand, means resharding by issuing the radosgw-admin command through the monitor node of the cluster. This has the advantage of manually controlling the resharding time and the specific number of shards after resharding.
[0004] However, there is a problem with both dynamic and static resharding: the shard of the bucket cannot be operated during the reshard expansion, resulting in users being unable to upload, delete, or perform other operations involving object metadata modification during the bucket reshard period. When the number of metadata records in the user's bucket is too large, the shard expansion time is very long, which will seriously affect the user experience. Therefore, the need to design a method for seamless shard expansion is becoming increasingly urgent.
[0005] Summary of the Invention
[0006] The purpose of the present invention is to provide a method for realizing Shard seamless expansion based on replication, aiming to solve the problems raised in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solutions:
[0008] A method for implementing Shard seamless expansion based on replication includes the following steps:
[0009] Step S1: Create a new bucket instance for the bucket that needs to be resharded and start preparing for reshard expansion;
[0010] Step S2: Set the bucket status to Resharding, indicating that the bucket in step S1 has started the Reshard operation;
[0011] Step S3: Add the ID of the newly created bucket instance to the bucket information, indicating that if the user uploads or deletes data later, the new bucket instance needs to be operated synchronously;
[0012] Step S4: Traverse each shard of the old bucket and rebalance the data on the shard to the new bucket shard instance;
[0013] Step S5: Traverse the error log and query the reshard process. Find any operations that failed on the new bucket shard due to concurrent data synchronization from the old shard to the new shard, and re-synchronize and apply them to the new bucket shard.
[0014] Step S6: Use a full comparison tool to ensure data consistency between the new shard and the old shard.
[0015] Step S7: Delete the old bucket shard to complete the seamless expansion of the bucket.
[0016] As a preferred solution of the present invention, in step S4, the data is balanced to the new bucket shard instance through a hash algorithm.
[0017] As a preferred solution of the present invention, it further includes adding a data structure, wherein the added data structure is new_bucket_instance_id and errorlog.
[0018] As a preferred solution of the present invention, the new_bucket_instance_id is used to mark the newly generated bucket id in the Reshard process.
[0019] As a preferred solution of the present invention, the errorlog is used to record the success of the operation on the original Shard and the failure of the operation on the new Shard during the Reshard process, and synchronously update the records to the new Shard.
[0020] As a preferred solution of the present invention, the structure of the errorlog is:
[0021] As a preferred solution of the present invention, in step S5, the business process and Reshard will be concurrent, causing the two processes to overlap each other, and then modification is performed. The specific steps of modification include adding metadata records, modifying metadata records, deleting metadata records, errorlog records and consumption, and full comparison.
[0022] As a preferred solution of the present invention, the steps of recording the newly added metadata are as follows:
[0023] I. When a new object is uploaded during the Reshard process, the Reshard entry is obtained at time t1, written to the old bucket shard at time t2, and written to the new bucket shard at time t3;
[0024] Ⅱ. If writing fails, it will be recorded in the errorlog and background synchronization will be performed through the errorlog.
[0025] As a preferred solution of the present invention, the modified metadata is recorded as follows:
[0026] Ⅰ. During the resharding process, metadata modification operations are performed. First, the index on the original shard is updated, then the index on the original shard is read and synchronized to the new shard.
[0027] Ⅱ. If synchronization fails, it needs to be recorded in the errorlog and synchronized later.
[0028] As a preferred solution of the present invention, the full comparison is used to ensure strong consistency of data. The full comparison is performed twice.
[0029] Compared with the prior art, the present invention has the following beneficial effects:
[0030] 1. The present invention can allow users to delete, upload, and modify metadata records during the Shard expansion process, so that Shard expansion can be performed in the background without affecting user business, and can improve user read and write performance after the Shard expansion is completed.
[0031] 2. In the scenario where users modify index metadata, the present invention uses errorlog to save the index records of the new Shard operation and performs background consumption to ensure data consistency. A Sharding_status is added to the metadata of each object to indicate whether the object is being synchronized. If it is being synchronized, index modification, deletion, or deletion operations are not allowed, reducing the number of records in the errorlog.
[0032] 3. In order to ensure strong data consistency in the present invention, a full comparison is required before Reshard is completed to ensure that the data on the new Shard is completely consistent with the original Shard. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0034] FIG1 is an overall flow chart of a method for realizing Shard senseless expansion based on replication according to the present invention;
[0035] FIG2 is a flowchart of Reshard replication in a method for realizing Shard seamless expansion based on replication according to the present invention;
[0036] FIG3 is a schematic diagram of the timing of newly added metadata records in a method for realizing Shard seamless expansion based on replication according to the present invention;
[0037] FIG4 is a flowchart of modifying metadata records in a Shard senseless expansion method based on replication according to the present invention;
[0038] FIG5 is a timing diagram of Reshard modification in a Shard senseless expansion method based on replication according to the present invention;
[0039] FIG6 is a deletion flowchart of a method for realizing Shard senseless expansion based on replication according to the present invention;
[0040] FIG7 is a timing diagram of deleting metadata records in a Shard senseless expansion method based on replication according to the present invention;
[0041] FIG8 is a flowchart of errorlog background consumption in a Shard senseless expansion method based on replication of the present invention;
[0042] FIG9 is a flowchart of full comparison in a method for realizing Shard seamless expansion based on replication according to the present invention. DETAILED DESCRIPTION
[0043] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0044] Example 1
[0045] Please refer to Figures 1 to 9. The present invention provides the following technical solutions:
[0046] A method for implementing Shard seamless expansion based on replication includes the following steps:
[0047] Step S1: Create a new bucket instance for the bucket that needs to be resharded and start preparing for reshard expansion;
[0048] Step S2: Set the bucket status to Resharding, indicating that the bucket in step S1 has started the Reshard operation;
[0049] Step S3: Add the ID of the newly created bucket instance to the bucket information, indicating that if the user uploads or deletes data later, the new bucket instance needs to be operated synchronously;
[0050] Step S4: Traverse each shard of the old bucket and rebalance the data on the shard to the new bucket shard instance;
[0051] Step S5: Traverse the error log and query the reshard process. Find any operations that failed on the new bucket shard due to concurrent data synchronization from the old shard to the new shard, and re-synchronize and apply them to the new bucket shard.
[0052] Step S6: Use a full comparison tool to ensure data consistency between the new shard and the old shard.
[0053] Step S7: Delete the old bucket shard to complete the seamless expansion of the bucket.
[0054] In a specific embodiment of the present invention, a replication-based Shard seamless expansion method is proposed to address the problem that during the Shard expansion of a bucket in CEPH object storage, the data on the Shard cannot be modified, resulting in users being unable to upload or delete the bucket. This method allows users to upload and delete objects simultaneously during the Shard expansion, improving the user experience of the product. After resharding, the number of index entries on each shard in the user's bucket can be reduced, thereby improving the speed of users' reading, writing, or deletion operations.
[0055] Specifically, the main process of the present invention is shown in Figure 1. When expanding Shard capacity, it is first necessary to create a bucket instance and set the Resharding bucket status to Rsharding, indicating that the bucket is undergoing Resharding operation; a new flag bit - new_bucket_instance_id is added to bucket info, indicating that if the user performs upload and download operations at this time, the bucket instance needs to be operated synchronously at the same time; during the Reshard process, the metadata on the original bucket Shard needs to be migrated. During the migration process, if the metadata record exists on the new bucket Shard, the metadata on the original bucket Shard will not be overwritten, and if the user fails to upload or download the new bucket instance during the migration process, the corresponding information will be recorded in the errorlog; during the migration process, the metadata record in the errorlog on the new bucket Shard needs to be synchronized, and the Resharding bucket status is changed to Complete; finally, the new_bucket_instance_id in bucket info is changed to the new bucket instance id, and the old bucket instance is deleted to complete the seamless Reshard expansion;
[0056] The main data structures added in this invention are: (1) new_bucket_instance_id, which marks the newly generated bucket id during the reshard process; (2) errorlog, which mainly records the records of successful operations on the original shard but failed operations on the new shard during the reshard process. Therefore, the background thread needs to synchronize these operations to the new shard; at the same time, in order to ensure strong data consistency, after all index data is migrated to reshard, it is necessary to perform a full comparison of the indexes on the original shard and the new shard, and then update the bucket id (rgw_link_bucket);
[0057] The errorlog structure is as follows (ErrorOmapKey):
[0058] OMAP<string,errorkey>
[0059] The key is a string, and the key is the currently obtained timestamp. The time when the operation on the new Shard failed can be obtained through the key value. The structure of errorkey is:
[0060] The errorkey mainly records the bucket_name, shard_id, and corresponding obj_key of the failed operation. Due to issues such as multiple versions, multiple obj_keys may exist in the same operation. These different obj_keys are a transaction operation and must ensure consistency. There are two types of op_type: one is set, which means reading the corresponding obj from the original shard and then synchronizing it to the new shard; the other is delete, which means deleting the corresponding obj from the new shard.
[0061] Specifically, as shown in Figure 2, if the current bucket is resharding, writing the bucket index will no longer be blocked and will become a double write. That is, the original shard is written first, and then the new shard is written. The subsequent process will not proceed until both are written successfully. Writing to the shard includes modifying the omap header, adding the omap key, and deleting the omap key. The business process includes uploading objects, deleting objects, and modifying object attributes.
[0062] Due to the concurrency of business processes and Reshard, there may be a problem of two processes overlapping each other for the same omapkey. To modify the process specifically:
[0063] (1) Add metadata records
[0064] As shown in Figure 3, if a new object is uploaded during the resharding process, the reshard entry is obtained at time t1, written to the old bucket shard at time t2, and written to the new bucket shard at time t3. If the write fails, it is recorded in the error log and synchronized in the background through the error log. In this scenario, whether the write process or the reshard process writes the entry first will not affect the data and will not cause data inconsistency.
[0065] (2) Modify metadata records
[0066] As shown in Figure 4, during the resharding process, metadata modification operations first require updating the index on the original shard, then reading the index on the original shard and synchronizing it to the new shard. If the synchronization fails, it needs to be recorded in the error log and synchronized later.
[0067] As shown in Figure 5, in the following scenario, at time t1, the reshard retrieves the entry, at time t2, the write process updates the old shard, at time t3, the write process writes to the new shard, and at time t4, the reshard process synchronizes the old entry with the same key to the new shard, overwriting the original entry. In this case, the metadata record is directly read from the old shard, modified, and written to the new shard. During the reshard process, if an entry with the same key already exists in the new shard, the key is ignored.
[0068] (3) Deleting metadata records
[0069] As shown in Figure 6, during the resharding process, the deletion process, when a request to delete an object is made simultaneously, first deletes the index metadata on the original shard, then deletes the index metadata on the new shard. If the deletion of the index metadata on the new shard fails, an error log is recorded; if the deletion of the index metadata on the original shard succeeds, a success message is returned; otherwise, a failure message is returned.
[0070] As shown in Figure 7, a deletion operation is performed during the resharding process. This may result in the same situation as modifying metadata records: the user request succeeds, but the metadata is not deleted, that is, the object is not deleted successfully. To address this situation, the redundant index metadata on the new shard is deleted through a subsequent full comparison.
[0071] (4) Errorlog recording and consumption
[0072] As shown in Figure 8, error logs are primarily recorded in new rados objects in the log pool. During upload, modification, and deletion, double writing is performed: first writing to the original shard, then writing to the new shard. If writing to the original shard succeeds but writing to the new shard fails, the bucket_name and shard_id of the original shard, as well as the key value of the index metadata for the operation, are required. Error logs are consumed by background threads. When the cluster is started, a separate error log consumption thread is established, and the background synchronizes the index of the error log records. It is worth noting that when retrieving the error log, it must be locked to prevent multiple threads from synchronizing the same record.
[0073] (5) Full comparison tool
[0074] The main purpose of full comparison is to ensure strong data consistency and to provide a safety net for problems that may arise during the resharding process. There are two main full comparisons: (1) Compare the new Shard with the original Shard. First, list all index metadata on the original Shard. If there are some index metadata on the original Shard but not on the new Shard, synchronize the index metadata on the original Shard to the new Shard; (2) Compare the index data on the original Shard with the new Shard. If there are some index metadata on the new Shard but not on the original Shard, delete the index data on the new Shard.
[0075] Specifically, the present invention is applicable to object storage services developed based on CEPH. Too many objects in an object storage bucket will affect the user's read and write performance, and Shard expansion is required. This method can achieve user-unaware Shard expansion. It can allow users to delete, upload, and modify metadata records during the Shard expansion process, so that Shard expansion can be performed in the background without affecting user services. After the Shard expansion is completed, the user's read and write performance can be improved. For scenarios where users modify index metadata, the errorlog is used to save the index records of the new Shard and perform background consumption to ensure data consistency. A Sharding_status is added to the metadata of each object to indicate whether the object is being synchronized. If it is being synchronized, index modification, deletion, or deletion operations are not allowed, thereby reducing the number of records in the errorlog. In order to ensure strong data consistency, a full comparison is required before Reshard is completed to ensure that the data on the new Shard is completely consistent with the data on the original Shard.
[0076] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art will be able to modify the technical solutions described in the aforementioned embodiments or substitute equivalents for some of the technical features. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for realizing Shard seamless expansion based on replication, characterized in that: The steps include: Step S1: Create a new bucket instance for the bucket that needs to be resharded, and start preparing for reshard expansion; Step S2: Set the bucket status to Resharding, indicating that the bucket in step S1 has started the Reshard operation; Step S3: Add the ID of the newly created bucket instance to the bucket information, indicating that if the user uploads or deletes data afterwards, the new bucket instance needs to be operated synchronously; Step S4: traverse each shard of the old bucket and rebalance the data on the shard to the new bucket shard instance; Step S5: Traverse the error log and query the reshard process. The operation that caused the user operation to fail on the new bucket shard due to concurrent data synchronization from the old shard to the new shard is resynchronized and applied to the new bucket shard. Step S6: Use a full comparison tool to ensure data consistency between the new shard and the old shard; Step S7: Delete the old bucket shard to complete the seamless expansion of the bucket.
2. According to the method for realizing Shard seamless expansion based on replication according to claim 1, it is characterized in that: In step S4, the data is balanced to the new bucket shard instance through a hash algorithm.
3. According to the method for realizing Shard seamless expansion based on replication according to claim 2, it is characterized in that: It also includes adding data structures, where the added data structures are new_bucket_instance_id and errorlog.
4. According to the method for realizing Shard seamless expansion based on replication according to claim 3, it is characterized in that: The new_bucket_instance_id is used to mark the newly generated bucket id in the Reshard process.
5. According to the method for realizing Shard capacity expansion without feeling based on replication according to claim 4, it is characterized in that: The errorlog is used to record the success of the operation on the original shard and the failure of the operation on the new shard during the reshard process, and is updated synchronously to the new shard.
6. According to the method for realizing Shard seamless expansion based on replication according to claim 5, it is characterized in that: The structure of the errorlog is:
7. According to claim 6, a method for realizing Shard seamless expansion based on replication is characterized in that: In step S5, the business process and Reshard will be concurrent, causing the two processes to overlap each other, so they are modified. The specific steps of modification include adding metadata records, modifying metadata records, deleting metadata records, errorlog records and consumption, and full comparison.
8. According to claim 7, a method for realizing Shard capacity expansion without feeling based on replication is characterized in that: The steps for adding metadata recording are as follows: Ⅰ. When a new object is uploaded during the Reshard process, the Reshard entry is obtained at time t1, the old bucket shard is written at time t2, and the new bucket shard is written at time t3; Ⅱ. When writing fails, it is recorded in the errorlog and background synchronization is performed through the errorlog.
9. According to claim 8, a method for realizing Shard seamless expansion based on replication is characterized in that: The modified metadata is recorded as follows: Ⅰ. Perform metadata modification operations during the Reshard process. First, update the index on the original Shard, then read the index on the original Shard and synchronize it to the new Shard. Ⅱ. When synchronization fails, it needs to be recorded in errorlog and synchronized later.
10. According to the method for realizing Shard seamless expansion based on replication in claim 9, it is characterized in that the full comparison is used to ensure strong consistency of data, and the full comparison is performed twice.
Citation Information
Patent Citations
Storage capacity expansion method, device and equipment and readable storage medium
CN111159296A
Database expansion method and device, electronic equipment and machine readable storage medium
CN111400273A
Non-inductive capacity expansion method and system for FLASH, storage medium and terminal
CN111459419A
Automatic cloud backup execution method based on backup task
CN112035297A
Online capacity expansion method for mass object storage
CN112181309A
