← Back to team overview

maria-discuss team mailing list archive

Re: fsync necessary for synchronous page flush?

 

Hi Jan,

Thanks for clarification. I should have used synchronous write, instead of
synchronous flush. My point is that I noticed for sync writes, fsync is
called to force pages to be on persistent storage. while for AIO pages,
fsync is not called to force pages to be on persistent storage. My question
here is why fsync is required for sync IOs. Does InnoDB maintain a dirty
page table? Is fsync called to guarantee the page to be on persistent
storage so that the dirty page table can be updated? If this is the case,
when is the dirty page table updated for asynchronous IOs?

P.S. I couldn't find code for dirty page table. So I am not sure if InnoDB
maintains a dirty page table for recovery. Could you please give me a
pointer to related code and related resources? Thanks.

Xiaofei

On Wed, May 6, 2015 at 10:12 AM, Jan Lindström <jan.lindstrom@xxxxxxxxxxx>
wrote:

> Hi,
>
> Terminology is little bit confusing here. Page flushing means that we have
> done synchronous write to disk but that does not mean that write is
> physically on device yet, therefore there is flush to force it to
> persistent storage.
>
> R: Jan
>
> On Wed, May 6, 2015 at 12:57 AM, Xiaofei Du <xiaofei.du008@xxxxxxxxx>
> wrote:
>
>> Hello,
>>
>> When a dirty page is flushed synchronously in buf_flush_write_block_low,
>> fsync is called in the following snippet. I am wondering why
>> we need this fsync for synchronous flush? The record should be in
>> the log already, so recovery should be able to successfully redo it
>> and apply to the disk during recovery. Maybe I am missing something here,
>> please let me know if I am wrong. Thanks much!
>>
>> Xiaofei
>>
>>
>> /* When doing single page flushing the IO is done synchronously and we
>> flush the changes to disk only for the tablespace we are working on. */ if
>> (sync) { ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE); fil_flush(buf_page_get_space(bpage));
>> /* true means we want to evict this page from the LRU list as well. */
>> buf_page_io_complete(bpage, true); }
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~maria-discuss
>> Post to     : maria-discuss@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~maria-discuss
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>

Follow ups

References