title: Are concurrency issues possible when using the WCF Service Behavior attribute set to ConcurrencyMode.Multiple and InstanceContextMode.PerCall?
body: <p>We have a WCF service that makes a good deal of transactional NHibernate calls.  Occasionally we were seeing SQL timeouts, even though the calls were updating different rows and the tables were set to row level locking.</p>
  
  <p>After digging into the logs, it looks like different threads were entering the same point in the code (our transaction using block), and an update was hanging on commit.  It didn't make sense, though, because we believed that the following service class attribute was forcing a unique execution thread per service call:</p>
  
  <pre><code>[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)]
  </code></pre>
  
  <p>We recently changed the concurrency mode to <code>ConcurrencyMode.Single</code> and haven't yet run into any issues, but the bug was very difficult to reproduce (if anyone has any thoughts on flushing a bug like that out, let me know!).</p>
  
  <p>Anyway, that all brings me to my question: shouldn't an InstanceContextMode of PerCall enforce thread-safety within the service, even if the ConcurrencyMode is set to multiple?  How would it be possible for two calls to be serviced by the same service instance?</p>
  
  <p>Thanks!</p>