True CREATED return value for ENSURE-DIRECTORIES-EXIST when multiple processes attempt to create the same directory.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
ENSURE-
(defun test-loop ()
(let ((pathname #P"/tmp/example/"))
(loop
for attempt from 0 below 100
until
(progn
(let* ((t1-created nil)
(t1 (sb-thread:
(t2 (sb-thread:
(cond ((and t1-created t2-created)
t)
$ sbcl --noinform --no-userinit --non-interactive --load /tmp/test.lisp --eval '(test-loop)'
Both threads created the directory /tmp/example/ on attempt 0.
It is expected that only one invocation of ENSURE-
The secondary value, created, is true if any directories were created.
which I interpret as ENSURE-
The implementation of ENSURE-
It is possible that the message printed by ENSURE-
If the containing directories do not exist and if verbose is true, then the
implementation is permitted (but not required) to perform output to standard
output saying what directories were created.
meaning that a message could be printed after any directories were created. Currently, messages are printed prior to creation which may result in two processes outputting a message when only one succeeds.
The requested behaviour is useful for ensuring that the created directory is new e.g. temporary directories.
sbcl --version:
SBCL 2.4.7
uname -a:
22.6.0 Darwin Kernel Version 22.6.0: Mon Jun 24 01:25:37 PDT 2024; root:xnu-
*FEATURES*:
(:ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT :ANSI-CL :BSD :COMMON-LISP :DARWIN
:IEEE-
:SB-CORE-
:UNIX)
This all makes sense. Looking at the code, there is a comment that hints at historical(?) complications: "If we can trust mkdir returning ENOENT and EEXIST". Something to be checked I guess. This is the point where NFS might enter the discussion. Also note that Windows CreateDirectory hides behind UNIX-MKDIR and the error codes need to match up.