Avoid crashes on a concurrently dropped schema
Avoid crashes on a concurrently dropped schema
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
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
Re: Avoid crashes on a concurrently dropped schema
От:
Heikki Linnakangas <hlinnaka@iki.fi>
Дата:
On 25/10/2026 17:40, Baji Shaik wrote: > 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. Committed down to v14, thanks! - Heikki