Re: SQL:2011 application time

Paul A Jungwirth <pj@illuminatedcomputing.com>

From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, jian he <jian.universality@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, vignesh C <vignesh21@gmail.com>
Date: 2025-01-23T23:20:10Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Rename gist stratnum support function

  2. Remove support for temporal RESTRICT foreign keys

  3. Cache NO ACTION foreign keys separately from RESTRICT foreign keys

  4. Fix NO ACTION temporal foreign keys when the referenced endpoints change

  5. Improve whitespace in without_overlaps test

  6. Tests for logical replication with temporal keys

  7. Support for GiST in get_equal_strategy_number()

  8. Make the conditions in IsIndexUsableForReplicaIdentityFull() more explicit

  9. Replace get_equal_strategy_number_for_am() by get_equal_strategy_number()

  10. Improve internal logical replication error for missing equality strategy

  11. Simplify IsIndexUsableForReplicaIdentityFull()

  12. Fix ALTER TABLE / REPLICA IDENTITY for temporal tables

  13. doc: Update pg_constraint.conexclop docs for WITHOUT OVERLAPS

  14. doc: Add PERIOD to ALTER TABLE reference docs

  15. doc: Add WITHOUT OVERLAPS to ALTER TABLE reference docs

  16. Add temporal FOREIGN KEY contraints

  17. Add temporal PRIMARY KEY and UNIQUE constraints

  18. Add stratnum GiST support function

  19. Avoid crashing when a JIT-inlined backend function throws an error.

  20. Revert temporal primary keys and foreign keys

  21. Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes

  22. Add test for REPLICA IDENTITY with a temporal key

  23. Use half-open interval notation in without_overlaps tests

  24. Use daterange and YMD in without_overlaps tests instead of tsrange.

  25. Rename pg_constraint.conwithoutoverlaps to conperiod

  26. Fix comment on gist_stratnum_btree

  27. Add missing TAP test name

  28. Improve error handling of HMAC computations

  29. Rename functions to avoid future conflicts

On 1/23/25 07:31, Peter Eisentraut wrote:
> On 22.01.25 05:00, Tom Lane wrote:
>> Peter Eisentraut <peter@eisentraut.org> writes:
>>> I have committed the fix for foreign key NO ACTION (patch 0002, this did
>>> not require patch 0001).
>>
>> That commit seems to be causing occasional buildfarm failures:
>>
>> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=indri&dt=2025-01-22%2001%3A29%3A35
>> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mylodon&dt=2025-01-22%2001%3A17%3A14
>>
>> Both of these look like
>>
>> --- /Users/buildfarm/bf-data/HEAD/pgsql.build/src/test/regress/expected/without_overlaps.out    
>> 2025-01-21 20:29:36
>> +++ /Users/buildfarm/bf-data/HEAD/pgsql.build/src/test/regress/results/without_overlaps.out    
>> 2025-01-21 20:43:08
>> @@ -1792,8 +1792,6 @@
>>     SET valid_at = CASE WHEN lower(valid_at) = '2018-01-01' THEN daterange('2018-01-01', 
>> '2018-01-05')
>>                         WHEN lower(valid_at) = '2018-02-01' THEN daterange('2018-01-05', 
>> '2018-03-01') END
>>     WHERE id = '[6,7)';
>> -ERROR:  update or delete on table "temporal_rng" violates RESTRICT setting of foreign key 
>> constraint "temporal_fk_rng2rng_fk" on table "temporal_fk_rng2rng"
>> -DETAIL:  Key (id, valid_at)=([6,7), [2018-01-01,2018-02-01)) is referenced from table 
>> "temporal_fk_rng2rng".
>>   -- a PK update that fails because both are referenced (even before commit):
>>   BEGIN;
>>     ALTER TABLE temporal_fk_rng2rng
>>
>> ie, an expected error did not get thrown.
> 
> I suspect the nested locking clauses in the new SQL query in the patch. I don't see anything else in 
> the patch that would possibly create this kind unstable behavior.

I can't find a regression.diffs in the second link. Is there one? I can't tell if it's the same 
failure as in the first link as not.

I ran installcheck-parallel on my own machine continuously over night and haven't been able to 
reproduce this yet. How many cases have appeared on the build farm? More than these two? And just to 
confirm: they are only since committing 1772d554b0?

The strange thing is that the omitted error message is for a RESTRICT foreign key, and 1772d554b0 
only changes behavior when is_no_action. That makes me think the bug is with the original temporal 
FK commit. But that has been running on the build farm for a long time, so probably not.

Likewise, I don't see how it can be the nested locking, when that SQL isn't used for RESTRICT 
constraints.

The infrequent failure made me suspect a memory error. It's hard to come up with explanations.

What about caching the FK's query plan? Could the RESTRICT test ever reuse the constraint oid from 
the NO ACTION tests just above it? I'm pretty sure that's not supposed to happen, but if it used a 
plan generated from the NO ACTION SQL, it would exhibit the behavior we're seeing. It also makes 
sense why it only appeared after 1772d554b0.

I'll dig into that hypothesis and let you know if I figure anything out.

Yours,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com