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 1iGI0h-0004Sr-J7 for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Oct 2019 07:28:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iGI0g-00042R-46 for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Oct 2019 07:28:18 +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 1iGI0f-000428-K4 for pgsql-bugs@lists.postgresql.org; Fri, 04 Oct 2019 07:28:17 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iGI0b-0007Mi-Rp for pgsql-bugs@lists.postgresql.org; Fri, 04 Oct 2019 07:28:16 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 6A9C721C4AB2 for ; Fri, 4 Oct 2019 10:28:11 +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 [192.168.27.200] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 4505321C4AB1 for ; Fri, 4 Oct 2019 10:28:11 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1570174091; bh=fZLTgWKppqWieoZ1Ry0g+j9OfbSwuDSVG2IbUUMCyvU=; h=Subject:To:References:From:Date:In-Reply-To; b=P23fKrIrIQCHAzS6O+PF3KV/l/MKrtYc0yh0RLL8cCu3QLdhDEHT0+PiD1TOtMjOn /A6NfHfavxubJOAmIbeGZNKvgeU9Z+rubLDc8kZ/q6p3ijWz1fFxYl9czAcCj+jVLN E4mdmVl8v/lZ2muttfrg8DpqxtE24vwra9MNqock= Subject: Re: Write skew anmalies are found in SERIALIZABLE isolation To: pgsql-bugs@lists.postgresql.org References: From: Konstantin Knizhnik Message-ID: Date: Fri, 4 Oct 2019 10:28:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D1151ABAD716CBA478ABE36D" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D1151ABAD716CBA478ABE36D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 04.10.2019 4:36, 张舒燕 wrote: > We have tested versions of 9.4.0, 9.6.0, 10.0, 11.0 and 11.5 and found > the Bug on all of them. > > We have wrong statements in the last email. > "If each transaction only read one item with secondary index and write > another item with primary index, write skew anomalies are more ( -> > less) likely to occur." > "At last, we run the same join SQL, and more ( -> less) anomalies can > be found. The corresponding test program is Test2.java." > There are less anomalies can be found in the second situation using > Test2.java. > > And some mistakes in our test programs have been fixed. > > Best regards , > Shuyan Zhang, ECNU I do not think that this problem is somehow related with "write skew anomalies". The type of "col" is decimal, but you are extracting it as "double", making conversion and loosing precision. Then you perform some manipulations using Java BigDecimal class, convert result to string (which also does some rounding) and subtract this value from the column. As a result of this conversions  your original  assumption that (x+y)*0.9 < (x+y) may be wrong. Please try to reproduce the problem using integer type  and I am almost sure that you will not able to get this anomalies. > ------------------ Original ------------------ > *From: * "Peter Geoghegan"; > *Date: * Fri, Oct 4, 2019 05:05 AM > *To: * "张舒燕"<51184501183@stu.ecnu.edu.cn>; > *Cc: * "pgsql-bugs"; > *Subject: * Re: Write skew anmalies are found in SERIALIZABLE isolation > On Thu, Oct 3, 2019 at 9:18 AM 张舒燕 <51184501183@stu.ecnu.edu.cn> wrote: > > When we set the isolation level to SERIALIZABLE, we observed some > wirte skew anmalies. > > What version of PostgreSQL did you test? Does this bug affect all > versions? > > -- > Peter Geoghegan -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------D1151ABAD716CBA478ABE36D Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 04.10.2019 4:36, 张舒燕 wrote:
We have tested versions of 9.4.0, 9.6.0, 10.0, 11.0 and 11.5 and found the Bug on all of them.

We have wrong statements in the last email.
"If each transaction only read one item with secondary index and write another item with primary index, write skew anomalies are more ( -> less) likely to occur."
"At last, we run the same join SQL, and more ( -> less) anomalies can be found. The corresponding test program is Test2.java."
There are less anomalies can be found in the second situation using Test2.java.

And some mistakes in our test programs have been fixed.

Best regards ,
Shuyan Zhang, ECNU

I do not think that this problem is somehow related with "write skew anomalies".
The type of "col" is decimal, but you are extracting it as "double", making conversion and loosing precision.
Then you perform some manipulations using Java BigDecimal class, convert result to string (which also does some rounding) and subtract this value from the column.
As a result of this conversions  your original  assumption that (x+y)*0.9 < (x+y) may be wrong.
Please try to reproduce the problem using integer type  and I am almost sure that you will not able to get this anomalies.


 
------------------ Original ------------------
Date:  Fri, Oct 4, 2019 05:05 AM
Subject:  Re: Write skew anmalies are found in SERIALIZABLE isolation
 
On Thu, Oct 3, 2019 at 9:18 AM 张舒燕 <51184501183@stu.ecnu.edu.cn> wrote:
> When we set the isolation level to SERIALIZABLE, we observed some wirte skew anmalies.

What version of PostgreSQL did you test? Does this bug affect all versions?

--
Peter Geoghegan

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company 
--------------D1151ABAD716CBA478ABE36D--