Changeset: 74d34475b622 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74d34475b622 Modified Files: monetdb5/optimizer/opt_pushselect.c sql/server/sql_partition.c sql/storage/bat/bat_storage.c sql/storage/sql_storage.h sql/storage/store.c Branch: Jun2020 Log Message:
added cleanup of transaction's when the allocator become too large (2x the gtrans size) fixed crash where types were coming from the incorrect allocator diffs (162 lines): diff --git a/monetdb5/optimizer/opt_pushselect.c b/monetdb5/optimizer/opt_pushselect.c --- a/monetdb5/optimizer/opt_pushselect.c +++ b/monetdb5/optimizer/opt_pushselect.c @@ -697,6 +697,7 @@ OPTpushselectImplementation(Client cntxt actions++; } } + assert (p == old[i] || oclean[i]); pushInstruction(mb,p); } for (j=1; j<i; j++) diff --git a/sql/server/sql_partition.c b/sql/server/sql_partition.c --- a/sql/server/sql_partition.c +++ b/sql/server/sql_partition.c @@ -308,7 +308,7 @@ initialize_sql_parts(mvc *sql, sql_table find_partition_type(&found, mt); localtype = found.type->localtype; if (isPartitionedByExpressionTable(mt)) /* Propagate type to outer transaction table */ - dup_sql_type(tr, mt->s, &(mt->part.pexp->type), &(mt->po->part.pexp->type)); + mt->po->part.pexp->type = mt->part.pexp->type; if (localtype != TYPE_str && mt->members.set && list_length(mt->members.set)) { list *new = sa_list(tr->sa), *old = sa_list(tr->sa); @@ -320,7 +320,7 @@ initialize_sql_parts(mvc *sql, sql_table base_init(tr->sa, &p->base, pt->base.id, TR_NEW, pt->base.name); p->t = mt; assert(isMergeTable(mt) || isReplicaTable(mt)); - dup_sql_type(tr, mt->s, &found, &(p->tpe)); + p->tpe = found; p->with_nills = next->with_nills; if (isListPartitionTable(mt)) { 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 @@ -2757,7 +2757,6 @@ update_table(sql_trans *tr, sql_table *f } } - dup_sql_type(tr->parent, ft->s, &(cc->type), &(oc->type)); oc->colnr = cc->colnr; oc->null = cc->null; oc->unique = cc->unique; diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h --- a/sql/storage/sql_storage.h +++ b/sql/storage/sql_storage.h @@ -506,6 +506,4 @@ extern sql_part *sql_trans_copy_part(sql extern void sql_trans_drop_any_comment(sql_trans *tr, sqlid id); extern void sql_trans_drop_obj_priv(sql_trans *tr, sqlid obj_id); -extern void dup_sql_type(sql_trans *tr, sql_schema *os, sql_subtype *oc, sql_subtype *nc); - #endif /*SQL_STORAGE_H */ diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -37,8 +37,6 @@ int store_readonly = 0; int store_singleuser = 0; int store_initialized = 0; -backend_stack backend_stk; - store_functions store_funcs; table_functions table_funcs; logger_functions logger_funcs; @@ -1660,18 +1658,18 @@ create_sql_table(sql_allocator *sa, cons return create_sql_table_with_id(sa, next_oid(), name, type, system, persistence, commit_action, properties); } -void -dup_sql_type(sql_trans *tr, sql_schema *os, sql_subtype *oc, sql_subtype *nc) +static void +dup_sql_type(sql_trans *tr, sql_schema *s, sql_subtype *oc, sql_subtype *nc) { nc->digits = oc->digits; nc->scale = oc->scale; nc->type = oc->type; - if (os && nc->type->s) { /* user type */ + if (s && nc->type->s) { /* user type */ sql_type *lt = NULL; - if (os->base.id == nc->type->s->base.id) { + if (s->base.id == nc->type->s->base.id) { /* Current user type belongs to current schema. So search there for current user type. */ - lt = find_sql_type(os, nc->type->base.name); + lt = find_sql_type(s, nc->type->base.name); } else { /* Current user type belongs to another schema in the current transaction. Search there for current user type. */ lt = sql_trans_bind_type(tr, NULL, nc->type->base.name); @@ -1851,7 +1849,7 @@ store_schema_number(void) } static int -store_load(void) { +store_load(backend_stack stk) { int first; sql_allocator *sa; @@ -1878,7 +1876,7 @@ store_load(void) { if (!sequences_init()) return -1; - gtrans = tr = create_trans(sa, backend_stk); + gtrans = tr = create_trans(sa, stk); if (!gtrans) return -1; @@ -1889,7 +1887,7 @@ store_load(void) { /* cannot initialize database in readonly mode */ if (store_readonly) return -1; - tr = sql_trans_create(backend_stk, NULL, NULL, true); + tr = sql_trans_create(stk, NULL, NULL, true); if (!tr) { TRC_CRITICAL(SQL_STORE, "Failed to start a transaction while loading the storage\n"); return -1; @@ -2091,7 +2089,6 @@ store_init(int debug, store_type store, { int v = 1; - backend_stk = stk; store_readonly = readonly; store_singleuser = singleuser; @@ -2121,7 +2118,7 @@ store_init(int debug, store_type store, /* create the initial store structure or re-load previous data */ MT_lock_unset(&bs_lock); - return store_load(); + return store_load(stk); } static int @@ -4717,7 +4714,6 @@ reset_column(sql_trans *tr, sql_column * return LOG_ERR; } - dup_sql_type(tr, pfc->t->s, &(pfc->type), &(fc->type)); fc->null = pfc->null; fc->unique = pfc->unique; fc->colnr = pfc->colnr; @@ -6355,7 +6351,7 @@ create_sql_column(sql_trans *tr, sql_tab sql_column *col = SA_ZNEW(tr->sa, sql_column); base_init(tr->sa, &col->base, next_oid(), TR_NEW, name); - dup_sql_type(tr, t->s, tpe, &(col->type)); + col->type = *tpe; col->def = NULL; col->null = 1; col->colnr = table_next_column_nr(t); @@ -7467,9 +7463,9 @@ sql_trans_begin(sql_session *s) snr = tr->schema_number; TRC_DEBUG(SQL_STORE, "Enter sql_trans_begin for transaction: %d\n", snr); if (tr->parent && tr->parent == gtrans && - (tr->stime < gtrans->wstime || tr->wtime || + (tr->stime < gtrans->wstime || tr->wtime || tr->sa->nr > (2*gtrans->sa->nr) || store_schema_number() != snr)) { - if (!list_empty(tr->moved_tables)) { + if (!list_empty(tr->moved_tables) || tr->sa->nr > (2*gtrans->sa->nr)) { sql_trans_destroy(tr, false); s->tr = tr = sql_trans_create(s->stk, NULL, NULL, false); } else { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list