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/net slow lock #2266

Merged
merged 17 commits into from
Jan 5, 2021
Merged

Fix/net slow lock #2266

merged 17 commits into from
Jan 5, 2021

Conversation

jcnelson
Copy link
Member

@jcnelson jcnelson commented Jan 5, 2021

This PR addresses #2258 by moving management of unconfirmed state and microblock mining back into the relayer thread (now that it's safe to do this).

The p2p thread will drive microblock mining using a RunMicroblockTenure relayer directive, which will be sent to wake up the relayer every so often to mine the next microblock (according to the microblock interval from the config file).

The p2p thread can no longer manage the unconfirmed state trie on its own, so I modified the UnconfirmedState struct to have a "read-only" mode that will allow it to be used to query an existing trie in the underlying MARF. To make this happen safely, I also added a new Clarity API method begin_read_only_checked(), which unlike begin_read_only() can fail if, for example, the given trie doesn't exist. This is necessary because the relayer thread can delete the unconfirmed trie while the p2p thread is using it to service requests; these requests should fail gracefully if this happens.

Because the p2p thread needs to know which transactions went into the unconfirmed state trie (so it can handle /v2/transactions/unconfirmed/{:txid}), I took the path of least resistance and made it so that the relay thread will share a copy of its unconfirmed state's mined transaction list with the p2p thread via a mutex guard. It's not the prettiest solution, but it requires fewer lines of code an introduces fewer failure modes than the alternatives I could think of.

Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

This LGTM! Just make sure that the neon_integrations microblock test still works with the latest change.

@jcnelson
Copy link
Member Author

jcnelson commented Jan 5, 2021

It passes locally at least.

Copy link
Contributor

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

LGTM!

@jcnelson
Copy link
Member Author

jcnelson commented Jan 5, 2021

Flaky tests pass locally.

@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants