Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIYQM-0007ZS-VM for pgsql-admin@arkaria.postgresql.org; Mon, 22 Apr 2019 12:51:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hIYQL-0000Eo-Hc for pgsql-admin@arkaria.postgresql.org; Mon, 22 Apr 2019 12:51:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIYQK-000069-Vf for pgsql-admin@lists.postgresql.org; Mon, 22 Apr 2019 12:51:53 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIYQH-0006C7-Qj for pgsql-admin@postgresql.org; Mon, 22 Apr 2019 12:51:51 +0000 Received: by mail-qt1-x844.google.com with SMTP id v7so8351001qti.7 for ; Mon, 22 Apr 2019 05:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=iHkZjEboYB8JXUxC/QxMzBoqGbZOeZcTMsf1xMCLYX4=; b=U9/ggThf6SAvgkoB93oPsT9vl087EacR1GRWGnu6j0N7p9fP9npruaAOlM7RT1nH8a SFMH/yA0BQTOfeV3krLAW7JsThyFwvs1yFGv9gDfNeqjMATLw8Moc8A3wPAuH9u5qCCi 0eQd0W6Tk9epiu/SJnG886YXiFYHLX4X1Zf/oA4dMCr+ORpyYjnLnN4TBtpL+2ApOaqr BTRKwwQEFepaK7n/h6wpEjUQmI1CuatDYIL7GUS/A0NY5d8kxTvUiyctR/TCbxvbnjAB YU+HZkb32s+ecFGd6JB/wjbcxOTQ9tStUVVk7Gd9Ock1UbIatXs8WfIvIcnOmIaRu9ae rkfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=iHkZjEboYB8JXUxC/QxMzBoqGbZOeZcTMsf1xMCLYX4=; b=lfQz8JCMHFE8cKl5cOwVf18tMwb264SiZ4RpKH3uFsEytEkt4d22Do+6SOERl6U7u/ k5z2q3UK4bEjUQUL3MVtZ52P7u1S1JHAI6r3agzBpwTkmGaAOkbREimM2n2tUxkIfAom rmczcQBY+LX15K/4v5I7dd2ugY8wTJtLc/+GkTlEYZTDEILsJAeklFRxv+0POsbvnPLF sN1o8IrT4DNqfmhHurA3vuVbwu0H73/1YDK2S5OoU4qUJZlxvtnwkG4KS6mzKh6IKfkc gIyw2lZiAnO0bzceznvQsfZqKr9AJQI1R+inOOy0ypzH1v0gLNZN2iS9a3K9qajrlpiQ 6wGw== X-Gm-Message-State: APjAAAUM4QmYbLR1Dm9vZOX1ch1VJa11LpFNX7qTuJVr7TBjNv3E7XjN cvXnjq7YE60KVdVKN6UhznTfng== X-Google-Smtp-Source: APXvYqyOrIqGVmHMH1QKKO2yxEvxGdrd7++RxMARLoHSfAiu8MO7QUHmnwUo+ZF2AJxLprTETp1T0A== X-Received: by 2002:ac8:2a51:: with SMTP id l17mr15236902qtl.76.1555937508925; Mon, 22 Apr 2019 05:51:48 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id j8sm4838904qki.7.2019.04.22.05.51.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 05:51:48 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 775AB1206A9; Mon, 22 Apr 2019 08:51:43 -0400 (-04) Date: Mon, 22 Apr 2019 08:51:43 -0400 From: Alvaro Herrera To: pavan95 Cc: pgsql-admin@postgresql.org Subject: Re: Too many serialization errors in production Message-ID: <20190422125143.GA10281@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1555926651747-0.post@n3.nabble.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Apr-22, pavan95 wrote: > So you are suggesting that changing isolation level from the ODOO > application side/ limiting a user to execute "set > default_transaction_isolation='Repeatable Read' is a bad idea correct? Yeah. Changing the isolation level is a one-line change in terms of source of code, but the implications for the correctness of the application are very serious, and might cause your data to become invalid eventually. I wonder if this problem is related to this bugfix, which came out of a report from Odoo. If you're running 9.5.3 or earlier (or 9.4.8 or earlier, or 9.3.13 or earlier), the fix might just be to update to a newer minor. Author: Alvaro Herrera Branch: master Release: REL9_6_BR [533e9c6b0] 2016-07-15 14:17:20 -0400 Branch: REL9_5_STABLE Release: REL9_5_4 [649dd1b58] 2016-07-15 14:17:20 -0400 Branch: REL9_4_STABLE Release: REL9_4_9 [166873dd0] 2016-07-15 14:17:20 -0400 Branch: REL9_3_STABLE Release: REL9_3_14 [6c243f90a] 2016-07-15 14:17:20 -0400 Avoid serializability errors when locking a tuple with a committed update When key-share locking a tuple that has been not-key-updated, and the update is a committed transaction, in some cases we raised serializability errors: ERROR: could not serialize access due to concurrent update Because the key-share doesn't conflict with the update, the error is unnecessary and inconsistent with the case that the update hasn't committed yet. This causes problems for some usage patterns, even if it can be claimed that it's sufficient to retry the aborted transaction: given a steady stream of updating transactions and a long locking transaction, the long transaction can be starved indefinitely despite multiple retries. To fix, we recognize that HeapTupleSatisfiesUpdate can return HeapTupleUpdated when an updating transaction has committed, and that we need to deal with that case exactly as if it were a non-committed update: verify whether the two operations conflict, and if not, carry on normally. If they do conflict, however, there is a difference: in the HeapTupleBeingUpdated case we can just sleep until the concurrent transaction is gone, while in the HeapTupleUpdated case this is not possible and we must raise an error instead. Per trouble report from Olivier Dony. In addition to a couple of test cases that verify the changed behavior, I added a test case to verify the behavior that remains unchanged, namely that errors are raised when a update that modifies the key is used. That must still generate serializability errors. One pre-existing test case changes behavior; per discussion, the new behavior is actually the desired one. Discussion: https://www.postgresql.org/message-id/560AA479.4080807@odoo.com https://www.postgresql.org/message-id/20151014164844.3019.25750@wrigleys.postgresql.org Backpatch to 9.3, where the problem appeared. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services