From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9E29246971A for ; Mon, 9 Dec 2019 17:07:30 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id u17so15792772lja.4 for ; Mon, 09 Dec 2019 06:07:30 -0800 (PST) Date: Mon, 9 Dec 2019 17:07:28 +0300 From: Konstantin Osipov Message-ID: <20191209140728.GC8196@atlas> References: <20191209134851.14462-1-arkholga@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191209134851.14462-1-arkholga@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH rfc v2] memtx: fix out of memory handling for rtree List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Olga Arkhangelskaia Cc: tarantool-patches@dev.tarantool.org * Olga Arkhangelskaia [19/12/09 16:49]: > When tarantool tries to recover rtree from a snapshot and memtx_memory value is > lower than it has been when the snapshot was created, server suffers from > segmentation fault. This happens because there is no out of memory error > handling in rtree lib. In another words, we do not check the result of > malloc operation. > To prevent this behaviour we simply reserve memory before replace operation for > rtree. And if there is not enough memory to be reserved - server will fail > gently with the "Failed to allocate" error message. It seems you're on track. You don't explain, however, why you had to add an additional reserve() which is on the side of the main execution flow (which is box_process1): during snapshot recovery the secondary keys are built in batches, not using box_process1, so the check sitting on the main execution track is not invoked. This begs the question: shouldn't you add the check to memtx_*_build_next() instead? -- Konstantin Osipov, Moscow, Russia