title: What may be the reasons for "already in write transaction" errors for Realm iOS?
body: <p>we are using Realm to cache ChatMessage objects within our iOS app. We also use Realm to persist some other local objects within our app. For chat messages, when we receive messages from PubNub, we create a new local ChatMessage object, and write it within the main queue. For other objects writes, we offload them into non-specific global queue and put the write transaction in it.</p>
  
  <p>Currently, we are constantly experience exceptions when we wrote the ChatMessage objects, stating that the transactions were "already in write transaction". I checked all places to make sure there is no function that triggers beginWriteTransaction within each beginWriteTransacdtion/commitWriteTransaction codes. And the codes in between are mainly just Realm objects values modifications or creations. So we have absolutely no clue why this bug happened. (It's not very frequent. Usually 1-3 times per daily usage.)</p>
  
  <p>Is it possible that multiple messages from PubNub come in (in main queue) triggers multiple write transactions leading to this issue? Or could some unfinished commitWriteTransaction cause this type of problem (we didn't check commit transaction errors yet, I'm not sure the best way to handle errors from Realm)? Also, could any write transaction failed when apps went into background, and causes such errors?</p>
  
  <p>Thank you all very much!</p>