xiaoyuyao commented on a change in pull request #1504:
URL: https://github.com/apache/ozone/pull/1504#discussion_r524422468



##########
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.
+![avatar](image/truncate.png)
+
+## 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.  
+
+OM stores `<key, RepeatedTruncateOmKeyInfo>` in truncateTable, and returns 
succ to client.  The `TruncateKey` in `RepeatedTruncateOmKeyInfo` represents 
one truncate key operation, so the list of `TruncateKey` allows us to store a 
list of truncate operations related to one key.

Review comment:
       what's the *key state* after return succ to client but actual truncate 
is pending? Does it allow truncate? This could lead to data loss is there is no 
control between pending truncate and append.
   




----------------------------------------------------------------
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]

Reply via email to