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 1fTRBI-00048a-4Y for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jun 2018 12:16:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTRBG-0008Sj-Sq for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jun 2018 12:16:46 +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 1fTRBG-0008SY-IF for pgsql-hackers@lists.postgresql.org; Thu, 14 Jun 2018 12:16:46 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTRBC-0007lO-Q4 for pgsql-hackers@postgresql.org; Thu, 14 Jun 2018 12:16:45 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 5955221C1CB1; Thu, 14 Jun 2018 15:16:41 +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 2248D21C1CAE; Thu, 14 Jun 2018 15:16:41 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1528978601; bh=/TcJ9fugsf3X0NlyvezXAtijrBl5oU0ZxIo9Zi9SgWk=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=KZCm7YC0Oj/WzAAaSO9CAZcLQgRFTxdWFYKtNL0KDXfFjQWZIqtkkfYG9hxPnCWDp KkZnPbwhgbYJvVPhK1LsNuAw/Tb6LvLqdn5f9tsHGbTTxJfCiETsoZq5RwAWJ96Tp5 RuewjEgCjnWxBPQggUtcFQVAWkKJc72QX0Gw5hNw= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 14 Jun 2018 15:16:41 +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> Message-ID: <73b627e7ba86e38ec4bf8923c45cace2@postgrespro.ru> 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:44, Fabien COELHO wrote: > Hello Marina, > >> I suppose that this is related; because of my patch there may be a lot >> of such code (see v7 in [1]): >> >> - fprintf(stderr, >> - "malformed variable \"%s\" value: \"%s\"\n", >> - var->name, var->svalue); >> + if (debug_level >= DEBUG_FAILS) >> + { >> + fprintf(stderr, >> + "malformed variable \"%s\" value: \"%s\"\n", >> + var->name, var->svalue); >> + } >> >> - if (debug) >> + if (debug_level >= DEBUG_ALL) >> fprintf(stderr, "client %d sending %s\n", st->id, sql); > > I'm not sure that debug messages needs to be kept after debug, if it > is about debugging pgbench itself. That is debatable. AFAICS it is not about debugging pgbench itself, but about more detailed information that can be used to understand what exactly happened during its launch. In the case of errors this helps to distinguish between failures or errors by type (including which limit for retries was violated and how far it was exceeded for the serialization/deadlock errors). >>> The code adapts/duplicates existing server-side "ereport" stuff and >>> brings it to the frontend, where the logging needs are somehow quite >>> different. >>> >>> I'd prefer to avoid duplication and/or have some code sharing. >> >> I was recommended to use the same interface in [3]: >> >>>> On elog/errstart: we already have a convention for what ereport() >>>> calls look like; I suggest to use that instead of inventing your >>>> own. > > The "elog" interface already exists, it is not an invention. "ereport" > is a hack which is somehow necessary in some cases. I prefer a simple > function call if possible for the purpose, and ISTM that this is the > case. > That is a lot of complication which are justified server side > where logging requirements are special, but in this case I see it as > overkill. I think we need ereport() if we want to make detailed error messages (see examples in [1]).. >>> If it really needs to be duplicated, I'd suggest to put all this >>> stuff in separated files. If we want to do that, I think that it >>> would belong to fe_utils, and where it could/should be used by all >>> front-end programs. >> >> I'll try to do it.. > > Dunno. If you only need one "elog" function which prints a message to > stderr and decides whether to abort/exit/whatevrer, maybe it can just > be kept in pgbench. If there are are several complicated functions and > macros, better with a file. So I'd say it depends. > So my current view is that if you only need an "elog" function, it is > simpler to add it to "pgbench.c". Thank you! >>> For logging purposes, ISTM that the "elog" macro interface is nicer, >>> closer to the existing "fprintf(stderr", as it would not introduce >>> the >>> additional parentheses hack for "rest". >> >> I was also recommended to use ereport() instead of elog() in [3]: > > Probably. Are you hoping that advises from different reviewers should > be consistent? That seems optimistic:-) To make the patch committable there should be no objection to it.. [1] https://www.postgresql.org/message-id/c89fcc380a19380260b5ea463efc1416%40postgrespro.ru -- Marina Polyakova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company