Changeset: cb28be30354f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cb28be30354f
Modified Files:
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
Branch: smart-merge-jan22
Log Message:

Undo changeset 52cba3e788de:
Keeping currently committing transaction amongst actives
is easier to work with after all.


diffs (59 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -408,6 +408,9 @@ merge_segments(storage *s, sql_trans *tr
                                int merge = 1;
                                for (int i = 0; active[i] != 0; i++) {
                                        assert(active[i] != seg->ts && 
active[i] != cur->ts);
+
+                                       if (active[i] == tr->ts)
+                                               continue; /* pretent that 
committing transaction has already committed and is no longer active */
                                        if (seg->ts < active[i] && cur->ts < 
active[i])
                                                break;
                                        if (seg->ts > active[i] && cur->ts > 
active[i])
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -58,17 +58,15 @@ store_oldest(sqlstore *store)
 }
 
 static ulng *
-store_get_active(sqlstore *store, sql_trans* tr)
-{
-       ulng *active = GDKmalloc(sizeof(ulng) * store->active->cnt);
+store_get_active(sqlstore *store)
+{
+
+       ulng *active = GDKmalloc(sizeof(ulng) * (store->active->cnt + 1));
        node *cur = store->active->h;
-       int j = 0;
        for (int i = 0; i < store->active->cnt; i++, cur = cur->next) {
-               ulng ts = ((sql_session*)cur->data)->tr->ts;
-               if (ts != tr->ts)
-                       active[j++] = ((sql_session*)cur->data)->tr->ts;
-       }
-       active[j] = 0;
+               active[i] = ((sql_session*)cur->data)->tr->ts;
+       }
+       active[store->active->cnt] = 0;
        return active;
 }
 
@@ -3639,7 +3637,7 @@ sql_trans_rollback(sql_trans *tr, bool c
                store_lock(store);
                ulng oldest = store_oldest(store);
                ulng commit_ts = store_get_timestamp(store); /* use most recent 
timestamp such that we can cleanup savely */
-               ulng *active = store_get_active(store, tr); /* get active 
transactions (to merge segments) */
+               ulng *active = store_get_active(store); /* get active 
transactions (to merge segments) */
                for(node *n=nl->h; n; n = n->next) {
                        sql_change *c = n->data;
 
@@ -3992,7 +3990,7 @@ sql_trans_commit(sql_trans *tr)
                if (ATOMIC_GET(&store->nr_active) == 1 && !tr->parent)
                        oldest = commit_ts;
                store_pending_changes(store, oldest);
-               ulng *active = store_get_active(store, tr); /* get active 
transactions (to merge segments) */
+               ulng *active = store_get_active(store); /* get active 
transactions (to merge segments) */
                for(node *n=tr->changes->h; n && ok == LOG_OK; n = n->next) {
                        sql_change *c = n->data;
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to