Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH] xlog: fix fallocate vs read race
Date: Fri, 14 Dec 2018 14:12:40 +0300	[thread overview]
Message-ID: <20181214111240.egnimmmhekj5vzir@esperanza> (raw)
In-Reply-To: <20181214110741.GA7745@chai>

On Fri, Dec 14, 2018 at 02:07:41PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev@gmail.com> [18/12/14 13:30]:
> > posix_fallocate(), which is used for preallocating disk space for WAL
> > files, increases the file size and fills the allocated space with zeros.
> > The problem is a WAL file may be read by a relay thread at the same time
> > it is written to. We try to handle the zeroed space in xlog_cursor (see
> > xlog_cursor_next_tx()), however this turns out to be not enough, because
> > transactions are written not atomically so it may occur that a writer
> > writes half a transaction when a reader reads it. Without fallocate, the
> > reader would stop at EOF until the rest of the transaction is written,
> > but with fallocate it reads zeroes instead and thinks that the xlog file
> > is corrupted while actually it is not.
> 
> You should use check_program_runs() not check_symbol_exists and
> avoid checks at runtime. 

At compile time we don't know if the filesystem that will be used for
storing WALs supports fallocate() so the runtime check is a must.

  reply	other threads:[~2018-12-14 11:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 10:29 Vladimir Davydov
2018-12-14 11:07 ` Konstantin Osipov
2018-12-14 11:12   ` Vladimir Davydov [this message]
2018-12-14 12:04 ` Vladimir Davydov
2018-12-14 12:30 ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181214111240.egnimmmhekj5vzir@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] xlog: fix fallocate vs read race' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox