Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: [PATCH 1.10 2/2] vinyl: free region on vylog commit instead of resetting it
Date: Tue, 25 Jun 2019 15:46:05 +0300	[thread overview]
Message-ID: <db40dec3774a26e77732b5c911d440412a12c75e.1561466574.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1561466574.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1561466574.git.vdavydov.dev@gmail.com>

region_reset() only frees memory from the last slab. As a result, if
a vylog transaction happens to use more than one slab, memory used by
vy_log.pool won't be freed, neither will it be reused, i.e. we'll get
a memory leak. Fix it by using region_free() instead of region_reset().
It's okay from performance point of view, because vylog transactions
are rare events.

Note, the master branch isn't affected to this issue, because the vylog
memory management was completely reworked there. 2.1 isn't affected
either, because there region_reset() was modified to free all slabs.
However, rather than backporting any of those commits, I think it's
more appropriate to simply use region_free().
---
 src/box/vy_log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/box/vy_log.c b/src/box/vy_log.c
index a0c6480e..275d5d72 100644
--- a/src/box/vy_log.c
+++ b/src/box/vy_log.c
@@ -802,7 +802,7 @@ vy_log_flush(void)
 		return -1;
 
 	/* Success. Free flushed records. */
-	region_reset(&vy_log.pool);
+	region_free(&vy_log.pool);
 	stailq_create(&vy_log.tx);
 	return 0;
 }
-- 
2.11.0

  parent reply	other threads:[~2019-06-25 12:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 12:46 [PATCH 1.10 0/2] Vinyl memory leak fixes Vladimir Davydov
2019-06-25 12:46 ` [PATCH 1.10 1/2] vinyl: clean up region after allocating surrogate statement Vladimir Davydov
2019-06-25 12:46 ` Vladimir Davydov [this message]
2019-06-25 12:46 ` [PATCH 1.10 0/2] Vinyl memory leak fixes 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=db40dec3774a26e77732b5c911d440412a12c75e.1561466574.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 1.10 2/2] vinyl: free region on vylog commit instead of resetting it' \
    /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