Skip to content
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

shared log not flush to disk/ssd before return set result to client #472

Open
qinzuoyan opened this issue Jul 19, 2016 · 9 comments
Open
Labels

Comments

@qinzuoyan
Copy link
Collaborator

in mutation_log_shared::append(), the shared log is not flushed (fsync on linux) before commit, which may cause data lost when machine restart under strong consistency semantics.

@shengofsun
Copy link
Collaborator

In addition, fsync is a block io operation, which is unfriendly to rDSN, so should we consider "aio_fsync" and wrap it as a api of disk_aio?

@imzhenyu
Copy link
Owner

There is a currently a flush method in aio_provider. Can you guys do a survey to see whether flush and fsync are the same thing or not? aio_fsync is great - I don't realize there is an async version on Linux:)

@shengofsun
Copy link
Collaborator

@imzhenyu, in aio_provider of linux, the flush method calls fsync, but we don't see anywhere that calls aio_provider's flush during the prepare of a mutation log.

@imzhenyu
Copy link
Owner

Thanks, @shengofsun. There are two ways to ensure the data is really pushed to disk: fsync and use direct io. I guess in our case using direct IO is easier? (with a direct io flag when opening the log). It is more complicated on windows though as it requires aligned memory.

@shengofsun
Copy link
Collaborator

@imzhenyu did you refer to the O_DIRECT? Behavior of O_DIRECT in Linux is not hardware/filesystem-independent, O_SYNC/O_DSYNC should be the proper choice for us. See this
Three issues:
(1) is there a corresponding option in windows?
(2) there are noticeable write amplification when syncing with hardware. I guess we should need a page cache in our disk engine.
(3) I'm not sure whether linux AIO works fine with O_SYNC/O_DSYNC flags.

@qinzuoyan qinzuoyan added the bug label Jul 20, 2016
@imzhenyu
Copy link
Owner

imzhenyu commented Jul 20, 2016

Seems O_DIRECT + O_SYNC is good enough. But unfortunately, the buffer should be the same as the situation under Windows that it needs to be aligned. For your questions:

  • yes
  • if we need to do hard sync, we anyway will have write amplification issue.
  • i'm not sure neither - we may try and see.

@shengofsun
Copy link
Collaborator

O_SYNC is enough for hard sync, but as far as I can see, O_DIRECT is not necessary. And if we write file with a buffer of page size, the write amplification issue should reduce. Of course, this also need to test.

@qinzuoyan
Copy link
Collaborator Author

so the resolution is to set O_SYNC flag when dsn_file_open() in log_file::create_write()?

@imzhenyu
Copy link
Owner

Let's try and see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants