Skip to content

fix(rpc): Race condition when waiting for response on broadcast_tx_sync/commit#3193

Merged
andynog merged 2 commits intomainfrom
hvanz/fix-mempool-rpc-reqres
Jun 5, 2024
Merged

fix(rpc): Race condition when waiting for response on broadcast_tx_sync/commit#3193
andynog merged 2 commits intomainfrom
hvanz/fix-mempool-rpc-reqres

Conversation

@hvanz
Copy link
Collaborator

@hvanz hvanz commented Jun 5, 2024

This PR fixes a race condition generated when calling broadcast_tx_sync and broadcast_tx_commit. When closing the context, we want to also close the goroutine waiting for the response with reqRes.Wait(). We don't need to do reqRes.Done() because there is a chance it may become negative; instead, we just let the ABCI client to do it.

This bug was recently introduced by #3131.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

@hvanz hvanz added bug Something isn't working mempool rpc backport-to-v1.x labels Jun 5, 2024
@hvanz hvanz self-assigned this Jun 5, 2024
@hvanz hvanz changed the title fix(rpc): Race condition when waiting for response on broadcast_tx_sync/commit fix(rpc): Race condition when waiting for response on broadcast_tx_sync/commit Jun 5, 2024
@hvanz hvanz marked this pull request as ready for review June 5, 2024 12:09
@hvanz hvanz requested a review from a team as a code owner June 5, 2024 12:09
@hvanz hvanz requested a review from a team June 5, 2024 12:09
Copy link
Collaborator

@andynog andynog left a comment

Choose a reason for hiding this comment

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

lgtm

@andynog andynog added this pull request to the merge queue Jun 5, 2024
Merged via the queue into main with commit cd465c5 Jun 5, 2024
@andynog andynog deleted the hvanz/fix-mempool-rpc-reqres branch June 5, 2024 13:56
mergify bot pushed a commit that referenced this pull request Jun 5, 2024
…ync/commit` (#3193)

This PR fixes a race condition generated when calling
`broadcast_tx_sync` and `broadcast_tx_commit`. When closing the context,
we want to also close the goroutine waiting for the response with
`reqRes.Wait()`. We don't need to do `reqRes.Done()` because there is a
chance it may become negative; instead, we just let the ABCI client to
do it.

This bug was recently introduced by #3131.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit cd465c5)

# Conflicts:
#	rpc/core/mempool.go
hvanz added a commit that referenced this pull request Jun 5, 2024
…ync/commit` (backport #3193) (#3194)

This PR fixes a race condition generated when calling
`broadcast_tx_sync` and `broadcast_tx_commit`. When closing the context,
we want to also close the goroutine waiting for the response with
`reqRes.Wait()`. We don't need to do `reqRes.Done()` because there is a
chance it may become negative; instead, we just let the ABCI client to
do it.

This bug was recently introduced by #3131.


---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3193 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Hernán Vanzetto <15466498+hvanz@users.noreply.github.com>
Co-authored-by: hvanz <hernan.vanzetto@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mempool rpc

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants