Skip to content

Commit 2461444

Browse files
committed
{180374805} No timeout for successfully authenticated connections
Signed-off-by: mohitkhullar <mkhullar1@bloomberg.net>
1 parent e5c131f commit 2461444

File tree

7 files changed

+49
-3
lines changed

7 files changed

+49
-3
lines changed

db/comdb2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ int gbl_uses_password;
236236
int gbl_unauth_tag_access = 0;
237237
int64_t gbl_num_auth_allowed = 0;
238238
int64_t gbl_num_auth_denied = 0;
239+
int gbl_allow_old_authn = 1;
239240
int gbl_uses_externalauth = 0;
240241
int gbl_uses_externalauth_connect = 0;
241242
int gbl_externalauth_warn = 0;

db/comdb2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,7 @@ extern int gbl_maxreclen;
16321632
extern int gbl_penaltyincpercent;
16331633
extern int gbl_maxwthreadpenalty;
16341634

1635+
extern int gbl_allow_old_authn;
16351636
extern int gbl_uses_password;
16361637
extern int gbl_unauth_tag_access;
16371638
extern int gbl_uses_externalauth;

db/db_tunables.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,10 @@ REGISTER_TUNABLE("merge_table_enabled",
23832383
TUNABLE_BOOLEAN, &gbl_merge_table_enabled, 0, NULL, NULL,
23842384
NULL, NULL);
23852385

2386+
REGISTER_TUNABLE("allow_old_authn", "Reuse old successful authentication for the connection",
2387+
TUNABLE_BOOLEAN, &gbl_allow_old_authn, NOARG | READEARLY,
2388+
NULL, NULL, NULL, NULL);
2389+
23862390
REGISTER_TUNABLE("externalauth", NULL, TUNABLE_BOOLEAN, &gbl_uses_externalauth, NOARG | READEARLY,
23872391
NULL, NULL, NULL, NULL);
23882392

