Changeset: 2b53471b5349 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2b53471b5349
Modified Files:
sql/storage/bat/bat_storage.c
Branch: Jun2020
Log Message:
only free sql objects when oldest reference object is younger
diffs (119 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
@@ -2689,8 +2689,9 @@ static int
update_table(sql_trans *tr, sql_table *ft, sql_table *tt)
{
sql_trans *oldest = oldest_active_transaction();
+ sql_table *ot = NULL;
int ok = LOG_OK;
- node *n, *m;
+ node *n, *m, *o = NULL;
if (ATOMIC_GET(&store_nr_active) == 1 || ft->base.allocated) {
if (ATOMIC_GET(&store_nr_active) > 1 && ft->data) { /* move
delta */
@@ -2707,12 +2708,16 @@ update_table(sql_trans *tr, sql_table *f
bat_destroy(b->cached);
b->cached = NULL;
}
- while (b && b->wtime >= oldest->stime)
- b = b->next;
- if (b && b->next) {
+ /* find table t->base.stime */
+ ot = tr_find_table(oldest, tt);
+ if (b && ot && b->wtime < ot->base.stime) {
+ while (b && b->wtime >= ot->base.stime)
+ b = b->next;
/* anything older can go */
- delayed_destroy_dbat(b->next);
- b->next = NULL;
+ if (b && b->next && b->wtime < ot->base.stime) {
+ delayed_destroy_dbat(b->next);
+ b->next = NULL;
+ }
}
} else if (tt->data && ft->base.allocated) {
if (tr_update_dbat(tr, tt->data, ft->data) != LOG_OK)
@@ -2734,7 +2739,9 @@ update_table(sql_trans *tr, sql_table *f
ft->data = NULL;
}
}
- for (n = ft->columns.set->h, m = tt->columns.set->h; ok == LOG_OK && n
&& m; n = n->next, m = m->next) {
+ if (ot)
+ o = ot->columns.set->h;
+ for (n = ft->columns.set->h, m = tt->columns.set->h; ok == LOG_OK && n
&& m; n = n->next, m = m->next, o=(o?o->next:NULL)) {
sql_column *cc = n->data; // TODO: either stick to to/from
terminology or old/current terminology
sql_column *oc = m->data;
@@ -2742,6 +2749,7 @@ update_table(sql_trans *tr, sql_table *f
assert(!cc->base.wtime || oc->base.wtime <
cc->base.wtime || (oc->base.wtime == cc->base.wtime && oc->base.allocated /*
alter */));
if (ATOMIC_GET(&store_nr_active) > 1 && cc->data) { /*
move delta */
sql_delta *b = cc->data;
+ sql_column *oldc = NULL;
if (!oc->data)
oc->base.allocated = cc->base.allocated;
@@ -2755,12 +2763,17 @@ update_table(sql_trans *tr, sql_table *f
bat_destroy(b->cached);
b->cached = NULL;
}
- while (b && b->wtime >= oldest->stime)
- b = b->next;
- if (b && b->next) {
+ /* find column c->base.stime */
+ if (o)
+ oldc = o->data;
+ if (oldc && b && oldc->base.id == cc->base.id
&& b->wtime < oldc->base.stime) {
+ while (b && b->wtime >=
oldc->base.stime)
+ b = b->next;
/* anything older can go */
- delayed_destroy_bat(b->next);
- b->next = NULL;
+ if (b && b->next && b->wtime <
oldc->base.stime) {
+ delayed_destroy_bat(b->next);
+ b->next = NULL;
+ }
}
} else if (oc->data && cc->base.allocated) {
if (tr_update_delta(tr, oc->data, cc->data,
cc->unique == 1) != LOG_OK)
@@ -2813,7 +2826,9 @@ update_table(sql_trans *tr, sql_table *f
cc->base.allocated = 0;
}
if (ok == LOG_OK && tt->idxs.set) {
- for (n = ft->idxs.set->h, m = tt->idxs.set->h; ok == LOG_OK &&
n && m; n = n->next, m = m->next) {
+ if (ot)
+ o = ot->idxs.set->h;
+ for (n = ft->idxs.set->h, m = tt->idxs.set->h; ok == LOG_OK &&
n && m; n = n->next, m = m->next, o=(o?o->next:NULL)) {
sql_idx *ci = n->data;
sql_idx *oi = m->data;
@@ -2826,6 +2841,7 @@ update_table(sql_trans *tr, sql_table *f
if (ATOMIC_GET(&store_nr_active) == 1 ||
(ci->base.wtime && ci->base.allocated)) {
if (ATOMIC_GET(&store_nr_active) > 1 &&
ci->data) { /* move delta */
sql_delta *b = ci->data;
+ sql_idx *oldi = NULL;
if (!oi->data)
oi->base.allocated =
ci->base.allocated;
@@ -2839,12 +2855,16 @@ update_table(sql_trans *tr, sql_table *f
bat_destroy(b->cached);
b->cached = NULL;
}
- while (b && b->wtime >= oldest->stime)
- b = b->next;
- if (b && b->next) {
+ if (o)
+ oldi = o->data;
+ if (oldi && b && oldi->base.id ==
ci->base.id && b->wtime < oldi->base.stime) {
+ while (b && b->wtime >=
oldi->base.stime)
+ b = b->next;
/* anything older can go */
- delayed_destroy_bat(b->next);
- b->next = NULL;
+ if (b && b->next && b->wtime >=
oldi->base.stime) {
+
delayed_destroy_bat(b->next);
+ b->next = NULL;
+ }
}
} else if (oi->data && ci->base.allocated) {
if (tr_update_delta(tr, oi->data,
ci->data, 0) != LOG_OK)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list