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

Cleanup and prevent thread starvation while in the read window. #844

Closed
wants to merge 25 commits into from

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented Mar 17, 2023

Resolves #822.

This PR encapsulate wait and lock operations in the ro transaction queue, and makes the tasks wait on a condition variable while the read window is active, and there are transactions either in the queue or being processed.

It addresses the issue of thread starvation described in issue #822.

@greg7mdp greg7mdp requested review from heifner and linh2931 March 17, 2023 19:00
Copy link
Member

@heifner heifner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be coordinated with #843 as it addresses some of the same issues.

@greg7mdp
Copy link
Contributor Author

Seems like this should be coordinated with #843 as it addresses some of the same issues.

I agree. Areg asked me to work on this yesterday, and it seems both Lin and I worked on this in parallel.

@greg7mdp greg7mdp requested a review from arhag March 17, 2023 20:12
@linh2931
Copy link
Member

Was focusing on fixing the main branch this afternoon. We should get together when Kevin is back to talk about the best way, keeping in mind to benefit Kevin's upcoming PR.

@greg7mdp
Copy link
Contributor Author

greg7mdp commented Mar 20, 2023

What test do we have that run readonly transactions, with a read window active? I believe test_read_only_trx runs only without a read window.

@greg7mdp greg7mdp marked this pull request as draft March 21, 2023 12:49
@greg7mdp greg7mdp marked this pull request as ready for review March 21, 2023 17:16
trx = std::move(queue.front());
queue.pop_front();
return true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is more complicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean by this.

plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/producer_plugin.cpp Show resolved Hide resolved
plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
@greg7mdp greg7mdp self-assigned this Mar 21, 2023
bool should_exit() {
return *received_block_ptr || exiting_read_window ||
fc::time_point::now() >= read_window_deadline;
return *received_block_ptr || exiting_read_window || fc::time_point::now() >= read_window_deadline;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the condition in #862 is better and clearly spelled out (num_waiting == max_waiting || fc::time_point::now() >= read_window_deadline || *received_block_ptr). And the order reflects the likelihood of conditions too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to test num_waiting == max_waiting here on purpose.

plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/test/test_read_only_trx.cpp Outdated Show resolved Hide resolved
@greg7mdp greg7mdp changed the base branch from main to release/4.0 March 24, 2023 18:21
@greg7mdp greg7mdp changed the base branch from release/4.0 to main March 24, 2023 18:24
@greg7mdp greg7mdp closed this Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read-only transaction processing - prevent thread starvation while in the read window.
3 participants