[PATCH 1.10 2/2] vinyl: free region on vylog commit instead of resetting it

Vladimir Davydov vdavydov.dev at gmail.com
Tue Jun 25 15:46:05 MSK 2019


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




More information about the Tarantool-patches mailing list