Skip to content

Commit bb2d162

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

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

db/comdb2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ int gbl_selectv_rangechk = 0; /* disable selectv range check by default */
451451

452452
int gbl_sql_tranlevel_preserved = TRANLEVEL_SOSQL;
453453
int gbl_sql_tranlevel_default = TRANLEVEL_SOSQL;
454-
int gbl_snapshot_impl = TRANLEVEL_SNAPISOL;
454+
int gbl_snapshot_impl = TRANLEVEL_MODSNAP;
455455
int gbl_exit_alarm_sec = 300;
456456
int gbl_test_blkseq_replay_code = 0;
457457
int gbl_dump_blkseq = 0;

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)