Skip to content

Commit d675b5e

Browse files
committed
chunk: use socksql if txn is snapshot by default
Signed-off-by: Rivers Zhang <hzhang320@bloomberg.net>
1 parent abdf9a2 commit d675b5e

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

db/config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,8 @@ static int read_lrl_option(struct dbenv *dbenv, char *line,
12611261
} else if (tokcmp(tok, ltok, "enable_snapshot_isolation") == 0) {
12621262
gbl_snapisol = 1;
12631263
gbl_use_modsnap_for_snapshot = 1;
1264+
if (gbl_sql_tranlevel_default == gbl_snapshot_impl)
1265+
gbl_sql_tranlevel_default = TRANLEVEL_MODSNAP;
12641266
gbl_snapshot_impl = TRANLEVEL_MODSNAP;
12651267
gbl_modsnap_asof = 1;
12661268
} else if (tokcmp(tok, ltok, "enable_serial_isolation") == 0) {

db/process_message.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5144,6 +5144,8 @@ int process_command(struct dbenv *dbenv, char *line, int lline, int st)
51445144
}
51455145
} else if (tokcmp(tok, ltok, "do_not_use_modsnap_for_snapshot") == 0) {
51465146
gbl_use_modsnap_for_snapshot = 0;
5147+
if (gbl_sql_tranlevel_default == gbl_snapshot_impl)
5148+
gbl_sql_tranlevel_default = TRANLEVEL_SNAPISOL;
51475149
gbl_snapshot_impl = TRANLEVEL_SNAPISOL;
51485150
} else if (tokcmp(tok, ltok, "del_llmeta_comdb2_seqno") == 0) {
51495151
bdb_del_seqno(NULL);

plugins/newsql/newsql.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,9 +1746,18 @@ int process_set_commands(struct sqlclntstate *clnt, CDB2SQLQUERY *sql_query)
17461746
sqlstr);
17471747
rc = ii + 1;
17481748
} else if (clnt->dbtran.mode != TRANLEVEL_SOSQL) {
1749-
snprintf(err, sizeof(err),
1750-
"transaction chunks require SOCKSQL transaction mode");
1751-
rc = ii + 1;
1749+
int snapshot_by_default =
1750+
(clnt->dbtran.mode == TRANLEVEL_MODSNAP && gbl_sql_tranlevel_default == TRANLEVEL_MODSNAP);
1751+
if (snapshot_by_default) {
1752+
logmsg(LOGMSG_DEBUG, "snapshot is on by default, use socksql instead\n");
1753+
clnt->dbtran.mode = TRANLEVEL_SOSQL;
1754+
clnt->dbtran.maxchunksize = tmp;
1755+
/* in chunked mode, we disable verify retries */
1756+
clnt->verifyretry_off = 1;
1757+
} else {
1758+
snprintf(err, sizeof(err), "transaction chunks require SOCKSQL transaction mode");
1759+
rc = ii + 1;
1760+
}
17521761
} else {
17531762
clnt->dbtran.maxchunksize = tmp;
17541763
/* in chunked mode, we disable verify retries */
@@ -1792,9 +1801,15 @@ int process_set_commands(struct sqlclntstate *clnt, CDB2SQLQUERY *sql_query)
17921801
if (clnt->dbtran.mode == TRANLEVEL_INVALID) {
17931802
rc = ii + 1;
17941803
} else if (clnt->dbtran.mode != TRANLEVEL_SOSQL && clnt->dbtran.maxchunksize) {
1795-
snprintf(err, sizeof(err),
1796-
"transaction chunks require SOCKSQL transaction mode");
1797-
rc = ii + 1;
1804+
int snapshot_by_default =
1805+
(clnt->dbtran.mode == TRANLEVEL_MODSNAP && gbl_sql_tranlevel_default == TRANLEVEL_MODSNAP);
1806+
if (snapshot_by_default) {
1807+
logmsg(LOGMSG_DEBUG, "snapshot is on by default, use socksql instead\n");
1808+
clnt->dbtran.mode = TRANLEVEL_SOSQL;
1809+
} else {
1810+
snprintf(err, sizeof(err), "transaction chunks require SOCKSQL transaction mode");
1811+
rc = ii + 1;
1812+
}
17981813
}
17991814
}
18001815
} else if (strncasecmp(sqlstr, "timeout", 7) == 0) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enable_snapshot_isolation
2+
sql_tranlevel_default snapshot

0 commit comments

Comments
 (0)