Rename atomicWrite to writeToCompletion#5273
Conversation
|
Hi @wzshiming. Thanks for your PR. I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
163efd8 to
6bff768
Compare
|
Sorry I didn't get your point. could you mind to explain more? thanks |
@fuweid |
|
Build succeeded.
|
content/local/store.go
Outdated
There was a problem hiding this comment.
Should be changed to write a random temporary file Instead of writing a fixed temporary file.
The path will be locked by content store. In content store, I think it is safe to use %s.tmp in here.
Anyway, I am ok to align with continuity package. :) And why not just use the existing function?
There was a problem hiding this comment.
If it does not concurrent writing of %s.tmp, then there is actually no need to atomic write, right?
I found that it is to fix some failures in Windows CI #3324
However, this modification cannot guarantee Linux atomic writing, nor does it guarantee windows atomic writing.
It's just a temporary solution that can pass CI.
I think it is necessary to implement the atomic write of Windows and then use it here
There was a problem hiding this comment.
The atomic write is to make sure that the content is completeness. Sometimes, the disk has pressure and the content will be truncated somehow. The atomic write is like transaction, not just for concurrent.
There was a problem hiding this comment.
Thank you, I understand, i found the original PR #2580.
it was forcibly interrupted when the file was just opened and no data was written. error caused by empty data when reading.
Although I think we should deal with empty data in this case, instead of guaranteeing to write data here, but thank you.
There was a problem hiding this comment.
The atomicWrite is used to ensure the content should be completeness, not empty or part of it. :)
Any two attempts to write to the same path (for example: async close operations with updated timestamps for the close operation) should already be atomic using sem locks. As Fu Wei says the "atomic" part of this call is to ensure if the renamed file (path) exists it has the contents (timestamp). I don't think it would hurt to use a unique random file name extension here, but I also don't believe it is necessary, given the callers are in charge of making sure the write to path is atomic. Maybe we should rename the call to writeToCompletion() |
|
Renaming is fine is to prevent unintended use of the function. I don't think this change is necessary and if it is, then there is a larger problem to solve with the ref lock. If the locks aren't working and there is a race at the filesystem level, the behavior should already be considered undefined. If there was a "bad resume" detected as indicated by the above Info level log message, then this change would necessitate cleaning up any of the relevant tmp files since the new attempt to recreate would no longer handle it (now it just truncs and retries). We should only rely on cleanup (via Abort or Commit) to handle removal of known files or anything unexpectedly placed in the directory, our goal is always to keep the filesystem as clean as possible at all times. |
6d871f2 to
648e0db
Compare
|
Build succeeded.
|
|
Build succeeded.
|
648e0db to
c097a66
Compare
|
Build succeeded.
|
|
please rebase, thanks~ |
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
c097a66 to
9fcea1d
Compare
|
Build succeeded.
|
The function does not guarantee atomicity, because the same temporary file will be opened multiple times.
containerd/content/local/store.go
Lines 689 to 701 in 75a0c2b
Should be changed to write a random temporary file Instead of writing a fixed temporary file.
Like this https://github.com/containerd/continuity/blob/93e15499afd51cdc830773dc804c89c11673fc63/ioutils.go#L34-L63
Signed-off-by: Shiming Zhang wzshiming@foxmail.com