Message passing concurrency and shared state

time to read 2 min | 213 words

Mike Rettig has left a somewhat snarky comment on a post detailing a deadlock issue that I run into:

Locking on shared state? I thought you were a proponent of message based concurrency.  This post demonstrates exactly why concurrency combined with shared state is so hard.
Looking forward to your next thread race or deadlock,

The problem with message passing concurrency is that the underlying assumption here is that there isn’t any shared state. But in my situation, that is no a valid assumption.

Let us see if I can give a good example of what I mean. Let us assume that we have a message passing the exchange the following messages:

  • Session Created { Session Id }
  • Statement Executed { Session Id, Statement Text }
  • Query Sessions And Statements { }

Furthermore, you are not going to be make use of something like a DB to manage the state (which would handle the sharing issue for you), you have to manage everything in memory.

I would be very interested in hearing how you can design such a system without having shared state and locking.