Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhfpC-0001fg-Nq for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Sep 2016 16:35:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bhfpB-0004tX-Hd for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Sep 2016 16:35:45 +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.84_2) (envelope-from ) id 1bhflG-0004V7-KR for pgsql-bugs@postgresql.org; Wed, 07 Sep 2016 16:31:42 +0000 Received: from mail2.odoo.com ([149.202.180.44]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bhflD-0004LE-G6 for pgsql-bugs@postgresql.org; Wed, 07 Sep 2016 16:31:41 +0000 Received: from [10.10.23.17] (98.71.144.195.ipv4.evonet.be [195.144.71.98]) (Authenticated sender: odo) by mail2.odoo.com (Postfix) with ESMTPSA id AC20AA3762; Wed, 7 Sep 2016 18:31:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=odoo.com; s=mail; t=1473265897; bh=TyCLK26a8D6eo3fe6VUGaI/slYNF1r0rJsxZBl7aUKA=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=tV89lBd59ovTOizwEM65yMGcyi//oSwEXgGId5ju4WkEfhqUJ+ihMOr/dc5azcFAu B0Jaoii2PMk7eeacNZA6nspP0lgTZKxr2YysaUvCC+jo5xoVg2ZDscT0G8dvLPJT5a cbFKMP93FYE2fVYDVJpgRYj41WvQadQRWLUbAU0A= Subject: Re: Serialization failures on PQ9.5 To: Sean Gong References: <20160907155855.GA113269@alvherre.pgsql> Cc: Alvaro Herrera , pgsql-bugs@postgresql.org, =?UTF-8?B?6K645bu66b6Z?= From: Olivier Dony Message-ID: <57D040E8.1070409@odoo.com> Date: Wed, 7 Sep 2016 18:31:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160907155855.GA113269@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail2.odoo.com X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 09/07/2016 05:58 PM, Alvaro Herrera wrote: >> Now, we are facing the same issue using 9.0e-20160504 with psql 9.5.4. >> We are getting ERROR: could not serialize access due to concurrent update >> When executing 2 same sql at same time: >> UPDATE "stock_quant" SET "qty"=10.0,"write_uid"=1,"write_date"=(now() at time zone 'UTC') WHERE id IN (271941) >> >> Just want to know, is there any final solution for this bug? Has it been fixed on 9.5.4 or not? > > 9.5.4 was tagged on August and the fix was pushed on 15th July, so 9.5.4 > should definitely not exhibit the same problem. > > Note that you can receive the "could not serialize access ..." error > message for other cases, so it's not necessarily a bug that you are > getting it. Exactly. If, as you say, you're executing twice the exact same UPDATE on the same `stock_quant` record, in two parallel transactions, you _must_ be getting a TransactionRollbackError. Odoo uses REPEATABLE READ isolation mode explicitly for that purpose, otherwise you might be silently corrupting the data integrity. Note that the Odoo framework will detect such transaction conflicts in most cases and silently retry the failed transaction. You will notice this in the logs with messages such as: (...) INFO (...) SERIALIZATION_FAILURE, retry 1/5 in 0.324 sec In most cases the next attempt will pass without any conflict. This is the expected behavior when two transaction attempt to update the same record at the same time, and you can safely ignore them. If you have a lot of them to the point of impacting your system performance, then something might be wrong in your installation / customizations. You can find out whether you're facing this bug or a normal conflict by looking at the PostgreSQL ERROR CONTEXT in the logs. A regular conflict will typically show an UPDATE query (it should in your example), whereas you would see an internal SELECT FOR [KEY] SHARE when the bug is triggered, e.g: ERROR: could not serialize access due to concurrent update CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."users" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x" Hope this helps, Olivier -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs