From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 02AA02577A for ; Mon, 12 Aug 2019 18:27:52 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4jpzG_14I7m9 for ; Mon, 12 Aug 2019 18:27:51 -0400 (EDT) Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id B685125531 for ; Mon, 12 Aug 2019 18:27:51 -0400 (EDT) Received: by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1hxIn7-0007Z6-VG for tarantool-patches@freelists.org; Tue, 13 Aug 2019 01:27:50 +0300 Date: Tue, 13 Aug 2019 01:27:49 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH 09/13] memtx: enter small delayed free mode from snapshot iterator Message-ID: <20190812222749.GB32337@atlas> References: <916ffc0f334fc6c4f176af1fa85cd68072c17d0d.1565430177.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <916ffc0f334fc6c4f176af1fa85cd68072c17d0d.1565430177.git.vdavydov.dev@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org * Vladimir Davydov [19/08/10 23:22]: > We must enable SMALL_DELAYED_FREE_MODE to safely use a memtx snapshot > iterator. Currently, we do that in checkpoint related callbacks, but if > we want to reuse snapshot iterators for other purposes, e.g. feeding > a read view to a newly joined replica, we better hide this code behind > snapshot iterator constructors. this is not enough, you may have multiple replicas joining, and you need multiple checkpoint support for that. Currently delayed free mode only supports one active checkpoint. > +void > +memtx_enter_delayed_free_mode(struct memtx_engine *memtx) > +{ > + memtx->snapshot_version++; > + if (memtx->delayed_free_mode++ == 0) > + small_alloc_setopt(&memtx->alloc, SMALL_DELAYED_FREE_MODE, true); > +} Just adding a counter will easily never free any memory if it never drops below 1. -- Konstantin Osipov, Moscow, Russia