Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sTN5Y-00FYgB-Kv for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2024 14:54:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sTN5W-00Ao3C-Qx for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2024 14:54:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sTN5W-00Ao34-FT for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2024 14:54:02 +0000 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sTN5T-002BBL-Re for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2024 14:54:01 +0000 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-25e919bec9eso1773453fac.1 for ; Mon, 15 Jul 2024 07:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721055239; x=1721660039; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=kWMMu9W38Ty/vcIxQyqP8cr7AMMvUrppvyGtJqDOTvI=; b=UyxEzu//EH5JdPs+e83AGz5jdenrJprwuvpa1K1PDfFc7fA0zQmwtcHvjE6/Z5lumy dQO0pN5WoePjr1QC2Ss/tlS/Uq3ciFA2ha4WSEwNlzBiZXRmaueHDjV+kGb0w6YurmmR i4UKU/dWM/+tSoddHsZRcdYTdsglGL51MAal1QsSMN+XARduIBI8xn37UzE5Ok4XnPwP lNm18lTzhd911JFN3dspfX5IwFsA1oag4NvZHenkll0Rq3IUvt9uHW25RnwL5VoNagbs Ft0fW3+gedRZJvcif9qvdeQTNZ+8J0jJk0yjrSZm4ucEBMLekgmVZpqmMKAxHmn20B3w 9kcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721055239; x=1721660039; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kWMMu9W38Ty/vcIxQyqP8cr7AMMvUrppvyGtJqDOTvI=; b=JEQXYbYbMzIHw02fwTBtt4h4T+HiAGWELZR8vLs8XH4qft3kTVAR9acAfaISw/gPb8 Wr0cVGiu++AkEPLGyb9q1b1oDlzPoQxefjhllfzLMSW3BfrcfnC2YlkrJDg+OLJKhhoU HYb1E757V9VDVxuo5mAjGckytOFJ6pOItkttKI0Up9BYqjzr4mN8OTRRufZ3h9AEunpR xeeico5xeHvo2SbWS/whIY60GaW71pc4Lo4MKNlQ9cjoVZwMX7UmKYkZivrUqzdLnHxp Zi+j5Kb9hXNUuDDFQoTrTe8E7+vwwZ6sgcqi/DzaUqF/qUGUqgeijdmZJWlwLLeiYDnE XkLQ== X-Gm-Message-State: AOJu0YyOUeCgb6FgB+MqJAaCQinZZ6Y6gq2D+aEq6zBuHssceoNQn/5E LNlmledcg9jY3+7k9r5iiMCltzAhzKvrzaPH0WgRXRnXGeIN8JT1tagCYwt/I5Px6ZrGRZJeION mQpd9kSG4mtkkSJn56+nQH0/7gTZab7CB X-Google-Smtp-Source: AGHT+IE8USjAs1oJ3Jza6csuAX3QuvAvv40r/aPBvdbzLS7+Kt9Y3o8HfMfqkTdPbkwUTnnFHeyZS9znfoFW2/llyJw= X-Received: by 2002:a05:6870:961e:b0:254:a2c2:d3cc with SMTP id 586e51a60fabf-25eae7f383fmr17095429fac.19.1721055238871; Mon, 15 Jul 2024 07:53:58 -0700 (PDT) MIME-Version: 1.0 References: <20240715143518.3v5xdfuj27ryzuzh@hjp.at> In-Reply-To: <20240715143518.3v5xdfuj27ryzuzh@hjp.at> From: Ron Johnson Date: Mon, 15 Jul 2024 10:53:46 -0400 Message-ID: Subject: Re: How does this FK constraint error happen? To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000026e36e061d4a66b5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000026e36e061d4a66b5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 15, 2024 at 10:35=E2=80=AFAM Peter J. Holzer = wrote: [snip] > > Is it possible that some other process created an entry in > rel_group_user between these two queries? That was, in fact, the problem. At just the wrong time to impact one of the child databases (TAPd), but not the other two (TAPb and TAPc). TAPd=3D# select * from rel_group_user where user_id between 1100 and 1300 order by user_id; user_id | group_id | modified_by | modified_on ---------+----------+-------------+------------------------- 1133 | 2 | 1133 | 2024-07-15 08:43:35.669 1142 | 2 | 1142 | 2024-07-15 09:05:58.451 1147 | 2 | 1147 | 2024-07-15 09:30:37.169 1158 | 2 | 1158 | 2024-07-15 09:36:45.142 1197 | 2 | 1197 | 2024-07-15 09:52:58.477 1210 | 2 | 1210 | 2024-07-15 02:42:09.355 <<<<<<<<<<<<< 1229 | 2 | 1229 | 2024-07-15 08:33:48.443 1242 | 2 | 1242 | 2024-07-15 10:29:51.176 1260 | 2 | 1260 | 2024-07-15 07:36:21.182 1283 | 2 | 1283 | 2024-07-15 09:48:25.214 1288 | 2 | 1288 | 2024-07-15 08:10:33.609 (11 rows) TAPd=3D# select user_id, login_id, created_on, modified_on TAPd-# from public.access_user TAPd-# where user_id =3D 1210; user_id | login_id | created_on | modified_on ---------+------------+-------------------------+------------------------- 1210 | JORIEUSER3 | 2023-10-20 11:54:24.562 | 2024-07-15 02:42:09.355 (1 row) --00000000000026e36e061d4a66b5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jul 15, 2024 at 10:35=E2=80=AFAM = Peter J. Holzer <hjp-pgsql@hjp.at> wrote:

