Mercurial > hg > MonetDB
changeset 86168:cb28be30354f smart-merge-jan22
Undo changeset 52cba3e788de:
Keeping currently committing transaction amongst actives
is easier to work with after all.
| author | Aris Koning <aris.koning@monetdbsolutions.com> |
|---|---|
| date | Wed, 27 Jul 2022 10:17:17 +0200 |
| parents | 63bd719a1528 |
| children | 51f88573403f |
| files | sql/storage/bat/bat_storage.c sql/storage/store.c |
| diffstat | 2 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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])
--- 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;
