bazel icon indicating copy to clipboard operation
bazel copied to clipboard

macOS: Cannot delete sandbox directory after action execution

Open bendowski opened this issue 9 years ago • 17 comments

Description of the problem / feature request / question:

After running tests, I see this warning:

WARNING: Cannot delete sandbox directory after action execution: /private/var/tmp/_bazel_user/81e2f173210dcd47c26dbf4a42147a8b/bazel-sandbox/2551a3b4-abe3-4c34-a39d-37b44153e291-0 (java.io.IOException: /private/var/tmp/_bazel_user/81e2f173210dcd47c26dbf4a42147a8b/bazel-sandbox/2551a3b4-abe3-4c34-a39d-37b44153e291-0/execroot/master/_tmp/tests_2 (Directory not empty)).

Please let me know how I can provide more debugging information.

Environment info

  • Operating System: macOS Sierra 10.12.2

  • Bazel version (output of bazel info release): release 0.4.3-homebrew

bendowski avatar Jan 18 '17 15:01 bendowski

We used to have this problem although I don't remember the reason. I remember @philwo had a fix https://github.com/bazelbuild/bazel/commit/95b16a89001014c48e77e5c38c4ca17bd28d3ebb. I'm not sure if this should happen now...

hermione521 avatar Jan 19 '17 10:01 hermione521

@benol : Thanks for the bug report! I'm trying to collect some hopefully useful data:

  • Do you see this warning consistently or just intermittently?
  • Have you seen it with just this target or with other tests too?
  • Is the directory left behind after Bazel finished? Are you able to list the contents of it does it indeed look non-empty?
  • Are you aware of any workaround?

laszlocsomor avatar Jan 23 '17 12:01 laszlocsomor

  • I can see it consistently for one target that creates a lot of files in TEST_TMPDIR and runs other processes from within the test.
  • Only in this target.
  • It's left on disk and it's non-empty.

In our case we spawn a new JVM to work, inside the sandbox, on files in the TEST_TMPDIR directory. After Bazel fails to clean up the sandbox, I can see this directory left there, with a lock file used by the child process.

So it's possible that Bazel fails to kill all child processes before deleting sandbox. It would seem the child process was either alive and holding the lock, or killed forcefully and Bazel fails to delete the locked file.

After Bazel prints the warning and leaves the sandbox directory on disk, I can manually delete it with simple "rm -rf /private/var/.../bazel-sandbox/hashhash"

We don't have this problem on Linux.

bendowski avatar Jan 24 '17 13:01 bendowski

Thanks, that's great info.

So it sounds like the sandbox cleanup is broken -- it doesn't kill all child processes and fails to clean up all directories.

@hermione521 : does that sound like a plausible root cause? I think we could repro this with an action that spawns a process which holds on to a file descriptor and doesn't terminate.

laszlocsomor avatar Jan 25 '17 09:01 laszlocsomor

I tried several things but still can't reproduce. It would be much helpful if you can provide a minimal example to reproduce. Thank you!

hermione521 avatar Jan 27 '17 13:01 hermione521

I actually got a similar message but I'm not sure it was deterministic. I was wading through several issues so ignored it for the time being but if it will surface again I'll try and triage and generate a minimal example.

ittaiz avatar Jan 27 '17 13:01 ittaiz

@ittaiz that would be very helpful! Thank you in advance!

hermione521 avatar Jan 27 '17 13:01 hermione521

@hermione521 happened again to me today but since I'm generating a big bazel codebase (rather generating hundreds of builds files via a migration tool from maven) I don't think I can generate a minima example. Mainly since I don't know why this happens. Any chance you can give me a few concrete steps you'd like me to take when this occurs to capture the state of the workshop?

ittaiz avatar Mar 12 '17 14:03 ittaiz

@hermione521 ping? happened to me again. a small repro isn't likely but maybe I can dig some more details if you point me to the right direction

ittaiz avatar Mar 20 '17 15:03 ittaiz

Hmm.. I don't have any idea except clean them manually.. Let's ping @philwo to see if it helps.

hermione521 avatar Mar 21 '17 12:03 hermione521

I'm currently doing a big round of bug-fixes and will try to fix whatever might cause this. I'll specifically look into whether there are any race conditions in Bazel's process management on macOS.

I'll follow up on this, but if I don't, please ping this bug in ~1 week and I'll send a status update. :)

philwo avatar Mar 21 '17 13:03 philwo

Ping :) On Tue, 21 Mar 2017 at 15:57 Philipp Wollermann [email protected] wrote:

I'm currently doing a big round of bug-fixes and will try to fix whatever might cause this. I'll specifically look into whether there are any race conditions in Bazel's process management on macOS.

I'll follow up on this, but if I don't, please ping this bug in ~1 week and I'll send a status update. :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/2371#issuecomment-288085832, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUIF1pCVtP8TR0p7mkCuifXoqZezES6ks5rn9dGgaJpZM4LnDF8 .

ittaiz avatar Mar 29 '17 07:03 ittaiz

Hi @ittaiz,

I've been working on a fix for this over the last days, hope to get it submitted tomorrow. Will ping this bug then!

Philipp

philwo avatar Apr 06 '17 14:04 philwo

@philwo can we close this now?

ulfjack avatar Jun 29 '17 19:06 ulfjack

The fix has been rolled back, so maybe we should keep it open. On the other hand... did this happen to someone in the last month? If not, we can also close it, I don't mind.

philwo avatar Jul 10 '17 15:07 philwo

We used to get this from time to time. Don't remember if recently. But if the fix has been rolled back then why not keep it open?

On Mon, Jul 10, 2017 at 6:04 PM Philipp Wollermann [email protected] wrote:

The fix has been rolled back, so maybe we should keep it open. On the other hand... did this happen to someone in the last month? If not, we can also close it, I don't mind.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/2371#issuecomment-314134228, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUIFyhGQu3Jg34aLFYE2KCFwWhXNA3Xks5sMj18gaJpZM4LnDF8 .

ittaiz avatar Jul 10 '17 15:07 ittaiz

Closing. Please re-open if someone sees this again.

philwo avatar Jul 19 '18 12:07 philwo