Skip to content

Commit

Permalink
Default schema change saving to 7.0 format to allow schema changes to…
Browse files Browse the repository at this point in the history
… race with server upgrade.

Signed-off-by: Dorin Hogea <dhogea@bloomberg.net>
  • Loading branch information
dorinhogea committed May 23, 2024
1 parent bd2abe4 commit 92b71f8
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 61 deletions.
4 changes: 3 additions & 1 deletion bdb/llmeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -10943,7 +10943,8 @@ int bdb_del_view(tran_type *t, const char *view_name)
}

#include "schemachange.h"

#if 0
rqid is 1
/*
DRQS-170879936:
Expand Down Expand Up @@ -10991,3 +10992,4 @@ void *buf_get_schemachange(struct schema_change_type *s, void *p_buf,
}
return NULL;
}
#endif
1 change: 1 addition & 0 deletions db/db_tunables.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ extern int gbl_timer_warn_interval;
int gbl_incoherent_clnt_wait = 0;
int gbl_new_leader_duration = 3;
extern int gbl_transaction_grace_period;
extern int gbl_sc_7format;
extern int gbl_dohsql_joins;

/*
Expand Down
4 changes: 4 additions & 0 deletions db/db_tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,10 @@ REGISTER_TUNABLE("transaction_grace_period",
"Time to wait for connections with pending transactions to go away on exit. (Default: 60)",
TUNABLE_INTEGER, &gbl_transaction_grace_period, 0, NULL, NULL, NULL, NULL);

REGISTER_TUNABLE("sc_7format",
"Save schema change object in 7.0 format",
TUNABLE_BOOLEAN, &gbl_sc_7format, INTERNAL, NULL, NULL, NULL, NULL);

REGISTER_TUNABLE("dohsql_joins",
"Enable to support joins in parallel sql execution (default: on)",
TUNABLE_BOOLEAN, &gbl_dohsql_joins, 0, NULL, NULL, NULL, NULL);
Expand Down
38 changes: 10 additions & 28 deletions db/osqlcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7759,10 +7759,7 @@ int osql_send_schemachange(osql_target_t *target, unsigned long long rqid,
{

schemachange_packed_size(sc);
size_t osql_rpl_size =
((rqid == OSQL_RQID_USE_UUID) ? OSQLCOMM_UUID_RPL_TYPE_LEN
: OSQLCOMM_RPL_TYPE_LEN) +
sc->packed_len;
size_t osql_rpl_size = OSQLCOMM_UUID_RPL_TYPE_LEN + sc->packed_len;
uint8_t *buf = alloca(osql_rpl_size);
uint8_t *p_buf = buf;
uint8_t *p_buf_end = p_buf + osql_rpl_size;
Expand All @@ -7773,32 +7770,17 @@ int osql_send_schemachange(osql_target_t *target, unsigned long long rqid,

strcpy(sc->original_master_node, target->host);

if (rqid == OSQL_RQID_USE_UUID) {
osql_uuid_rpl_t hd_uuid = {0};
osql_uuid_rpl_t hd_uuid = {0};

hd_uuid.type = OSQL_SCHEMACHANGE;
comdb2uuidcpy(hd_uuid.uuid, uuid);
if (!(p_buf = osqlcomm_schemachange_uuid_rpl_type_put(
&hd_uuid, sc, p_buf, p_buf_end))) {
logmsg(LOGMSG_ERROR, "%s:%s returns NULL\n", __func__,
"osqlcomm_schemachange_uuid_rpl_type_put");
return -1;
}

type = osql_net_type_to_net_uuid_type(NET_OSQL_SOCK_RPL);
} else {
osql_rpl_t hd = {0};

hd.type = OSQL_SCHEMACHANGE;
hd.sid = rqid;

if (!(p_buf = osqlcomm_schemachange_rpl_type_put(&hd, sc, p_buf,
p_buf_end))) {
logmsg(LOGMSG_ERROR, "%s:%s returns NULL\n", __func__,
"osqlcomm_schemachange_rpl_type_put");
return -1;
}
hd_uuid.type = OSQL_SCHEMACHANGE;
comdb2uuidcpy(hd_uuid.uuid, uuid);
if (!(p_buf = osqlcomm_schemachange_uuid_rpl_type_put(
&hd_uuid, sc, p_buf, p_buf_end))) {
logmsg(LOGMSG_ERROR, "%s:%s returns NULL\n", __func__,
"osqlcomm_schemachange_uuid_rpl_type_put");
return -1;
}
type = osql_net_type_to_net_uuid_type(NET_OSQL_SOCK_RPL);

if (gbl_enable_osql_logging) {
logmsg(LOGMSG_DEBUG, "[%llu %s] send OSQL_SCHEMACHANGE %s\n", rqid,
Expand Down
Loading

0 comments on commit 92b71f8

Please sign in to comment.