Repository navigation
DX-128365: [C++][Gandiva] Add BuildScope::PreShutdown to wait for in-flight builds before exit - #163
Draft
victor6567758 wants to merge 1 commit into
Draft
victor6567758 wants to merge 1 commit into
victor6567758 wants to merge 1 commit into
Conversation
…flight builds before exit
Collaborator
|
Should this handle other cases besides build? like evaluate or shutdown? |
Collaborator
|
Also the status code is ambiguous. Status::Invalid is also what a bad expression returns. Status::Cancelled (or a unique message the JNI layer can map) would let callers tell them apart. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DX-128365: an executor crashed with SIGSEGV in LLVM code generation (
buildProjector) during graceful shutdown.System.exitends inexit(), which runs static destructors while builder threads are still compiling inProjector::Make/Filter::Make. A compile cannot be interrupted, so the embedder needs a way to stop new builds and wait for the running ones before the process exits.This adds that, as an explicit call. There are no atexit hooks.
Changes
BuildScope(new,shutdown_guard.h/.cc): RAII scope held for the whole ofProjector::Make(the overload that compiles) andFilter::Make. It counts builds in flight and rejects new ones once shutdown has started, withStatus::Invalid("Gandiva is shutting down").BuildScope::PreShutdown(timeout): rejects new builds and waits until none are in flight. ReturnsOK,IOErroron timeout, orInvalidif called from inside a build (it would wait for itself).PreShutdownto sleep and wake it, so normal builds never take a lock.shutdown_guard_test.cc, registered as its own test binary (gandiva-shutdown-guard-test) becausePreShutdownis one-way for the life of the process.Why compiles are covered
Gandiva starts no threads.
LLJITBuilderis used with the defaultNumCompileThreads = 0, and the machine code is generated on the first symbol lookup, whichLLVMGenerator::Buildperforms for every expression insideMake. So the whole compile happens on the calling thread, inside the scope.Follow-up
A JNI binding and a call from Dremio's executor shutdown (arrow-java and Dremio changes) will come in separate PRs.
Testing
gandiva-shutdown-guard-testctest -R gandiva)exit()at a random time. WithoutPreShutdownit crashed in about 8 of 20 runs. WithPreShutdown(30s)beforeexit(), the runs completed withPreShutdown: OKand exit code 0. Final counts to be added before undrafting.