Skip to content

abci: remove lock protecting calls to the application interface#7984

Merged
mergify[bot] merged 25 commits intotendermint:masterfrom
tychoish:abci-remove-lock
Feb 24, 2022
Merged

abci: remove lock protecting calls to the application interface#7984
mergify[bot] merged 25 commits intotendermint:masterfrom
tychoish:abci-remove-lock

Conversation

@tychoish
Copy link
Contributor

@tychoish tychoish commented Feb 24, 2022

Closes #7073

As part of the 0.36 cycle we've discussed and decided to remove the mutex in tendermint that protects the ABCI application. First, applications should be able to be responsible for their own concurrency control, and can make more fine-grained decisions about concurrent use than tendermint ever could. Second, I've observed in recent weeks as we've been making this change that the mutex wasn't applied particularly consistently in many cases (e.g. multiple "local" connections to the application had multiple locks, etc.) so this will give more consistent experiences across ABCI execution environments, and simplifies the tendermint ABCI handling code.

@tychoish tychoish changed the title Please add a description of the changes that this PR introduces and the files that are the most critical to review. abci: remove lock protecting calls to the application interface Feb 24, 2022
}

func (s *SocketServer) unsafeRmConn(connID int) error {
if closer, ok := s.connsClose[connID]; ok {

Choose a reason for hiding this comment

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

Given that we're already under the lock here, and net.Conn implements io.Closer, do we need this separate map? It appears if we find a connection in s.conns we're already dropping it and closing it.

I see various closer functions plumbed around as parameters, but I maybe have missed where they're originating. Are these "close a related thing" someplace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unsafeRmConn does three things:

  • cleans up the map(s)
  • call the cancel function for the context that the connection handling threads are running for each connection
  • closes the actual connection .

This is more confusing than it needs to be and I think I can make something work that's more simple.

@thanethomson
Copy link
Contributor

This closes #7073 right?


#### ABCI Mutex

In previous versions of ABCI, Tendermint was prevented from making
Copy link
Contributor

Choose a reason for hiding this comment

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

main question for me is what can be concurrent, what needs to be sync and optimal setups. Setting everything as a rwmutex will cause issues like we have seen in the past. Some more clarification would help in migration of the sdk and other abci servers.

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 believe that this is really an application concern in terms of making sure that the application doesn't introduce some racey/non-deterministic behavior.

I think the problems we've seen in the past are "tendermint making concurrent calls to the app exercised application bugs".

Copy link
Contributor

Choose a reason for hiding this comment

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

so an app can set it up in any way they want? might make sense to document this. Building an app docs need updating as this is something to be careful with .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the point of this note. I've added some more text, but let me know if we should change it more.

@tychoish
Copy link
Contributor Author

This closes #7073 right?

Yes. In combination with 61a8127, tendermint will allow concurrent calls to ABCI applications, and defer concurrency control to the application.

@tychoish tychoish added the S:automerge Automatically merge PR when requirements pass label Feb 24, 2022
@mergify mergify bot merged commit 3e2d5db into tendermint:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S:automerge Automatically merge PR when requirements pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

abci: remove global mutex around local client

4 participants