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 1fTR64-0003nL-HY for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jun 2018 12:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTR62-0000fw-Ok for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jun 2018 12:11:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTR62-0000fm-Ao for pgsql-hackers@lists.postgresql.org; Thu, 14 Jun 2018 12:11:22 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTR5u-0004OQ-Uv for pgsql-hackers@postgresql.org; Thu, 14 Jun 2018 12:11:21 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 6054521C1CB1; Thu, 14 Jun 2018 15:11:13 +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 30CEB21C1CAE; Thu, 14 Jun 2018 15:11:13 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1528978273; bh=4g8j999nayiHb1Le13bPf9GeoY2vuxhPUYZzbXP1eUs=; h=Date:From:To:Cc:Subject; b=B9d5ejTDz+H0h/w3EJHvfO/Uul8j/T1M4bB07IimDiUn3S1Tk3w99N8udlQTzpX7e 4JfSh9DOcwUlNeDl3I3l8GxeWNwNnCRIUjS1QJ59yIG0jy/EHzGeWuMwPnPqgOrSsA w5SZF9HPhK0+v36o3KwLndR7Zff1/siTxVceoBvA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 14 Jun 2018 15:11:13 +0300 From: Marina Polyakova To: Alvaro Herrera Cc: Fabien COELHO , pgsql-hackers@postgresql.org, Ildus Kurbangaliev , Teodor Sigaev Subject: Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors Organization: Postgres Professional 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 13-06-2018 22:59, Alvaro Herrera wrote: > For context: in the backend, elog() is only used for internal messages > (i.e. "can't-happen" conditions), and ereport() is used for user-facing > messages. There are many things ereport() has that elog() doesn't, > such > as additional message fields (HINT, DETAIL, etc) that I think could > have > some use in pgbench as well. If you use elog() then you can't have > that. AFAIU originally it was not supposed that the pgbench error messages have these fields, so will it be good to change the final output to stderr?.. For example: - fprintf(stderr, "%s", PQerrorMessage(con)); - fprintf(stderr, "(ignoring this error and continuing anyway)\n"); + ereport(LOG, + (errmsg("Ignoring the server error and continuing anyway"), + errdetail("%s", PQerrorMessage(con)))); - fprintf(stderr, "%s", PQerrorMessage(con)); - if (sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) == 0) - { - fprintf(stderr, "Perhaps you need to do initialization (\"pgbench -i\") in database \"%s\"\n", PQdb(con)); - } - - exit(1); + ereport(ERROR, + (errmsg("Server error"), + errdetail("%s", PQerrorMessage(con)), + sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) == 0 ? + errhint("Perhaps you need to do initialization (\"pgbench -i\") in database \"%s\"\n", + PQdb(con)) : 0)); -- Marina Polyakova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company