Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOs8r-0000Sx-A1 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Dec 2017 21:31:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOs8q-0001xW-SJ for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Dec 2017 21:31:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOs8q-0001xM-F0 for pgsql-bugs@lists.postgresql.org; Tue, 12 Dec 2017 21:31:08 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eOs8m-0004F7-OW for pgsql-bugs@postgresql.org; Tue, 12 Dec 2017 21:31:07 +0000 Received: by mail-wm0-x234.google.com with SMTP id t8so1321420wmc.3 for ; Tue, 12 Dec 2017 13:31:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=13714E6QxkHEMNA37g/j/SNFS1svR8YbAvVmF2uHsOc=; b=lTF/+3OCHpdjYU5IHTWvXhNpAhNZvcF1GORwp743nN/84I1Gv7Hdw6X4JAjigvhHrY prwdSb6GjFHXw87+9eBDeycBH8MMVon5ZC5WHNv+e8QqyH0NtzlQNSFnDBObVriKDegi FZtyyaPteXWfOXSX82tJu+HmFP1Yt/4KPcDtibC9HunzIhUbI8vuxE3U4oo6atQCY0Er XS94XQ6Oaeu7F3SF5q6OVh4OJYVH76/puwKJF36KFHUORhnWZ2aMtHOKz1jhU4lW9jqL PyUni4xKqHnUzDvsSdazLO9WLSuI6W4MiXINZc8UOxfvHExRNfz15IJX2Qbi3hBz8fSi kW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=13714E6QxkHEMNA37g/j/SNFS1svR8YbAvVmF2uHsOc=; b=cZdkdRgSy6aArtaGyzfIUbBN9nROa8Cs/j7JnBrE//6VF1Ik9x8G8ksIntFJB09r3H Ij6VNHSon2bnlUxfnbxsKeXPdpk4k7dKlKWcpzcETyOqs7wA15boVTvLZZxcyu3gDeFL Q9Zlraxt0enxBxSelETyJf5+3bw+U7vTxObG+wt0AWZAGVxBbRmoNakqCp7X6xDa5RBk +gfZDMMnK8SxPevTwk9p3H1/kumCxNIcB7TlwuYiioZJSW2hOQ8or0e5LI3XnX4qtJAO /4oCHqt0G6wUypTAYtizVGh6g0MNNpt+g9hYSWYdE7r+heQtLE19K+CJNKuNKESI4SqA Bfog== X-Gm-Message-State: AKGB3mKqPlrp5w08HXFFBFYTAWryBuQ+FsYidvWXuDG36K8RQuUMiYTQ dax+imu3GoxVqIeOsH0uQD0prsKTuauZTPThwtmsbfsCHcml27yXtaD6mDPdQr5G7taH6pmi6Mr 0UPUnFjD66kB6D2MLjWMM+Jv+U6e1umyn4xLLg1oUdlj5kPoz2l5PohMS7ZXoofvuuIil3TrFla OMSODH X-Google-Smtp-Source: ACJfBot33zGfPx9WpD5K7L65Keo7RHqzcBnHG9oOrPip2Tf/Q/J4y4m4OwgA7c1S/OCb2YBHEiWXpQ== X-Received: by 10.80.241.218 with SMTP id y26mr4588185edl.120.1513114262901; Tue, 12 Dec 2017 13:31:02 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id f53sm236813ede.86.2017.12.12.13.31.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 13:31:01 -0800 (PST) Subject: Re: BUG #14948: cost overflow To: Jan Schulz , pgsql-bugs@postgresql.org References: <20171205105924.27108.93509@wrigleys.postgresql.org> <28067.1512486620@sss.pgh.pa.us> <29106.1512509416@sss.pgh.pa.us> From: Tomas Vondra Message-ID: <942ec3b6-13ca-8e2b-d29f-520cdc0bf970@2ndquadrant.com> Date: Tue, 12 Dec 2017 22:30:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/12/2017 02:54 PM, Jan Schulz wrote: > Hello, > > in the meantime we managed to not trigger the OOM kill anymore and now > also don't have this problem with the negative costs anymore. We still > have one staging environment where this error is present, but we would > like to reclaim it. Is there some guidelines I can follow to debug > this? > I think you're probably looking for this: https://wiki.postgresql.org/wiki/Getting_a_stack_trace_of_a_running_PostgreSQL_backend_on_Linux/BSD Once you have GDB attached to the process, you can set breakpoints on interesting places. I believe the most interesting function to inspect is btcostestimate, which is what produces estimates for the bitmap index scans: https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/selfuncs.c#L6880 In particular, we're interested in parameter values passed to the function, when it produces negative indexTotalCost (..-12884901880.97). The value is updated on multiple places in the function, so you'll need to step through and see at which point it gets negative. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services