Is it possible that some other process created an entry in
rel_group_user between these two queries?
=C2=A0
That was, in fact, the problem.=C2=A0 At just the wrong time to impact one= of the child databases (TAPd), but not the other two (TAPb and TAPc).

TAPd=3D# select * from rel_group_u= ser
where user_id between 1100 and 1300
order by user_id;
=C2=A0us= er_id | group_id | modified_by | =C2=A0 =C2=A0 =C2=A0 modified_on =C2=A0 = =C2=A0 =C2=A0
---------+----------+-------------+----------------------= ---
=C2=A0 =C2=A0 1133 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 = =C2=A0 =C2=A01133 | 2024-07-15 08:43:35.669
=C2=A0 =C2=A0 1142 | =C2=A0 = =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 =C2=A01142 | 2024-07-15 09:05:= 58.451
=C2=A0 =C2=A0 1147 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0= =C2=A0 =C2=A01147 | 2024-07-15 09:30:37.169
=C2=A0 =C2=A0 1158 | =C2=A0= =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 =C2=A01158 | 2024-07-15 09:36= :45.142
=C2=A0 =C2=A0 1197 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2= =A0 =C2=A0 =C2=A01197 | 2024-07-15 09:52:58.477
=C2=A0 =C2=A0 1210 | =C2= =A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 =C2=A01210 | 2024-07-15 02= :42:09.355=C2=A0 <<<<<<<<<<<<<
= =C2=A0 =C2=A0 1229 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 = =C2=A01229 | 2024-07-15 08:33:48.443
=C2=A0 =C2=A0 1242 | =C2=A0 =C2=A0 = =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 =C2=A01242 | 2024-07-15 10:29:51.176<= br>=C2=A0 =C2=A0 1260 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0= =C2=A01260 | 2024-07-15 07:36:21.182
=C2=A0 =C2=A0 1283 | =C2=A0 =C2=A0= =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2=A0 =C2=A01283 | 2024-07-15 09:48:25.214=
=C2=A0 =C2=A0 1288 | =C2=A0 =C2=A0 =C2=A0 =C2=A02 | =C2=A0 =C2=A0 =C2= =A0 =C2=A01288 | 2024-07-15 08:10:33.609
(11 rows)

TAPd=3D# selec= t user_id, login_id, created_on, modified_on
TAPd-# from public.access_u= ser
TAPd-# where user_id =3D 1210;
=C2=A0user_id | =C2=A0login_id =C2= =A0| =C2=A0 =C2=A0 =C2=A0 created_on =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 = =C2=A0 =C2=A0 modified_on =C2=A0 =C2=A0 =C2=A0
---------+------------+-= ------------------------+-------------------------
=C2=A0 =C2=A0 1210 | = JORIEUSER3 | 2023-10-20 11:54:24.562 | 2024-07-15 02:42:09.355
(1 row)
=C2=A0
--00000000000026e36e061d4a66b5--