db/sql.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ struct plugin_callbacks {
490490
plugin_func *local_check; /* newsql_local_check_evbuffer */
491491
plugin_func *peer_check; /* newsql_peer_check_evbuffer */
492492
auth_func *get_authdata; /* newsql_get_authdata */
493+
plugin_func *free_authdata; /* newsql_free_authdata */
493494
api_type_func *api_type; /* newsql_api_type */
494495

495496
/* Optional */
@@ -556,6 +557,7 @@ struct plugin_callbacks {
556557
make_plugin_callback(clnt, name, local_check); \
557558
make_plugin_callback(clnt, name, peer_check); \
558559
make_plugin_callback(clnt, name, get_authdata); \
560+
make_plugin_callback(clnt, name, free_authdata); \
559561
make_plugin_callback(clnt, name, api_type); \
560562
make_plugin_optional_null(clnt, count); \
561563
make_plugin_optional_null(clnt, type); \
@@ -586,6 +588,7 @@ int clr_high_availability(struct sqlclntstate *);
586588
uint64_t get_client_starttime(struct sqlclntstate *);
587589
int get_client_retries(struct sqlclntstate *);
588590
void *get_authdata(struct sqlclntstate *);
591+
void free_authdata(struct sqlclntstate *);
589592
char *clnt_tzname(struct sqlclntstate *, sqlite3_stmt *);
590593

591594
struct clnt_ddl_context {

db/sqlinterfaces.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ void *get_authdata(struct sqlclntstate *clnt)
592592
return clnt->plugin.get_authdata(clnt);
593593
}
594594

595+
void free_authdata(struct sqlclntstate *clnt)
596+
{
597+
if (clnt && clnt->plugin.free_authdata)
598+
clnt->plugin.free_authdata(clnt);
599+
}
600+
595601
static int skip_row(struct sqlclntstate *clnt, uint64_t rowid)
596602
{
597603
return clnt->plugin.skip_row(clnt, rowid);
@@ -5251,7 +5257,7 @@ void cleanup_clnt(struct sqlclntstate *clnt)
52515257
memset(clnt->work.aFingerprint, 0, FINGERPRINTSZ);
52525258

52535259
clear_session_tbls(clnt);
5254-
free(clnt->authdata);
5260+
free_authdata(clnt);
52555261
clnt->authdata = NULL;
52565262

52575263
free_client_adj_col_names(clnt);
@@ -5283,6 +5289,22 @@ void cleanup_clnt(struct sqlclntstate *clnt)
52835289
int gbl_unexpected_last_type_warn = 1;
52845290
int gbl_unexpected_last_type_abort = 0;
52855291

5292+
/* Not final */
5293+
int cdb2_get_tid() {
5294+
struct sql_thread *thd = pthread_getspecific(query_info_key);
5295+
if (thd == NULL)
5296+
return 0;
5297+
5298+
struct sqlclntstate *clnt = thd->clnt;
5299+
if (clnt == NULL)
5300+
return 0;
5301+
5302+
if (clnt->dbtran.cursor_tran)
5303+
return clnt->dbtran.cursor_tran->id;
5304+
5305+
return 0;
5306+
}
5307+
52865308
void reset_clnt(struct sqlclntstate *clnt, int initial)
52875309
{
52885310
if (initial) {
@@ -5437,7 +5459,7 @@ void reset_clnt(struct sqlclntstate *clnt, int initial)
54375459
}
54385460
free(clnt->context);
54395461
if (clnt->authdata) {
5440-
free(clnt->authdata);
5462+
free_authdata(clnt);
54415463
clnt->authdata = NULL;
54425464
}
54435465
clnt->context = NULL;
@@ -7008,6 +7030,10 @@ void *internal_get_authdata(struct sqlclntstate *a)
70087030
return a->authdata;
70097031
return NULL;
70107032
}
7033+
int internal_free_authdata(struct sqlclntstate *a)
7034+
{
7035+
return 0;
7036+
}
70117037
static int internal_local_check(struct sqlclntstate *a)
70127038
{
70137039
return 1;

plugins/newsql/newsql.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2519,6 +2519,7 @@ void free_newsql_appdata(struct sqlclntstate *clnt)
25192519
}
25202520

25212521
void *(*externalMakeNewsqlAuthData)(void *, CDB2SQLQUERY__IdentityBlob *id) = NULL;
2522+
void (*externalFreeNewsqlAuthData)(void *) = NULL;
25222523

25232524
static void *newsql_get_authdata(struct sqlclntstate *clnt)
25242525
{
@@ -2536,12 +2537,21 @@ static void *newsql_get_authdata(struct sqlclntstate *clnt)
25362537

25372538
}
25382539
if (clnt->authdata) {
2539-
free(clnt->authdata);
2540+
externalFreeNewsqlAuthData(clnt->authdata);
25402541
clnt->authdata = NULL;
25412542
}
25422543
return NULL;
25432544
}
25442545

2546+
static int newsql_free_authdata(struct sqlclntstate *clnt)
2547+
{
2548+
if (clnt->authdata) {
2549+
externalFreeNewsqlAuthData(clnt->authdata);
2550+
clnt->authdata = NULL;
2551+
}
2552+
return 0;
2553+
}
2554+
25452555
void newsql_setup_clnt(struct sqlclntstate *clnt)
25462556
{
25472557
struct newsql_appdata *appdata = clnt->appdata;

tests/tunables.test/t00_all_tunables.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
(name='allow_mismatched_tag_size', description='Allow variants in padding in static tag struct sizes', type='BOOLEAN', value='OFF', read_only='N')
3131
(name='allow_negative_column_size', description='Allow negative column size in csc2 schema. Added mostly for backwards compatibility. (Default: off)', type='BOOLEAN', value='OFF', read_only='Y')
3232
(name='allow_offline_upgrades', description='Allow machines marked offline to become master.', type='BOOLEAN', value='OFF', read_only='N')
33+
(name='allow_old_authn', description='Reuse old successful authentication for the connection', type='BOOLEAN', value='ON', read_only='N')
3334
(name='allow_parallel_rep_on_pagesplit', description='allow parallel rep on pgsplit', type='BOOLEAN', value='ON', read_only='N')
3435
(name='allow_parallel_rep_on_prefix', description='allow parallel rep on bam_prefix', type='BOOLEAN', value='ON', read_only='N')
3536
(name='allow_portmux_route', description='', type='BOOLEAN', value='ON', read_only='Y')

0 commit comments

Comments
 (0)