From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>,
tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 2/2] vinyl: clean-up read views if *_build_history() fails
Date: Fri, 10 Apr 2020 17:13:14 +0200 [thread overview]
Message-ID: <67dd4512-2e87-b9f1-79d4-b7d182c0634e@tarantool.org> (raw)
In-Reply-To: <73e1f0baf18ec008312d91db4449447b3c06aa86.1586381297.git.korablev@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 2387 bytes --]
Thanks for the patch!
See 2 comments below.
> diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c
> index 7a6a20627..f6e6ed4d2 100644
> --- a/src/box/vy_write_iterator.c
> +++ b/src/box/vy_write_iterator.c
> @@ -961,8 +961,11 @@ vy_write_iterator_build_read_views(struct vy_write_iterator *stream, int *count)
> size_t used = region_used(region);
> stream->rv_used_count = 0;
> if (vy_write_iterator_build_history(stream, &raw_count,
> - &is_first_insert) != 0)
> + &is_first_insert) != 0) {
> + for (int i = 0; i < stream->rv_count; ++i)
> + stream->read_views[i].history = NULL;
> goto error;
1. Kostja probably meant encapsulation of function
vy_write_iterator_build_history(). Currently that function
leaves garbage in case of a fail. Therefore it becomes not
self sufficient. Better cleanup the views in the same place
where they are created - inside build_history().
Imagine, if build_history() would be called not in a single
place. We would need to cleanup its garbage in each one.
Diff below and attached as a file.
====================
diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c
index f6e6ed4d2..7d8c60d73 100644
--- a/src/box/vy_write_iterator.c
+++ b/src/box/vy_write_iterator.c
@@ -790,8 +790,11 @@ next_lsn:
* statement around if this is major compaction, because
* there's no tuple it could overwrite.
*/
- if (rc == 0 && stream->is_last_level &&
- stream->deferred_delete_stmt != NULL) {
+ if (rc != 0) {
+ for (int i = 0; i < stream->rv_count; ++i)
+ stream->read_views[i].history = NULL;
+ } else if (stream->is_last_level &&
+ stream->deferred_delete_stmt != NULL) {
vy_stmt_unref_if_possible(stream->deferred_delete_stmt);
stream->deferred_delete_stmt = NULL;
}
@@ -961,11 +964,8 @@ vy_write_iterator_build_read_views(struct vy_write_iterator *stream, int *count)
size_t used = region_used(region);
stream->rv_used_count = 0;
if (vy_write_iterator_build_history(stream, &raw_count,
- &is_first_insert) != 0) {
- for (int i = 0; i < stream->rv_count; ++i)
- stream->read_views[i].history = NULL;
+ &is_first_insert) != 0)
goto error;
- }
if (raw_count == 0) {
/* A key is fully optimized. */
region_truncate(region, used);
====================
2. I rolled back the patch and run the test - it passed. What can be a reason?
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1188 bytes --]
diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c
index f6e6ed4d2..7d8c60d73 100644
--- a/src/box/vy_write_iterator.c
+++ b/src/box/vy_write_iterator.c
@@ -790,8 +790,11 @@ next_lsn:
* statement around if this is major compaction, because
* there's no tuple it could overwrite.
*/
- if (rc == 0 && stream->is_last_level &&
- stream->deferred_delete_stmt != NULL) {
+ if (rc != 0) {
+ for (int i = 0; i < stream->rv_count; ++i)
+ stream->read_views[i].history = NULL;
+ } else if (stream->is_last_level &&
+ stream->deferred_delete_stmt != NULL) {
vy_stmt_unref_if_possible(stream->deferred_delete_stmt);
stream->deferred_delete_stmt = NULL;
}
@@ -961,11 +964,8 @@ vy_write_iterator_build_read_views(struct vy_write_iterator *stream, int *count)
size_t used = region_used(region);
stream->rv_used_count = 0;
if (vy_write_iterator_build_history(stream, &raw_count,
- &is_first_insert) != 0) {
- for (int i = 0; i < stream->rv_count; ++i)
- stream->read_views[i].history = NULL;
+ &is_first_insert) != 0)
goto error;
- }
if (raw_count == 0) {
/* A key is fully optimized. */
region_truncate(region, used);
next prev parent reply other threads:[~2020-04-10 15:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 21:37 [Tarantool-patches] [PATCH 0/2] vinyl: fix uninitialized memory accesses Nikita Pettik
2020-04-08 21:37 ` [Tarantool-patches] [PATCH 1/2] vinyl: init all vars before cleanup in vy_lsm_split_range() Nikita Pettik
2020-04-09 8:18 ` Konstantin Osipov
2020-04-09 10:55 ` Nikita Pettik
2020-04-09 11:07 ` Konstantin Osipov
2020-04-09 11:26 ` Nikita Pettik
2020-04-10 15:13 ` Vladislav Shpilevoy
2020-04-10 15:40 ` Nikita Pettik
2020-04-10 18:24 ` Nikita Pettik
2020-04-11 17:39 ` Vladislav Shpilevoy
2020-04-13 22:29 ` Nikita Pettik
2020-04-14 21:40 ` Nikita Pettik
2020-04-08 21:37 ` [Tarantool-patches] [PATCH 2/2] vinyl: clean-up read views if *_build_history() fails Nikita Pettik
2020-04-09 8:19 ` Konstantin Osipov
2020-04-09 11:09 ` Nikita Pettik
2020-04-10 15:13 ` Vladislav Shpilevoy [this message]
2020-04-10 15:47 ` Nikita Pettik
2020-04-10 21:45 ` Nikita Pettik
2020-04-10 22:32 ` Vladislav Shpilevoy
2020-04-11 17:30 ` Konstantin Osipov
2020-04-13 22:31 ` Nikita Pettik
2020-04-13 22:35 ` Konstantin Osipov
2020-04-13 22:11 ` Nikita Pettik
2020-04-11 17:39 ` Vladislav Shpilevoy
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=67dd4512-2e87-b9f1-79d4-b7d182c0634e@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 2/2] vinyl: clean-up read views if *_build_history() fails' \
/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