-
Notifications
You must be signed in to change notification settings - Fork 59
fix: support retry when io write incompletely #818
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 you could look at the implementation of Kudu: https://github.com/apache/kudu/blob/6983d25c35df8569c1851bf27e2c75e98036c10d/src/kudu/util/env_posix.cc#L490
When errno == EINTR, Kudu would keeps retrying util other errors occur or write successfully, and also, keeps retrying until the number of remaining bytes (unwritten bytes) is 0.
In addition, it's better to test it on a real cluster to see if this issue could be resolved.
Like this ? @zhangyifan27 ssize_t
write_with_retry (int fd, const void* buf, size_t size)
{
ssize_t ret;
while (size > 0) {
do
{
ret = write(fd, buf, size);
} while ((ret < 0) && (errno == EINTR));
if (ret < 0)
return ret;
size -= ret;
buf += ret;
}
return 0;
} |
Co-authored-by: Wu Tao <[email protected]>
Co-authored-by: Wu Tao <[email protected]>
I have test
however maybe since the log is too large so that the
But this is another problem and not the pr target. |
4c1ca6d
apache/incubator-pegasus#659 has reported the io write operation bug and only
retry
can decrease the probability of occurrence. This pr refer stackovflow: handling-incomplete-write-calls , rocksdb and add the retry operation.Note:
FAIL_POINT_INJECT_VOID_F
macro to mockpwrite
to reproduce the bug