xiaoyuyao commented on a change in pull request #1504: URL: https://github.com/apache/ozone/pull/1504#discussion_r524416640
########## File path: hadoop-hdds/docs/content/design/truncate.md ########## @@ -0,0 +1,146 @@ +--- +title: Truncate +summary: Truncate the tail of some key. +date: 2020-10-16 +jira: HDDS-4239 +status: implementing +author: runzhiwang +--- +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. See accompanying LICENSE file. +--> + + +# Abstract + +This is a proposal to introduce truncate operation for Ozone, which will allow removing data from the tail of a file. + +The use cases for truncate include +1. Transaction, journal handling for external systems. Transactions are appended to a Ozone file while they succeed. When a transaction fails it is aborted and the file is truncated, which rolls it back to the previous successful transaction. +2. Ability to truncate incomplete data added to the file as a result of a failed write. This particularly enables users to reuse the same files after a failed create or append. +3. Allow users to remove data they accidentally appended. +4. Improved support for FUSE and NFSv3 connectors to Ozone. + +In proposed approach `truncate` is performed only on a closed key. If the key is opened for write, an attempt to truncate fails. + +# Implementation + +## Timing diagram + +This timing diagram omit the delete block between SCM and Datanode. + + +## OM + +When OM receives `truncate(key, newLength)`,in the `keyTable`, OM deletes the blocks which are fully truncated, and updates the block length which is partially truncated. Review comment: I feel newLength is more consistent with HCFS spec ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
