Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Ostanevich <sergos@tarantool.org>
To: Leonid Vasiliev <lvasiliev@tarantool.org>
Cc: m.semkin@corp.mail.ru,
	Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	Mergen Imeev <imeevma@gmail.com>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/3] sql: add missing diag_set on failure when working with files inside SQL module
Date: Tue, 15 Dec 2020 23:29:45 +0300	[thread overview]
Message-ID: <E43468D7-8B7E-4157-AC17-4B328927315E@tarantool.org> (raw)
In-Reply-To: <d38d3f49-7892-dd9e-63ac-31674310d36b@tarantool.org>

Thanks for the patch, LGTM.

Sergos

> On 14 Dec 2020, at 18:49, Leonid Vasiliev <lvasiliev@tarantool.org> wrote:
> 
> Hi! Thank you for the review.
> 
> On 13.12.2020 21:30, Vladislav Shpilevoy wrote:
>> Hi! Thanks for the patchset!
>> On 11.12.2020 15:49, Leonid Vasiliev wrote:
>>> From: Mergen Imeev <imeevma@gmail.com>
>>> 
>>> SQL module didn't set an error in the diagnostics area on a file
>>> operation failure. This could lead to a crash like in #5537.
>>> 
>>> Part of #5537
>>> ---
>>>  src/box/sql/os_unix.c | 9 +++++++--
>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
>>> index b351c55..557d709 100644
>>> --- a/src/box/sql/os_unix.c
>>> +++ b/src/box/sql/os_unix.c
>>> @@ -159,14 +159,17 @@ robust_open(const char *z, int f, mode_t m)
>>>  		if (fd < 0) {
>>>  			if (errno == EINTR)
>>>  				continue;
>>> +			diag_set(SystemError, strerror(errno));
>>>  			break;
>> SystemError already reports strerror() in ::log() method.
>> I don't think you need to duplicate it. Better add a proper
>> description. For example, the path. Grep "diag_set(SystemError"
>> in our project and see other usages which try to provide
>> more info. The same in other places.
> 
> I thought about adding more info to the error, but it seems to me that
> only "trace" is useful here. I do not mind your proposal. See full diff
> at the end of the letter
> 
>>>  		}
>>>  		if (fd >= SQL_MINIMUM_FILE_DESCRIPTOR)
>>>  			break;
>>>  		close(fd);
>>>  		fd = -1;
>>> -		if (open("/dev/null", f, m) < 0)
>>> +		if (open("/dev/null", f, m) < 0) {
>>> +			diag_set(SystemError, strerror(errno));
>>>  			break;
>>> +		}
>>>  	}
>>>  	if (fd >= 0) {
>>>  		if (m != 0) {
>>> @@ -831,8 +834,10 @@ seekAndWriteFd(int fd,		/* File descriptor to write to */
>>>  		rc = write(fd, pBuf, nBuf);
>>>  	} while (rc < 0 && errno == EINTR);
>>>  -	if (rc < 0)
>>> +	if (rc < 0) {
>>> +		diag_set(SystemError, strerror(errno));
>>>  		*piErrno = errno;
>>> +	}
>>>  	return rc;
>>>  }
>>>  
> 
> 
> src/box/sql/os_unix.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
> index b351c55..ea7d3cc 100644
> --- a/src/box/sql/os_unix.c
> +++ b/src/box/sql/os_unix.c
> @@ -159,14 +159,17 @@ robust_open(const char *z, int f, mode_t m)
> 		if (fd < 0) {
> 			if (errno == EINTR)
> 				continue;
> +			diag_set(SystemError, "failed to open file '%s'", z);
> 			break;
> 		}
> 		if (fd >= SQL_MINIMUM_FILE_DESCRIPTOR)
> 			break;
> 		close(fd);
> 		fd = -1;
> -		if (open("/dev/null", f, m) < 0)
> +		if (open("/dev/null", f, m) < 0) {
> +			diag_set(SystemError, "failed to open '/dev/null'");
> 			break;
> +		}
> 	}
> 	if (fd >= 0) {
> 		if (m != 0) {
> @@ -831,8 +834,10 @@ seekAndWriteFd(int fd,		/* File descriptor to write to */
> 		rc = write(fd, pBuf, nBuf);
> 	} while (rc < 0 && errno == EINTR);
> 
> -	if (rc < 0)
> +	if (rc < 0) {
> +		diag_set(SystemError, "failed to write %i bytes to file", nBuf);
> 		*piErrno = errno;
> +	}
> 	return rc;
> }

  reply	other threads:[~2020-12-15 20:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 14:49 [Tarantool-patches] [PATCH v2 0/3] Fix working with temporary files in VDBE Leonid Vasiliev
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 1/3] sql: add missing diag_set on failure when working with files inside SQL module Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:49     ` Leonid Vasiliev
2020-12-15 20:29       ` Sergey Ostanevich [this message]
2020-12-15 22:12   ` Vladislav Shpilevoy
2020-12-16 23:17     ` Leonid Vasiliev
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 2/3] sql: set an error to diag in sql_execute() on failure Leonid Vasiliev
2020-12-11 15:03   ` Nikita Pettik
2020-12-11 15:40     ` Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:52     ` Leonid Vasiliev
2020-12-15 21:05       ` Sergey Ostanevich
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 3/3] sql: update temporary file name format Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:54     ` Leonid Vasiliev
2020-12-15 21:07       ` Sergey Ostanevich
2020-12-16 14:47       ` Nikita Pettik

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=E43468D7-8B7E-4157-AC17-4B328927315E@tarantool.org \
    --to=sergos@tarantool.org \
    --cc=imeevma@gmail.com \
    --cc=lvasiliev@tarantool.org \
    --cc=m.semkin@corp.mail.ru \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/3] sql: add missing diag_set on failure when working with files inside SQL module' \
    /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