Hi,

I noticed two places that can segfault if a schema is dropped while
they run: pg_identify_object(), and schema_to_xml() with the related
SQL/XML functions. Both look up a schema name by OID without holding a
lock on the schema, and dereference the NULL that get_namespace_name()
returns after a concurrent DROP SCHEMA. It's a narrow race and rare in
practice, but any user can hit it, and it takes the cluster through
crash recovery.

0001 makes pg_identify_object() return NULL for the schema, as it
already does for objects that have gone away, so catalog-wide scans
keep working. 0002 makes the single-schema XML functions report
that the schema does not exist, as they do for a nonexistent schema,
and makes database_to_xml* skip it. Both go back to 14.

Thoughts?

Thanks,
Baji Shaik

Attachment: 0001-Avoid-crash-in-pg_identify_object-on-a-concurrently-.patch
Description: Binary data

Attachment: 0002-Avoid-crash-in-schema_to_xml-on-a-concurrently-dropp.patch
Description: Binary data

Reply via email to