Changeset: a9ed881d12bf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a9ed881d12bf
Modified Files:
        gdk/gdk.h
        gdk/gdk_bbp.c
        gdk/gdk_private.h
Branch: properties
Log Message:

Merged with default


diffs (truncated from 618 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -404,7 +404,6 @@ void *THRgetdata(int);
 int THRgettid(void);
 int THRhighwater(void);
 void THRsetdata(int, void *);
-void TMabort(void);
 gdk_return TMcommit(void);
 gdk_return TMsubcommit(BAT *bl);
 gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict sizes, int 
cnt, lng logno, lng transid);
@@ -795,13 +794,6 @@ str TABLETcreate_bats(Tablet *as, BUN es
 void TABLETdestroy_format(Tablet *as);
 int TABLEToutput_file(Tablet *as, BAT *order, stream *s);
 int TRACEtable(Client cntxt, BAT **r);
-str TRNglobal_abort(bit *ret);
-str TRNglobal_commit(bit *ret);
-str TRNglobal_sync(bit *ret);
-str TRNsubcommit(bit *ret, bat *bid);
-str TRNtrans_abort(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-str TRNtrans_clean(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-str TRNtrans_commit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 int TYPE_xml;
 UserStats USRstats;
 str WLCcommit(int clientid);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1996,68 +1996,8 @@ BUNtoid(BAT *b, BUN p)
 
 /*
  * @+ Transaction Management
- * @multitable @columnfractions 0.08 0.7
- * @item int
- * @tab
- *  TMcommit ()
- * @item int
- * @tab
- *  TMabort ()
- * @item int
- * @tab
- *  TMsubcommit ()
- * @end multitable
- *
- * MonetDB by default offers a global transaction environment.  The
- * global transaction involves all activities on all persistent BATs
- * by all threads.  Each global transaction ends with either TMabort
- * or TMcommit, and immediately starts a new transaction.  TMcommit
- * implements atomic commit to disk on the collection of all
- * persistent BATs. For all persistent BATs, the global commit also
- * flushes the delta status for these BATs (see
- * BATcommit/BATabort). This allows to perform TMabort quickly in
- * memory (without re-reading all disk images from disk).  The
- * collection of which BATs is persistent is also part of the global
- * transaction state. All BATs that where persistent at the last
- * commit, but were made transient since then, are made persistent
- * again by TMabort.  In other words, BATs that are deleted, are only
- * physically deleted at TMcommit time. Until that time, rollback
- * (TMabort) is possible.
- *
- * Use of TMabort is currently NOT RECOMMENDED due to two bugs:
- *
- * @itemize
- * @item
- * TMabort after a failed %TMcommit@ does not bring us back to the
- * previous committed state; but to the state at the failed TMcommit.
- * @item
- * At runtime, TMabort does not undo BAT name changes, whereas a cold
- * MonetDB restart does.
- * @end itemize
- *
- * In effect, the problems with TMabort reduce the functionality of
- * the global transaction mechanism to consistent checkpointing at
- * each TMcommit. For many applications, consistent checkpointingis
- * enough.
- *
- * Extension modules exist that provide fine grained locking (lock
- * module) and Write Ahead Logging (sqlserver).  Applications that
- * need more fine-grained transactions, should build this on top of
- * these extension primitives.
- *
- * TMsubcommit is intended to quickly add or remove BATs from the
- * persistent set. In both cases, rollback is not necessary, such that
- * the commit protocol can be accelerated. It comes down to writing a
- * new BBP.dir.
- *
- * Its parameter is a BAT-of-BATs (in the tail); the persistence
- * status of that BAT is committed. We assume here that the calling
- * thread has exclusive access to these bats.  An error is reported if
- * you try to partially commit an already committed persistent BAT (it
- * needs the rollback mechanism).
  */
 gdk_export gdk_return TMcommit(void);
-gdk_export void TMabort(void);
 gdk_export gdk_return TMsubcommit(BAT *bl);
 gdk_export gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict 
sizes, int cnt, lng logno, lng transid);
 
@@ -2089,13 +2029,7 @@ gdk_export gdk_return TMsubcommit_list(b
  * commit protocol, and changes may be lost after quitting or crashing
  * MonetDB.
  *
- * BATabort undo-s all changes since the previous state. The global
- * TMabort achieves a rollback to the previously committed state by
- * doing BATabort on all persistent bats.
- *
- * BUG: after a failed TMcommit, TMabort does not do anything because
- * TMcommit does the BATcommits @emph{before} attempting to sync to
- * disk instead of @sc{after} doing this.
+ * BATabort undo-s all changes since the previous state.
  */
 gdk_export void BATcommit(BAT *b, BUN size);
 gdk_export void BATfakeCommit(BAT *b);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -117,7 +117,7 @@ static gdk_return BBPfree(BAT *b);
 static void BBPdestroy(BAT *b);
 static void BBPuncacheit(bat bid, bool unloaddesc);
 static gdk_return BBPprepare(bool subcommit);
-static BAT *getBBPdescriptor(bat i, bool lock);
+static BAT *getBBPdescriptor(bat i);
 static gdk_return BBPbackup(BAT *b, bool subcommit);
 static gdk_return BBPdir_init(void);
 static void BBPcallbacks(void);
@@ -2488,7 +2488,7 @@ BBPinsert(BAT *bn)
        MT_lock_set(&GDKswapLock(i));
        BBP_status_set(i, BBPDELETING|BBPHOT);
        BBP_cache(i) = NULL;
-       BBP_desc(i) = NULL;
+       BBP_desc(i) = bn;
        BBP_refs(i) = 1;        /* new bats have 1 pin */
        BBP_lrefs(i) = 0;       /* ie. no logical refs */
        BBP_pid(i) = MT_getpid();
@@ -2545,7 +2545,6 @@ BBPcacheit(BAT *bn, bool lock)
        if (lock)
                MT_lock_set(&GDKswapLock(i));
        mode = (BBP_status(i) | BBPLOADED) & ~(BBPLOADING | BBPDELETING | 
BBPSWAPPED);
-       BBP_desc(i) = bn;
 
        /* cache it! */
        BBP_cache(i) = bn;
@@ -2834,14 +2833,19 @@ BATdescriptor(bat i)
 
        if (BBPcheck(i)) {
                b = BBP_desc(i);
-               if (b->theap->parentid != b->batCacheid &&
-                   BATdescriptor(b->theap->parentid) == NULL)
+               MT_lock_set(&b->theaplock);
+               int tp = b->theap->parentid;
+               int tvp = b->tvheap ? b->tvheap->parentid : 0;
+               MT_lock_unset(&b->theaplock);
+               if (tp != b->batCacheid &&
+                   BATdescriptor(tp) == NULL) {
                        return NULL;
-               if (b->tvheap &&
-                   b->tvheap->parentid != b->batCacheid &&
-                   BATdescriptor(b->tvheap->parentid) == NULL) {
-                       if (b->theap->parentid != b->batCacheid)
-                               BBPunfix(b->theap->parentid);
+               }
+               if (tvp != 0 &&
+                   tvp != b->batCacheid &&
+                   BATdescriptor(tvp) == NULL) {
+                       if (tp != b->batCacheid)
+                               BBPunfix(tp);
                        return NULL;
                }
                for (;;) {
@@ -2856,7 +2860,7 @@ BATdescriptor(bat i)
                        return NULL;
                b = BBP_cache(i);
                if (b == NULL)
-                       b = getBBPdescriptor(i, false);
+                       b = getBBPdescriptor(i);
                MT_lock_unset(&GDKswapLock(i));
        }
        return b;
@@ -3144,7 +3148,7 @@ BBPreclaim(BAT *b)
  * this.
  */
 static BAT *
-getBBPdescriptor(bat i, bool lock)
+getBBPdescriptor(bat i)
 {
        bool load = false;
        BAT *b = NULL;
@@ -3155,16 +3159,12 @@ getBBPdescriptor(bat i, bool lock)
                return NULL;
        }
        assert(BBP_refs(i));
-       if (lock)
-               MT_lock_set(&GDKswapLock(i));
        if ((b = BBP_cache(i)) == NULL || BBP_status(i) & BBPWAITING) {
 
                while (BBP_status(i) & BBPWAITING) {    /* wait for bat to be 
loaded by other thread */
-                       if (lock)
-                               MT_lock_unset(&GDKswapLock(i));
+                       MT_lock_unset(&GDKswapLock(i));
                        BBPspin(i, __func__, BBPWAITING);
-                       if (lock)
-                               MT_lock_set(&GDKswapLock(i));
+                       MT_lock_set(&GDKswapLock(i));
                }
                if (BBPvalid(i)) {
                        b = BBP_cache(i);
@@ -3175,12 +3175,10 @@ getBBPdescriptor(bat i, bool lock)
                        }
                }
        }
-       if (lock)
-               MT_lock_unset(&GDKswapLock(i));
        if (load) {
                TRC_DEBUG(IO_, "load %s\n", BBP_logical(i));
 
-               b = BATload_intern(i, lock);
+               b = BATload_intern(i, false);
 
                /* clearing bits can be done without the lock */
                BBP_status_off(i, BBPLOADING);
@@ -3190,14 +3188,6 @@ getBBPdescriptor(bat i, bool lock)
        return b;
 }
 
-BAT *
-BBPdescriptor(bat i)
-{
-       bool lock = locked_by == 0 || locked_by != MT_getpid();
-
-       return getBBPdescriptor(i, lock);
-}
-
 /*
  * In BBPsave executes unlocked; it just marks the BBP_status of the
  * BAT to BBPsaving, so others that want to save or unload this BAT
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -98,8 +98,6 @@ gdk_return BBPcacheit(BAT *bn, bool lock
        __attribute__((__visibility__("hidden")));
 void BBPclear(bat bid, bool lock)
        __attribute__((__visibility__("hidden")));
-BAT *BBPdescriptor(bat b)
-       __attribute__((__visibility__("hidden")));
 void BBPdump(void)             /* never called: for debugging only */
        __attribute__((__cold__));
 void BBPexit(void)
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -244,71 +244,3 @@ TMsubcommit(BAT *b)
        GDKfree(subcommit);
        return ret;
 }
-
-/*
- * @- TMabort
- * Transaction abort is cheap. We use the delta statuses to go back to
- * the previous version of each BAT. Also for BATs that are currently
- * swapped out. Persistent BATs that were made transient in this
- * transaction become persistent again.
- */
-void
-TMabort(void)
-{
-       int i;
-
-       BBPlock();
-       for (i = 1; i < getBBPsize(); i++) {
-               if (BBP_status(i) & BBPNEW) {
-                       BAT *b = BBPquickdesc(i);
-
-                       if (b) {
-                               if (!b->batTransient)
-                                       BBPrelease(i);
-                               b->batTransient = true;
-                               b->batDirtydesc = true;
-                       }
-               }
-       }
-       for (i = 1; i < getBBPsize(); i++) {
-               if (BBP_status(i) & (BBPPERSISTENT | BBPDELETED | BBPSWAPPED)) {
-                       BAT *b = BBPquickdesc(i);
-
-                       if (b == NULL)
-                               continue;
-
-                       BBPfix(i);
-                       if (BATdirty(b) || DELTAdirty(b)) {
-                               /* BUN move-backes need a real BAT! */
-                               /* Stefan:
-                                * Actually, in case DELTAdirty(b),
-                                * i.e., a BAT with differences that
-                                * is saved/swapped-out but not yet
-                                * committed, we (AFAIK) don't have to
-                                * load the BAT and apply the undo,
-                                * but rather could simply discard the
-                                * delta and revive the backup;
-                                * however, I don't know how to do
-                                * this (yet), hence we stick with
-                                * this solution for the time being
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to