szferi/gomdb — pull request #11 by maximelenoir (2014-01-19 20:56:51+00:00)
Title: Fixing potential issues with goroutines

Hi,

I've added the mandatory *MDB_NOTLS* flag to *Env.Open*. From mdb's doc : "Applications that multiplex many user threads over individual OS threads need this option [MDB_NOTLS]". 6e2b944

Also, "Such an application [that multiplexes user threads over OS threads] must also serialize the write transactions in an OS thread, since MDB's write locking is unaware of the user threads." and "A transaction and its cursors must only be used by a single thread, and a thread may only have a single transaction at a time. If *MDB_NOTLS* is in use, this does not apply to read-only transactions.". This is enforced by *runtime.LockOSThread()*. b2499f0

Even if the goroutine is locked to an OS thread, passing it through a channel to another routine is still possible and cannot, afaik, be prevented. Maybe this should be clearly stated in Txn documentation.

Thank you.