-
Notifications
You must be signed in to change notification settings - Fork 230
storage: fix ondemand read may cause IO err when enable prefetch #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could do like this as a start.
storage/src/cache/cachedfile.rs
Outdated
@@ -355,7 +355,16 @@ impl FileCacheEntry { | |||
None => return Ok(0), | |||
Some(v) => { | |||
if v.is_empty() { | |||
return Ok(0); | |||
if wait_inflight { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if wait_inflight && !bitmap.wait_for_range_ready(chunk_index, count)? {
return Err()
} else {
return Ok(0)
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, make sense , will update soon.
storage/src/cache/cachedfile.rs
Outdated
@@ -355,7 +355,16 @@ impl FileCacheEntry { | |||
None => return Ok(0), | |||
Some(v) => { | |||
if v.is_empty() { | |||
return Ok(0); | |||
if wait_inflight { | |||
// we get inflight io , wait them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we get inflight io, wait for them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, will fix it
Seems two read paths For this single patch, I think |
AFAK, ‘pending’ is empty seams can not guarantee all chunks are persisted in local file, if we already have chunks inflight? please correct me if I am wrong. |
I checked the implementation Moreover, I suppose |
I see. There is a new type @jiangliu Should we define |
Those fetch_xxx method defined by the BlobObject trait has no output buffer to receive the data, so all data must be written to the underlying cache files synchronously, otherwise the client may get stale data. |
Refer to comment for BlobObject trait , seems only fetch_range_uncompressed need to make sure all data ranges are ready. Does that mean other methods can return before the data is persisted in a local file? And if do_fetch_chunks called from prefetch worker is it still needed to wait all data ready? In this case the data does not need to be used immediately. |
Seems it would be better to enforce synchronous for all fetch_xxx method in BlobObject, to avoid possible data crash issues. If it turns out that prefetch suffers from synchronous sematic, we may add new API for it. And we are trying to enable async io recently, which will help too. |
OK , so for this patch we just drop wait_inflight , and if 'pending' is empty, call wait_for_range_ready to wait for all chunks to ready. Does it make sense? And I still worry that this may invoke profemance drop for prefetch workers. |
The prefetch performance issue could be traded off by add more working threads, and we are working on enabling async io framework, which will then fix the issue. |
For fscache scenario, when prefetch workers set data chunks to pending, the ondemand read procedure does not wait for these pending chunks to be downloaded and persisted before replying cread. Make do_fetch_chunks() also waiting for inflight io complete. Signed-off-by: Xin Yin <[email protected]>
Thanks , updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@kevinXYin So I personally don't think it is a big concern about prefetch performance. |
Thanks, understood. |
For fscache scenario, when prefetch workers set data chunks to pending,
the ondemand read procedure does not wait for these pending chunks to
be downloaded and persisted before replying cread.
Make fetch_range_uncompressed() also waiting for inflight io complete
for fscache.
Signed-off-by: Xin Yin [email protected]