siddhantsangwan commented on code in PR #8228:
URL: https://github.com/apache/ozone/pull/8228#discussion_r2030500369
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerData.java:
##########
@@ -431,20 +437,23 @@ public long getWriteBytes() {
* @param bytes the number of bytes write into the container.
*/
public void incrWriteBytes(long bytes) {
- long unused = getMaxSize() - getBytesUsed();
-
this.writeBytes.addAndGet(bytes);
/*
Increase the cached Used Space in VolumeInfo as it
maybe not updated, DU or DedicatedDiskSpaceUsage runs
periodically to update the Used Space in VolumeInfo.
*/
this.getVolume().incrementUsedSpace(bytes);
- // only if container size < max size
- if (committedSpace && unused > 0) {
- //with this write, container size might breach max size
- long decrement = Math.min(bytes, unused);
- this.getVolume().incCommittedBytes(0 - decrement);
+ // Calculate bytes used before this write operation.
+ // Note that getBytesUsed() already includes the 'bytes' from the current
write.
+ long bytesUsedBeforeWrite = getBytesUsed() - bytes;
Review Comment:
You're right Sammi. If it's overwrite, it's wrong to increment volume used
space and decrease committed space.
It looks like even the old code wasn't handling the overwrite case correctly
and there isn't enough test coverage. I'm also not sure how overwrite is used
or the concept behind it.
```
/**
* Overwrite is permitted if an only if the user explicitly asks for it. We
* permit this iff the key/value pair contains a flag called
* [OverWriteRequested, true].
*
* @param chunkInfo - Chunk info
* @return true if the user asks for it.
*/
private static boolean isOverWritePermitted(ChunkInfo chunkInfo) {
String overWrite = chunkInfo.getMetadata(OzoneConsts.CHUNK_OVERWRITE);
return Boolean.parseBoolean(overWrite);
}
```
So it's only permitted if `ChunkInfo` has explicit metadata that says
`OverWriteRequested` is true.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]