Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGMGK-00060x-2r for pgsql-general@arkaria.postgresql.org; Thu, 10 Sep 2020 13:05:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kGMGH-000896-L5 for pgsql-general@arkaria.postgresql.org; Thu, 10 Sep 2020 13:05:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGMGH-00088u-7n for pgsql-general@lists.postgresql.org; Thu, 10 Sep 2020 13:05:13 +0000 Received: from mail-qv1-xf41.google.com ([2607:f8b0:4864:20::f41]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kGMGD-00036h-U2 for pgsql-general@postgresql.org; Thu, 10 Sep 2020 13:05:12 +0000 Received: by mail-qv1-xf41.google.com with SMTP id cv8so3259978qvb.12 for ; Thu, 10 Sep 2020 06:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=americanefficient-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=fMdRmS+cIwa/g5f0mZUDpsyqnn7+cuyt5zKAduN5Z24=; b=FtlCRHj/YobAS2PLHGUKhYIp0K71DoOSHRHSXrP+fx4Zw2M01zgFYkXeHfIOIm+mRS M2SC2nDp1btk+pRUMXUvQ4+SyomsjJMb0RJ4P4ByOwhYWqWZJsDb3SdPPS1Xrrv5xURc CeDDgi6GGJXyVVu8OZiPa6pDjwEddVJolgjlYbwoDZoOpK10kA+4J19O9kTyKy9p4vw5 5/ygtLa/NoKNXbV5HucEulqEjyVfeNQph3ZF7pG3UU8TIYIQ7PAnFJr3++90iUxPSPeH MDc8UHQkXJuCmKDPEOirWryTf08lacKvylvmVc1QVjTcZA5LNUk2KGcKvrotJQkv6nmk RfQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=fMdRmS+cIwa/g5f0mZUDpsyqnn7+cuyt5zKAduN5Z24=; b=BtmpJm9AEGGQ5xeeYSJ2KfxQdZOgJ3+yQEUROJtNn6GGD8hm2T6DqHFFFJsaszWNim dGfD5PDVlZsJ05738Wgmqzj+1pQy4zHNft2dNpPNJUkemMo/eBRUPMhqqA1OQrNXGf3/ xSC7AAmX3ONPpMtyO7GLB7/dSKwo1ElWX5MJRPxUCRqtf1boycrmC89MYTy4ETtv+Tm9 Gul07O3Dy6nm/NqStGn5NP+yH5ezzSbN8Z7H/2ruHZOloQwJ84yzwhK6NtmcadaaJ30j pXGZXYl5IctPKYoxv8aoh1AT/dYuFJkoi31mjZaudaIcLahGW011Uv37WQubFNSyJ6ae jy8A== X-Gm-Message-State: AOAM533aZRKbxn9lIJRWBtkyNkzrAtAhXW1o+KydVer7kWPq7WQskvrr G/cNgC93YhZ6izubuQBoyIAbSQ== X-Google-Smtp-Source: ABdhPJxT+b03HNsqd4/0aRK/yeSeW4Sk/AhZLm+OWbVYHrP3BIWMc3TiC+R7LEqmdV9MDGCRyCaTnw== X-Received: by 2002:a0c:8444:: with SMTP id l62mr8637804qva.13.1599743105963; Thu, 10 Sep 2020 06:05:05 -0700 (PDT) Received: from [10.0.1.10] (user-10lff1p.cable.mindspring.com. [65.87.188.57]) by smtp.gmail.com with ESMTPSA id 8sm6273201qkc.100.2020.09.10.06.05.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 06:05:05 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: PKEY getting corrupted From: Philip Semanchuk In-Reply-To: Date: Thu, 10 Sep 2020 09:05:04 -0400 Cc: "pgsql-general@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: To: "Abraham, Danny" X-Mailer: Apple Mail (2.3608.120.23.2.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Sep 10, 2020, at 6:43 AM, Abraham, Danny = wrote: >=20 > Hi, >=20 > We have seen several times a situation where a PKEY is compromised and = duplicate values are created within a table. >=20 > This has happened so far on PG 928 on Linux and Windows, and also on = PG955 on AIX. >=20 > We ran massive test on PG10.4 but it has not recreated the problem. >=20 > Has anyone faced the same issue? Any known bug? In my experience, this is usually due to an application writing PK = values rather than allowing a Postgres sequence to generate them, or due = to the application misusing sequences. Postgres sequences are = monotonically increasing, so even if you insert sequence values =E2=80=9Co= ut of order=E2=80=9D, they won=E2=80=99t overlap. That=E2=80=99s not to = say a bug in Postgres is impossible, but every time I=E2=80=99ve seen = this problem, it=E2=80=99s been my application, not Postgres. Postgres 10 added new syntax for PK columns "GENERATED ALWAYS AS = IDENTITY=E2=80=9D = (https://www.postgresql.org/docs/10/sql-createtable.html). Postgres will = raise an exception if an application tries to insert a specific value = into a column defined this way. When we upgraded from 9.6 to 11 we = converted all of our PK columns to use this syntax which added a nice = safety net for us.=20 You=E2=80=99re probably already aware that 9.5.23 is the oldest = supported version in the 9.x series, so the sooner you can upgrade those = unsupported 9.x versions the better. Maybe you=E2=80=99re in the middle = of an upgrade already which is why this came up. :-)=20 Cheers Philip=