Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-17252: [R] Intermittent valgrind failure (wait for thread pool approach) #13779

Closed
wants to merge 9 commits into from
Closed
8 changes: 8 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
invisible()
}

.onUnload <- function(...) {
# When running valgrind we need to wait for the thread pools to finish
# running background tasks or else spurious memory leaks may be reported.
if (on_linux_dev()) {
WaitForIdleThreadPool()
}
}

configure_tzdb <- function() {
# This is needed on Windows to support timezone-aware calculations
if (requireNamespace("tzdb", quietly = TRUE)) {
Expand Down
4 changes: 4 additions & 0 deletions r/R/arrowExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions r/src/arrowExports.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions r/src/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ int GetIOThreadPoolCapacity() { return arrow::io::GetIOThreadPoolCapacity(); }
void SetIOThreadPoolCapacity(int threads) {
StopIfNotOk(arrow::io::SetIOThreadPoolCapacity(threads));
}

namespace arrow {
namespace io {
namespace internal {
arrow::internal::ThreadPool* GetIOThreadPool();
}
} // namespace io
} // namespace arrow

// [[arrow::export]]
void WaitForIdleThreadPool() {
arrow::internal::GetCpuThreadPool()->WaitForIdle();
arrow::io::internal::GetIOThreadPool()->WaitForIdle();
}