mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 14:17:21 +02:00
Avoid crash in rare case of concurrent DROP
When a role being dropped contains is referenced by catalog objects that are concurrently also being dropped, a crash can result while trying to construct the string that describes the objects. Suppress that by ignoring objects whose descriptions are returned as NULL. The majority of relevant codesites were already cautious about this already; we had just missed a couple. This is an old bug, so backpatch all the way back. Reported-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/17126-21887f04508cb5c8@postgresql.org
This commit is contained in:
parent
7dc9a310e5
commit
3eff168a29
@ -1108,6 +1108,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
|
|||||||
|
|
||||||
objDesc = getObjectDescription(obj);
|
objDesc = getObjectDescription(obj);
|
||||||
|
|
||||||
|
/* An object being dropped concurrently doesn't need to be reported */
|
||||||
|
if (objDesc == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If, at any stage of the recursive search, we reached the object via
|
* If, at any stage of the recursive search, we reached the object via
|
||||||
* an AUTO, INTERNAL, PARTITION, or EXTENSION dependency, then it's
|
* an AUTO, INTERNAL, PARTITION, or EXTENSION dependency, then it's
|
||||||
@ -1132,6 +1136,8 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
|
|||||||
{
|
{
|
||||||
char *otherDesc = getObjectDescription(&extra->dependee);
|
char *otherDesc = getObjectDescription(&extra->dependee);
|
||||||
|
|
||||||
|
if (otherDesc)
|
||||||
|
{
|
||||||
if (numReportedClient < MAX_REPORTED_DEPS)
|
if (numReportedClient < MAX_REPORTED_DEPS)
|
||||||
{
|
{
|
||||||
/* separate entries with a newline */
|
/* separate entries with a newline */
|
||||||
@ -1149,6 +1155,9 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
|
|||||||
appendStringInfo(&logdetail, _("%s depends on %s"),
|
appendStringInfo(&logdetail, _("%s depends on %s"),
|
||||||
objDesc, otherDesc);
|
objDesc, otherDesc);
|
||||||
pfree(otherDesc);
|
pfree(otherDesc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
numNotReportedClient++;
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1198,6 +1198,12 @@ storeObjectDescription(StringInfo descs,
|
|||||||
{
|
{
|
||||||
char *objdesc = getObjectDescription(object);
|
char *objdesc = getObjectDescription(object);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An object being dropped concurrently doesn't need to be reported.
|
||||||
|
*/
|
||||||
|
if (objdesc == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* separate entries with a newline */
|
/* separate entries with a newline */
|
||||||
if (descs->len != 0)
|
if (descs->len != 0)
|
||||||
appendStringInfoChar(descs, '\n');
|
appendStringInfoChar(descs, '\n');
|
||||||
|
Loading…
Reference in New Issue
Block a user