| From: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | PostgreSQL crash on reference integrity check with concurrent DDL |
| Date: | 2026-12-04 16:00:53 |
| Message-ID: | CALdSSPgBGQwDRmpBH9Q445A8UANu_HncM6ukt6djVb=_j_gP-w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
I discovered that postgres can run into NULL dereference in FK
validation when the
the referenced collation's schema is dropped concurrently. The
attached two-session isolation test creates a NOT VALID FK, then
validates it, while another session moves the referenced collation on
column to another schema and drops its old schema. On HEAD, the
backend crashes with SIGSEGV in ri_GenerateQualCollation, isolation
test tail output:
# @@ -31,6 +31,7 @@
# PERFORM injection_points_wakeup('ri-generate-qual-collation');
# END$$;
#
# -s1: NOTICE: validation failed with SQLSTATE XX000
# -step validate_fk: <... completed>
# -step checked:
# +PQconsumeInput failed: server closed the connection unexpectedly
# + This probably means the server terminated abnormally
# + before or while processing the request.
# +
not ok 1 - ri_collation_schema_drop 501 ms
# (test process exited with exit code 1)
1..1
# 1 of 1 tests failed.
0001 aims to fix NULL deref by simply checking for NULL. This is
however not very user-friendly, because it will fail DDL with XX000
code. To fix that, check the follow up patch, which takes
AccessShareLock on collation, serializing DDL.
--
Best regards,
Kirill Reshke
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Handle-missing-collation-namespace-in-RI-queries.patch | application/octet-stream | 1.5 KB |
| 0002-Test-RI-collation-namespace-drop-with-injection-poin.patch | application/octet-stream | 5.2 KB |
| followup-0001-Lock-collation-while-building-RI-query.patch | application/octet-stream | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-12-04 16:31:43 | Re: Logical Implication |
| Previous Message | Ayoub Kazar | 2026-12-04 15:58:02 | Re: Propagate LIMIT bound through the outer side of left join |