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

Fix the lock order issue caused by value operator init #9738

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions velox/exec/Values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ Values::Values(
operatorId,
values->id(),
"Values"),
roundsLeft_(values->repeatTimes()) {
valueNodes_(std::move(values)),
roundsLeft_(valueNodes_->repeatTimes()) {}

void Values::initialize() {
Operator::initialize();
VELOX_CHECK_NOT_NULL(valueNodes_);
VELOX_CHECK(values_.empty());
// Drop empty vectors. Operator::getOutput is expected to return nullptr or a
// non-empty vector.
values_.reserve(values->values().size());
for (auto& vector : values->values()) {
values_.reserve(valueNodes_->values().size());
for (auto& vector : valueNodes_->values()) {
if (vector->size() > 0) {
if (values->isParallelizable()) {
if (valueNodes_->isParallelizable()) {
// If this is parallelizable, copy the values to prevent Vectors from
// being shared across threads. Note that the contract in ValuesNode is
// that this should only be enabled for testing.
Expand All @@ -47,6 +53,8 @@ Values::Values(
}
}
}
// Drop the reference on the value nodes.
valueNodes_ = nullptr;
}

RowVectorPtr Values::getOutput() {
Expand Down
3 changes: 3 additions & 0 deletions velox/exec/Values.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Values : public SourceOperator {
DriverCtx* driverCtx,
std::shared_ptr<const core::ValuesNode> values);

void initialize() override;

RowVectorPtr getOutput() override;

BlockingReason isBlocked(ContinueFuture* /* unused */) override {
Expand Down Expand Up @@ -55,6 +57,7 @@ class Values : public SourceOperator {
}

private:
std::shared_ptr<const core::ValuesNode> valueNodes_;
std::vector<RowVectorPtr> values_;
int32_t current_ = 0;
size_t roundsLeft_ = 1;
Expand Down
Loading