ylavic commented on code in PR #49:
URL: https://github.com/apache/apr/pull/49#discussion_r1370436413


##########
dbm/apr_dbm_lmdb.c:
##########
@@ -156,14 +168,16 @@ static void vt_lmdb_close(apr_dbm_t *dbm)
 {
     real_file_t *f = dbm->file;
 
-    if (f->cursor) {
-        mdb_cursor_close(f->cursor);
-        f->cursor = NULL;
-    }
-
+    /* try to commit all transactions that haven't been commited yet on close 
*/
     if (f->txn) {
        mdb_txn_commit(f->txn);
        f->txn = NULL;
+       f->cursor = NULL;

Review Comment:
   Thinking more about whether or not we should commit or rollback an existing 
transaction in _close()..
   
   Looking at where a ->txn != NULL can come from here:
   1. After an _open() this allows to truncate if APR_DBM_RWTRUNC was set.
   2. After a _store() and _del(), which do commit implicitly already, there is 
nothing to commit in _close() (supposedly?)
   3. After anything else there is nothing to commit either since they are read 
operations (supposedly?)
   
   So if mdb_txn_commit() does nothing for an "empty" ->tnx (`2.` and `3.`), 
which seems likely, this commit in close only addresses `1.` right?
   IOW, it avoids an implicit commit in _open() if APR_DBM_RWTRUNC is set, 
defering to the next _store() or _del() or _close(), which looks fine/sensible.
   
   In the other dbm drivers there does not seem to be any commit/rollback 
possible or involved, _store() and _del() probably have immediate effect.
   For now we get the same in lmdb with the implicit commits in _store() and 
_del(), and I don't think we can avoid that since there is no commit/rollback 
API in apr_dbm that the user can play with explicitely.
   So, IIUC, unless we provide this new API (at some point) it seems that the 
implicit commit in _close() is what we want, as the only possible optimization 
with transactions for now...
   
   Do I get this right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@apr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to