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

Possible deadlock in TParallelUnorderedTableWriter #547

Open
chegoryu opened this issue Apr 24, 2024 · 0 comments
Open

Possible deadlock in TParallelUnorderedTableWriter #547

chegoryu opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
API API related bug Something isn't working

Comments

@chegoryu
Copy link
Contributor

chegoryu commented Apr 24, 2024

Assume you added options.ThreadCount_ + 1 write tasks to writer.

options.ThreadCount_ tasks are running now and the last one is waiting in the ThreadPool_ queue, i.e. all TaskFutures_ are not ready and this part of code always ended up in else { break; }

while (TaskFutures_.size() > 0) {
if (TaskFutures_.front().HasValue()) {
TaskFutures_.pop_front();
continue;
} else if (TaskFutures_.front().HasException()) {
Stopped_ = true;
TaskFutures_.front().TryRethrow();
} else {
break;
}
}

Then you call Finish() and start waiting for the completion of the task here:

::NThreading::WaitAll(TaskFutures_).GetValueSync();

After that something went wrong, for example cluster downtime/network problems/etc.

Nothing will be returned to the WritersPool_ due to exception from task.Process:

task.Process(writer);
// If exception in Process is thrown parallel writer is going to be aborted.
// No need to Release writer in this case.
WriterPool_.Release(std::move(writer));

And after first failed write task the last task (with options.ThreadCount_ + 1 number) will start waiting here:

while (WriterPool_.empty() && PoolSize_ >= MaxPoolSize_) {
HasWriterCV_.Wait(Lock_);
}

But no one will wake up this task here:

And also WriterPool_ will always be empty.

@chizhonkova chizhonkova added bug Something isn't working API API related labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API related bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants