title: lmdb.BadRslotError: mdb_txn_begin: MDB_BAD_RSLOT: Invalid reuse of reader locktable slot?
body: <p>I've been experimenting with nearest neighbor algorithm for images with the style presented <a href="https://medium.com/@kevin_yang/simple-approximate-nearest-neighbors-in-python-with-annoy-and-lmdb-e8a701baf905" rel="nofollow noreferrer">in this post</a> (i.e. goal is to see how many nearly similar images there is). After getting the example adapted to my case running, I have seen couple of times the error <em>"lmdb.BadRslotError: mdb_txn_begin: MDB_BAD_RSLOT: Invalid reuse of reader locktable slot"</em> , and wondering what is the cause?</p>
  
  <p>My hypothesis is that it was caused by opening the (same) lmdb twice in the same run (at least it hasn't appeared since fixing that), but not totally sure. One of the few search hits is given <a href="https://www.openldap.org/lists/openldap-devel/201409/msg00001.html" rel="nofollow noreferrer">in another forum</a>, but the answer is not definite.  </p>
  
  <p>So the error came from the .begin statement:</p>
  
  <pre><code>fn_lmdb = fn + '.lmdb'  # stores word &lt;-&gt; id mapping
  env = lmdb.open(fn_lmdb, map_size=int(1e9))
  
  with env.begin() as txn:
      ... 
  </code></pre>
  
  <p>At the moment after I moved open next to the begin, the error has not yet appeared, but not sure if I fixed the cause or just a symptom... Have you stumbled to this one, and what was the solution?</p>