Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions schemachange/sc_alter_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ int do_alter_table(struct ireq *iq, struct schema_change_type *s,

/* set sc_genids, 0 them if we are starting a new schema change, or
* restore them to their previous values if we are resuming */
if (init_sc_genids(newdb, s)) {
if (init_sc_genids(newdb, &db->sc_genids, s)) {
sc_errf(s, "failed initilizing sc_genids\n");
delete_temp_table(iq, newdb);
change_schemas_recover(s->tablename);
Expand All @@ -605,19 +605,19 @@ int do_alter_table(struct ireq *iq, struct schema_change_type *s,
assert(db->sharding_func);
for (i = 0; i < newdb->dtastripe; i++) {
for (int shard = 0; shard < db->sharding_arg->n - 1; shard++) {
if (newdb->sc_genids[i] < db->sharding_arg->cs[shard].resume_genids[i]) {
if (db->sc_genids[i] < db->sharding_arg->cs[shard].resume_genids[i]) {
logmsg(LOGMSG_INFO, "%s updating %s stripe %d sc_genid from %llx (%lld) to %llx (%lld) using %s\n",
__func__, s->tablename, i, newdb->sc_genids[i], newdb->sc_genids[i],
__func__, s->tablename, i, db->sc_genids[i], db->sc_genids[i],
db->sharding_arg->cs[shard].resume_genids[i], db->sharding_arg->cs[shard].resume_genids[i],
db->sharding_arg->ss[shard]->tablename);
newdb->sc_genids[i] = db->sharding_arg->cs[shard].resume_genids[i];
db->sc_genids[i] = db->sharding_arg->cs[shard].resume_genids[i];
}
}
}
}
for (i = 0; i < newdb->dtastripe; i++) {
logmsg(LOGMSG_INFO, "%s: %s stripe %d result resume genid %llx (%lld)\n", __func__, s->tablename, i,
newdb->sc_genids[i], newdb->sc_genids[i]);
db->sc_genids[i], db->sc_genids[i]);
}

Pthread_rwlock_wrlock(&db->sc_live_lk);
Expand Down Expand Up @@ -675,7 +675,7 @@ int do_alter_table(struct ireq *iq, struct schema_change_type *s,
changed == SC_CONSTRAINT_CHANGE) {
if (!s->live)
gbl_readonly_sc = 1;
rc = convert_all_records(db, newdb, newdb->sc_genids, s);
rc = convert_all_records(db, newdb, db->sc_genids, s);
if (rc == 1) rc = 0;
} else
rc = 0;
Expand Down Expand Up @@ -719,8 +719,7 @@ int do_alter_table(struct ireq *iq, struct schema_change_type *s,
live_sc_off(db);

for (i = 0; i < gbl_dtastripe; i++) {
sc_errf(s, " > [%s] stripe %2d was at 0x%016llx\n", s->tablename,
i, newdb->sc_genids[i]);
sc_errf(s, " > [%s] stripe %2d was at 0x%016llx\n", s->tablename, i, db->sc_genids[i]);
}

while (s->logical_livesc) {
Expand Down Expand Up @@ -798,7 +797,7 @@ static int do_merge_table(struct ireq *iq, struct schema_change_type *s,

/* set sc_genids, 0 them if we are starting a new schema change, or
* restore them to their previous values if we are resuming */
if (init_sc_genids(newdb, s)) {
if (init_sc_genids(newdb, &db->sc_genids, s)) {
sc_client_error(s, "Failed to initialize sc_genids");
return -1;
}
Expand Down Expand Up @@ -848,7 +847,7 @@ static int do_merge_table(struct ireq *iq, struct schema_change_type *s,

/* skip converting records for fastinit and planned schema change
* that doesn't require rebuilding anything. */
rc = convert_all_records(db, newdb, newdb->sc_genids, s);
rc = convert_all_records(db, newdb, db->sc_genids, s);
if (rc == 1) rc = 0;

remove_ongoing_alter(s);
Expand Down Expand Up @@ -886,8 +885,7 @@ static int do_merge_table(struct ireq *iq, struct schema_change_type *s,
live_sc_off(db);

for (i = 0; i < gbl_dtastripe; i++) {
sc_errf(s, " > [%s] stripe %2d was at 0x%016llx\n", s->tablename,
i, newdb->sc_genids[i]);
sc_errf(s, " > [%s] stripe %2d was at 0x%016llx\n", s->tablename, i, db->sc_genids[i]);
}

while (s->logical_livesc) {
Expand Down Expand Up @@ -1259,7 +1257,7 @@ int do_upgrade_table_int(struct schema_change_type *s)
sc_printf(s, "Starting FULL table upgrade.\n");
}

if (init_sc_genids(db, s)) {
if (init_sc_genids(db, &db->sc_genids, s)) {
sc_errf(s, "failed initilizing sc_genids\n");
return SC_LLMETA_ERR;
}
Expand Down
3 changes: 1 addition & 2 deletions schemachange/sc_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ int live_sc_post_update_delayed_key_adds(struct ireq *iq, void *trans, unsigned
#endif
/* need to check where the cursor is, even tho that check was done once in
* post_update */
int is_gen_gt_scptr = is_genid_right_of_stripe_pointer(
iq->usedb->handle, newgenid, usedb->sc_to->sc_genids);
int is_gen_gt_scptr = is_genid_right_of_stripe_pointer(iq->usedb->handle, newgenid, usedb->sc_from->sc_genids);
if (is_gen_gt_scptr) {
if (iq->debug) {
reqprintf(iq, "%s: skip genid 0x%llx to the right of scptr", __func__, newgenid);
Expand Down
4 changes: 4 additions & 0 deletions schemachange/sc_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,10 @@ int backout_schema_changes(struct ireq *iq, tran_type *tran)
backout_constraint_pointers(s->newdb, s->db);
}
change_schemas_recover(s->db->tablename);
if (s->db->sc_genids) {
free(s->db->sc_genids);
s->db->sc_genids = NULL;
}
}
/* TODO: (NC) Also delete view? */
sc_del_unused_files_tran(s->db, tran);
Expand Down
15 changes: 8 additions & 7 deletions schemachange/sc_records.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ static inline void lkcounter_check(struct convert_record_data *data, int now)
* If success it returns 0, if failure it returns <0 */
int gbl_debug_stall_in_oplog_seed = 0;

int init_sc_genids(struct dbtable *db, struct schema_change_type *s)
int init_sc_genids(struct dbtable *db, unsigned long long **p_sc_genids, struct schema_change_type *s)
{
void *rec;
int orglen, bdberr, stripe;
unsigned long long *sc_genids;
unsigned long long *sc_genids = *p_sc_genids;

if (db->sc_genids == NULL) {
db->sc_genids = malloc(sizeof(unsigned long long) * MAXDTASTRIPE);
if (db->sc_genids == NULL) {
if (sc_genids == NULL) {
sc_genids = malloc(sizeof(unsigned long long) * MAXDTASTRIPE);
if (sc_genids == NULL) {
logmsg(LOGMSG_ERROR,
"init_sc_genids: failed to allocate sc_genids\n");
return -1;
}
}

sc_genids = db->sc_genids;
*p_sc_genids = sc_genids;

/* if we aren't resuming simply zero the genids */
if (!s->resume) {
Expand Down Expand Up @@ -284,9 +284,10 @@ int init_sc_genids(struct dbtable *db, struct schema_change_type *s)
stripe);
sc_genids[stripe] = 0ULL;
}
} else
} else {
rc = bdb_get_high_genid(db->tablename, stripe, &sc_genids[stripe],
&bdberr);
}
if (rc < 0 || bdberr != BDBERR_NOERROR) {
sc_errf(s, "init_sc_genids: failed to find newest genid for "
"stripe: %d\n",
Expand Down
2 changes: 1 addition & 1 deletion schemachange/sc_records.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int upgrade_all_records(struct dbtable *db, unsigned long long *sc_genids,

void convert_record_data_cleanup(struct convert_record_data *data);

int init_sc_genids(struct dbtable *db, struct schema_change_type *s);
int init_sc_genids(struct dbtable *db, unsigned long long **p_sc_genids, struct schema_change_type *s);

void live_sc_enter_exclusive_all(bdb_state_type *, tran_type *);

Expand Down
3 changes: 1 addition & 2 deletions schemachange/sc_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,7 @@ void verify_schema_change_constraint(struct ireq *iq, void *trans,
if (usedb->sc_to->n_constraints == 0)
goto unlock;

if (is_genid_right_of_stripe_pointer(usedb->handle, newgenid,
usedb->sc_to->sc_genids)) {
if (is_genid_right_of_stripe_pointer(usedb->handle, newgenid, usedb->sc_from->sc_genids)) {
goto unlock;
}

Expand Down
8 changes: 3 additions & 5 deletions schemachange/schemachange.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,7 @@ int live_sc_post_delete_int(struct ireq *iq, void *trans,
return 0;
}

if (is_genid_right_of_stripe_pointer(iq->usedb->handle, genid,
iq->usedb->sc_to->sc_genids)) {
if (is_genid_right_of_stripe_pointer(iq->usedb->handle, genid, iq->usedb->sc_from->sc_genids)) {
return 0;
}

Expand Down Expand Up @@ -690,8 +689,7 @@ int live_sc_post_add_int(struct ireq *iq, void *trans, unsigned long long genid,
return 0;
}

if (is_genid_right_of_stripe_pointer(iq->usedb->handle, genid,
iq->usedb->sc_to->sc_genids)) {
if (is_genid_right_of_stripe_pointer(iq->usedb->handle, genid, iq->usedb->sc_from->sc_genids)) {
return 0;
}

Expand Down Expand Up @@ -779,7 +777,7 @@ int live_sc_post_update_int(struct ireq *iq, void *trans,
return 0;
}

unsigned long long *sc_genids = iq->usedb->sc_to->sc_genids;
unsigned long long *sc_genids = iq->usedb->sc_from->sc_genids;
if (iq->debug) {
reqpushprefixf(iq, "live_sc_post_update: ");
}
Expand Down
8 changes: 8 additions & 0 deletions tests/timepart_noneres.test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ifeq ($(TESTSROOTDIR),)
include ../testcase.mk
else
include $(TESTSROOTDIR)/testcase.mk
endif
ifeq ($(TEST_TIMEOUT),)
export TEST_TIMEOUT=5m
endif
1 change: 1 addition & 0 deletions tests/timepart_noneres.test/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This tests resuming a time partition collapse.
3 changes: 3 additions & 0 deletions tests/timepart_noneres.test/lrl.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table t t.csc2
init_with_genid48 0
multitable_ddl 1
122 changes: 122 additions & 0 deletions tests/timepart_noneres.test/output.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"NAME" : "t",
"PERIOD" : "daily",
"RETENTION" : 7,
"SHARD0NAME": "<none>",
"ROLLOUT" : "TRUNCATE",
"TABLES" :
[
{
"TABLENAME" : "$0_F64CD191",
},
{
"TABLENAME" : "$1_A2620AE4",
},
{
"TABLENAME" : "$2_C429139B",
},
{
"TABLENAME" : "$3_8A26EC5C",
},
{
"TABLENAME" : "$4_3FDAE1EA",
},
{
"TABLENAME" : "$5_9FEC23C1",
},
{
"TABLENAME" : "$6_93A67B48",
}
]
}
]
(name='t', period='daily', retention=7, nshards=7, version=1, shard0name='<none>')
(name='t', shardname='$0_F64CD191')
(name='t', shardname='$1_A2620AE4')
(name='t', shardname='$2_C429139B')
(name='t', shardname='$3_8A26EC5C')
(name='t', shardname='$4_3FDAE1EA')
(name='t', shardname='$5_9FEC23C1')
(name='t', shardname='$6_93A67B48')
(rows inserted=5)
(rows inserted=10)
(rows inserted=10)
(rows inserted=10)
(rows inserted=10)
(rows inserted=10)
(rows inserted=10)
(rows inserted=5)
[]

(count(*)=70)
(a=6, b=NULL)
(a=7, b=NULL)
(a=8, b=NULL)
(a=9, b=NULL)
(a=10, b=NULL)
(a=16, b=NULL)
(a=17, b=NULL)
(a=18, b=NULL)
(a=19, b=NULL)
(a=20, b=NULL)
(a=26, b=NULL)
(a=27, b=NULL)
(a=28, b=NULL)
(a=29, b=NULL)
(a=30, b=NULL)
(a=31, b=NULL)
(a=32, b=NULL)
(a=33, b=NULL)
(a=34, b=NULL)
(a=35, b=NULL)
(a=36, b=NULL)
(a=37, b=NULL)
(a=38, b=NULL)
(a=39, b=NULL)
(a=40, b=NULL)
(a=46, b=NULL)
(a=47, b=NULL)
(a=48, b=NULL)
(a=49, b=NULL)
(a=50, b=NULL)
(a=51, b=NULL)
(a=52, b=NULL)
(a=53, b=NULL)
(a=54, b=NULL)
(a=55, b=NULL)
(a=56, b=NULL)
(a=57, b=NULL)
(a=58, b=NULL)
(a=59, b=NULL)
(a=60, b=NULL)
(a=61, b=NULL)
(a=62, b=NULL)
(a=63, b=NULL)
(a=64, b=NULL)
(a=65, b=NULL)
(a=66, b=NULL)
(a=67, b=NULL)
(a=68, b=NULL)
(a=69, b=NULL)
(a=70, b=NULL)
(a=1021, b=NULL)
(a=1022, b=NULL)
(a=1023, b=NULL)
(a=1024, b=NULL)
(a=1025, b=NULL)
(a=1041, b=NULL)
(a=1042, b=NULL)
(a=1043, b=NULL)
(a=1044, b=NULL)
(a=1045, b=NULL)
(a=2001, b=NULL)
(a=2002, b=NULL)
(a=2003, b=NULL)
(a=2004, b=NULL)
(a=2005, b=NULL)
(a=2006, b=NULL)
(a=2007, b=NULL)
(a=2008, b=NULL)
(a=2009, b=NULL)
(a=2010, b=NULL)
Loading
Loading