From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 93A1C431780 for ; Mon, 31 Aug 2020 12:51:34 +0300 (MSK) Date: Mon, 31 Aug 2020 12:51:32 +0300 From: Kirill Yukhin Message-ID: <20200831095132.q2afqorjvhpby6de@tarantool.org> References: <77367c061961d33a6fd11325f4c6abb443ffb15a.1598537487.git.avtikhon@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <77367c061961d33a6fd11325f4c6abb443ffb15a.1598537487.git.avtikhon@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v2] vinyl: fix check vinyl_dir existence at bootstrap List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Alexander V. Tikhonov" Cc: tarantool-patches@dev.tarantool.org, Alexander Turenko Hello, On 27 авг 17:12, Alexander V. Tikhonov wrote: > During implementation of openSUSE build with testing got failed test > box-tap/cfg.test.lua. Found that when memtx_dir didn't exist and > vinyl_dir existed and also errno was set to ENOENT, box configuration > succeeded, but it shouldn't. Reason of this wrong behavior was that > not all of the failure paths in xdir_scan() set errno, but the caller > assumed it. > > Debugging the issue found that after xdir_scan() there was incorrect > check for errno when it returned negative values. xdir_scan() is not > system call and negative return value from it doesn't mean that errno > would be set too. Found that in situations when errno was left from > previous commands before xdir_scan() and xdir_scan() returned negative > value by itself it produced the wrong check. > > The previous failed logic of the check was to catch the error ENOENT > which set in the xdir_scan() function to handle the situation when > vinyl_dir was not exist. It failed, because checking ENOENT outside > the xdir_scan() function, we had to be sure that ENOENT had come from > xdir_scan() function call indeed and not from any other functions > before. To be sure in it possible fix could be reset errno before > xdir_scan() call, because errno could be passed from any other function > before call to xdir_scan(). > > As mentioned above xdir_scan() function is not system call and can be > changed in any possible way and it can return any result value without > need to setup errno. So check outside of this function on errno could > be broken. > > To avoid that we must not check errno after call of the function. > Better solution is to use the flag in xdir_scan(), to check if the > directory should exist. So errno check was removed and instead of it > the check for vinyl_dir existence using flag added. > > Closes #4594 > Needed for #4562 > > Co-authored-by: Alexander Turenko > --- > > Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-4562-vinyl-fix > Issue: https://github.com/tarantool/tarantool/issues/4594 > Issue: https://github.com/tarantool/tarantool/issues/4562 > Review: https://lists.tarantool.org/pipermail/tarantool-patches/2020-August/019130.html LGTM. I've checked your patch into 1.10, 2.4, 2.5 and master. -- Regards, Kirill Yukhin