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

Read-only transaction processing - prevent thread starvation while in the read window. #822

Closed
greg7mdp opened this issue Mar 15, 2023 · 0 comments · Fixed by #892 or #904
Closed
Assignees
Labels
bug Something isn't working 👍 lgtm

Comments

@greg7mdp
Copy link
Contributor

greg7mdp commented Mar 15, 2023

This is an issue related to the processing of read-only transactions in parallel during the read window.

When starting the read window, a task is posted for each thread in the ro thread pool (_ro_thread_pool), and this task has a loop doing approximately:

while (/* time left in read window */) {
      if (ro_trx_queue.empty())
          break;
      // pop and execute ro transaction
      ...
}

The issue is that, if for example we have only one ro trx in the queue when we enter the read window, the first thread will start executing this transaction, and all the other tasks will exit, leaving a single task to execute all further read transactions which may be posted while the read window is still active.

So essentially, for the remainder of the read window we would effectively execute readonly transactions on a single thread.

Instead of exiting the task, if there are other threads currently executing ro transactions, and there is time left in the read window, we should probably wait on a condition variable associated to the queue (_ro_trx_queue) instead of exiting the loop.

This will require changes to _ro_trx_queue. In addition encapsulate queue lock/unlock by adding a push/pop members to _ro_trx_queue.

@enf-ci-bot enf-ci-bot moved this to Todo in Team Backlog Mar 15, 2023
@heifner heifner added bug Something isn't working actionable and removed triage labels Mar 15, 2023
@arhag arhag removed the actionable label Mar 16, 2023
@linh2931 linh2931 self-assigned this Mar 16, 2023
@linh2931 linh2931 moved this from Todo to In Progress in Team Backlog Mar 16, 2023
@linh2931 linh2931 removed their assignment Mar 20, 2023
@greg7mdp greg7mdp self-assigned this Mar 21, 2023
@greg7mdp greg7mdp moved this from In Progress to Awaiting Review in Team Backlog Mar 21, 2023
heifner added a commit that referenced this issue Mar 22, 2023
heifner added a commit that referenced this issue Mar 22, 2023
greg7mdp added a commit that referenced this issue Mar 27, 2023
[4.0] Cleanup and prevent thread starvation while in the read window.
@github-project-automation github-project-automation bot moved this from Awaiting Review to Done in Team Backlog Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment