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).

Reply via email to