walkdir does not honor elevel because of call to AllocateDir, possibly causing issues in abort handler

From: Jelte Fennema <Jelte(dot)Fennema(at)microsoft(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: walkdir does not honor elevel because of call to AllocateDir, possibly causing issues in abort handler
Date: 2020-06-10 12:04:07
Message-ID: HE1PR83MB0218D385BCA08C32F0B10163F7830@HE1PR83MB0218.EURPRD83.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

walkdir is used indirectly in the abort handler of SharedFileSetOnDetach, which has the following comment:

/*
* Callback function that will be invoked when this backend detaches from a
* DSM segment holding a SharedFileSet that it has created or attached to. If
* we are the last to detach, then try to remove the directories and
* everything in them. We can't raise an error on failures, because this runs
* in error cleanup paths.
*/

walkdir itself has elevel, which is set to LOG in that case, so it should ot throw an ERROR.

However, since walkdir calls AllocateDir this is not always true. AllocateDir throws an ERROR in two places:

1. https://github.com/postgres/postgres/blob/5a4ada71a8f944600c348a6e4f5feb388ba8bd37/src/backend/storage/file/fd.c#L2590-L2593
2. and inderictly in reserveAllocatedDesc https://github.com/postgres/postgres/blob/5a4ada71a8f944600c348a6e4f5feb388ba8bd37/src/backend/storage/file/fd.c#L2266-L2268

The fix seems simple enough: AllocateDir and reserveAllocatedDesc should take an elevel argument and honor that. To not change the signature of AllocateDir and possibly break extions, it could simply become a wrapper of a new function like AllocateDirWithElevel(dirname, ERROR).

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Khandekar 2020-06-10 12:15:56 Re: Auto-vectorization speeds up multiplication of large-precision numerics
Previous Message Odin Ugedal 2020-06-10 11:45:02 Re: [PATCH] Add support for choosing huge page size