<div dir="ltr">I don't have any experience with <span style="font-family:arial,sans-serif;font-size:13px">_DBWithCursor, and I haven't really done extensive testing of my setup, so I'd be interested to </span>know what you learn about this use-case, as it's similar to mine. To allow multiple access, I'm opening a dbenv with these flags:<br>
<br>db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_LOCK<br><br>And then adding the flag: db.DB_TXN_NOWAIT<br><br>For the db (btree type), I'm opening it with:<br><br>db.DB_AUTO_COMMIT | db.DB_CREATE | db.DB_MULTIVERSION<br>
<br>Then, I wrap all of my cursors in a transaction that is opened with the flag:<br><br>db.DB_TXN_SNAPSHOT<br><br>This allows writing to the database when cursors are currently reading. I'm sure this is not the fastest solution (in fact, maybe it's quite slow), but it seems to be pretty flexible.<br>
<br>I'd be happy to hear of a faster/better way.<br><br><br>Ryan<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 16, 2014 at 11:07 AM, Matt Chaput <span dir="ltr"><<a href="mailto:matt@whoosh.ca" target="_blank">matt@whoosh.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi PyBSDDBers!<br>
<br>
I’m trying to use a BTree with single-writer/multi-reader transactional semantics: I want readers to see a snapshot of the moment they were opened, and changes made to writers to not be visible until they commit (and it’s OK if readers have to be re-opened).<br>


<br>
Just using bsddb3.btopen() *seems* to give me something very close to this automatically: if I open a “writer” and make changes, they aren’t visible in “readers” until the “writer” is closed and the “readers” are re-opened.<br>


<br>
However, the one thing this doesn’t seem to allow is aborting/rolling back the changes made in a writer.<br>
<br>
I tried using the bsddb.db API so I could use DBEnv.txn_begin() to get a transaction, but besides the code being harder to write, my test (writing just 50,000 keys) is *20x* slower with a transaction.<br>
<br>
So, some questions:<br>
<br>
* Am I correct in my belief that the _DBWithCursor helper object is giving me the semantics I want “for free”?<br>
<br>
* Is there a way I can use some attribute or method on _DBWithCursor, _DBWithCursor.db, etc. to abort its transaction?<br>
<br>
* If I need to use the low-level bsddb3.db API, can anyone suggest fixes for a horrible slowdown in put()s when I pass a transaction?<br>
<br>
  I tried opening the DBEnv with flags:<br>
<br>
    db.DB_INIT_TXN | db.DB_INIT_LOCK | db.DB_INIT_MPOOL | db.DB_TXN_NOSYNC<br>
<br>
  and the DB_BTREE DB with flags:<br>
<br>
    db.DB_MULTIVERSION<br>
<br>
  (When I found the DB_TXN_NOSYNC flag I really thought it was the answer, but it made no difference. But maybe I’m not using it right.)<br>
<br>
Thanks very much!<br>
<br>
Matt<br>
<br>
_______________________________________________<br>
pybsddb mailing list<br>
<a href="mailto:pybsddb@jcea.es" target="_blank">pybsddb@jcea.es</a><br>
<a href="https://mailman.jcea.es/listinfo/pybsddb" target="_blank">https://mailman.jcea.es/listinfo/pybsddb</a><br>
<a href="http://www.jcea.es/programacion/pybsddb.htm" target="_blank">http://www.jcea.es/programacion/pybsddb.htm</a></blockquote></div><br></div></div>