Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdXhY-0003D8-1r for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 09:15:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdXhV-0000D8-Bz for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 09:15:49 +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.89) (envelope-from ) id 1fdXhU-0000D0-Sw for pgsql-hackers@lists.postgresql.org; Thu, 12 Jul 2018 09:15:49 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdXhR-0004JV-9k for pgsql-hackers@postgresql.org; Thu, 12 Jul 2018 09:15:47 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 1E9A421C276F; Thu, 12 Jul 2018 12:15:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (cyclops.l.postgrespro.ru [192.168.27.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id D1CE721C275A; Thu, 12 Jul 2018 12:15:42 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1531386942; bh=QnsagwFnNjfDVcbt0HjrDwZTxcKW9oah67IzjnhbYcs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=PD3eCtTkXkjc8IOTWHvrlLaZR0ce0OEwj5LjN4FwyMS2wEugGj793cod2ZEwjQKDn wV0me7+tDpt3MCOlWPlprpF9gT7uBoQzTBwryuBXrYisPxQNgt9l80f3B885/x4JqI TP0670m0tROFfGLwV8P90AQHvgLtdRDhzpak9IeY= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 12 Jul 2018 12:15:42 +0300 From: Marina Polyakova To: Fabien COELHO Cc: Alvaro Herrera , pgsql-hackers@postgresql.org, Ildus Kurbangaliev , Teodor Sigaev Subject: Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors Organization: Postgres Professional In-Reply-To: References: <20180508193621.dphlgwrd5yz67o2z@alvherre.pgsql> <0569c5309cf536a839e2a3a1433bd113@postgrespro.ru> <976a25a46420c93866ada4051976b1be@postgrespro.ru> Message-ID: X-Sender: m.polyakova@postgrespro.ru User-Agent: Roundcube Webmail/1.2.4 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11-07-2018 22:34, Fabien COELHO wrote: >> can we try something like this? >> >> PGBENCH_ERROR_START(DEBUG_FAIL) >> { >> PGBENCH_ERROR("client %d repeats the failed transaction (try %d", > > Argh, no? I was thinking of something much more trivial: > > pgbench_error(DEBUG, "message format %d %s...", 12, "hello world"); > > If you really need some complex dynamic buffer, and I would prefer > that you avoid that, then the fallback is: > > if (level >= DEBUG) > { > initPQstuff(&msg); > ... > pgbench_error(DEBUG, "fixed message... %s\n", msg); > freePQstuff(&msg); > } > > The point is to avoid building the message with dynamic allocation and > so > if in the end it is not used. Ok! About avoidance - I'm afraid there's one more piece of debugging code with the same problem: else if (command->type == META_COMMAND) { ... initPQExpBuffer(&errmsg_buf); printfPQExpBuffer(&errmsg_buf, "client %d executing \\%s", st->id, argv[0]); for (i = 1; i < argc; i++) appendPQExpBuffer(&errmsg_buf, " %s", argv[i]); appendPQExpBufferChar(&errmsg_buf, '\n'); ereport(ELEVEL_DEBUG, (errmsg("%s", errmsg_buf.data))); termPQExpBuffer(&errmsg_buf); -- Marina Polyakova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company