Skip to content

Commit 3293fb9

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

File tree

7 files changed

+45
-3
lines changed

7 files changed

+45
-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
@@ -2379,6 +2379,10 @@ REGISTER_TUNABLE("merge_table_enabled",
23792379
TUNABLE_BOOLEAN, &gbl_merge_table_enabled, 0, NULL, NULL,
23802380
NULL, NULL);
23812381

2382+
REGISTER_TUNABLE("allow_old_authn", "Reuse old successful authentication for the connection",
2383+
TUNABLE_BOOLEAN, &gbl_allow_old_authn, NOARG | READEARLY,
2384+
NULL, NULL, NULL, NULL);
2385+
23822386
REGISTER_TUNABLE("externalauth", NULL, TUNABLE_BOOLEAN, &gbl_uses_externalauth, NOARG | READEARLY,
23832387
NULL, NULL, NULL, NULL);
23842388

db/sql.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ struct plugin_callbacks {
501501
plugin_func *local_check; /* newsql_local_check_evbuffer */
502502
plugin_func *peer_check; /* newsql_peer_check_evbuffer */
503503
auth_func *get_authdata; /* newsql_get_authdata */
504+
plugin_func *free_authdata; /* newsql_free_authdata */
504505
api_type_func *api_type; /* newsql_api_type */
505506

506507
/* Optional */
@@ -567,6 +568,7 @@ struct plugin_callbacks {
567568
make_plugin_callback(clnt, name, local_check); \
568569
make_plugin_callback(clnt, name, peer_check); \
569570
make_plugin_callback(clnt, name, get_authdata); \
571+
make_plugin_callback(clnt, name, free_authdata); \
570572
make_plugin_callback(clnt, name, api_type); \
571573
make_plugin_optional_null(clnt, count); \
572574
make_plugin_optional_null(clnt, type); \
@@ -597,6 +599,7 @@ int clr_high_availability(struct sqlclntstate *);
597599
uint64_t get_client_starttime(struct sqlclntstate *);
598600
int get_client_retries(struct sqlclntstate *);
599601
void *get_authdata(struct sqlclntstate *);
602+
void free_authdata(struct sqlclntstate *);
600603
char *clnt_tzname(struct sqlclntstate *, sqlite3_stmt *);
601604

602605
struct clnt_ddl_context {

db/sqlinterfaces.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,12 @@ void *get_authdata(struct sqlclntstate *clnt)
576576
return clnt->plugin.get_authdata(clnt);
577577
}
578578

579+
void free_authdata(struct sqlclntstate *clnt)
580+
{
581+
if (clnt && clnt->plugin.free_authdata)
582+
clnt->plugin.free_authdata(clnt);
583+
}
584+
579585
static int skip_row(struct sqlclntstate *clnt, uint64_t rowid)
580586
{
581587
return clnt->plugin.skip_row(clnt, rowid);
@@ -5245,7 +5251,7 @@ void cleanup_clnt(struct sqlclntstate *clnt)
52455251
memset(clnt->work.aFingerprint, 0, FINGERPRINTSZ);
52465252

52475253
clear_session_tbls(clnt);
5248-
free(clnt->authdata);
5254+
free_authdata(clnt);
52495255
clnt->authdata = NULL;
52505256

52515257
free_client_adj_col_names(clnt);
@@ -5277,6 +5283,18 @@ void cleanup_clnt(struct sqlclntstate *clnt)
52775283
int gbl_unexpected_last_type_warn = 1;
52785284
int gbl_unexpected_last_type_abort = 0;
52795285

5286+
int cdb2_in_client_trans() {
5287+
struct sql_thread *thd = pthread_getspecific(query_info_key);
5288+
if (thd == NULL)
5289+
return 0;
5290+
5291+
struct sqlclntstate *clnt = thd->clnt;
5292+
if (clnt == NULL)
5293+
return 0;
5294+
5295+
return clnt->in_client_trans;
5296+
}
5297+
52805298
void reset_clnt(struct sqlclntstate *clnt, int initial)
52815299
{
52825300
if (initial) {
@@ -5431,7 +5449,7 @@ void reset_clnt(struct sqlclntstate *clnt, int initial)
54315449
}
54325450
free(clnt->context);
54335451
if (clnt->authdata) {
5434-
free(clnt->authdata);
5452+
free_authdata(clnt);
54355453
clnt->authdata = NULL;
54365454
}
54375455
clnt->context = NULL;
@@ -6814,6 +6832,10 @@ void *internal_get_authdata(struct sqlclntstate *a)
68146832
return a->authdata;
68156833
return NULL;
68166834
}
6835+
int internal_free_authdata(struct sqlclntstate *a)
6836+
{
6837+
return 0;
6838+
}
68176839
static int internal_local_check(struct sqlclntstate *a)
68186840
{
68196841
return 1;

plugins/newsql/newsql.c

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

25322532
void *(*externalMakeNewsqlAuthData)(void *, CDB2SQLQUERY__IdentityBlob *id) = NULL;
2533+
void (*externalFreeNewsqlAuthData)(void *) = NULL;
25332534

25342535
static void *newsql_get_authdata(struct sqlclntstate *clnt)
25352536
{
@@ -2547,12 +2548,21 @@ static void *newsql_get_authdata(struct sqlclntstate *clnt)
25472548

25482549
}
25492550
if (clnt->authdata) {
2550-
free(clnt->authdata);
2551+
externalFreeNewsqlAuthData(clnt->authdata);
25512552
clnt->authdata = NULL;
25522553
}
25532554
return NULL;
25542555
}
25552556

2557+
static int newsql_free_authdata(struct sqlclntstate *clnt)
2558+
{
2559+
if (clnt->authdata) {
2560+
externalFreeNewsqlAuthData(clnt->authdata);
2561+
clnt->authdata = NULL;
2562+
}
2563+
return 0;
2564+
}
2565+
25562566
void newsql_setup_clnt(struct sqlclntstate *clnt)
25572567
{
25582568
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)