From 29be87c837ac62652eaf77ea36204a81dcde54d8 Mon Sep 17 00:00:00 2001 From: Dorin Hogea Date: Thu, 5 Dec 2024 15:00:52 -0500 Subject: [PATCH] Avoid reading llmeta disableskipscan tunable for all tables during analyze stat load. Instead, read at the server start and when that tunable changes for any table (which is signaled by a scdone sc_analyze message). Signed-off-by: Dorin Hogea --- db/comdb2.c | 3 +++ db/comdb2.h | 2 ++ db/sqlinterfaces.c | 7 +++++++ sqlite/src/analyze.c | 5 ----- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/db/comdb2.c b/db/comdb2.c index 6e5cc75fbc..f50170f4d5 100644 --- a/db/comdb2.c +++ b/db/comdb2.c @@ -5601,6 +5601,9 @@ int main(int argc, char **argv) exit(1); } + /* read disableskipscan here */ + get_disable_skipscan_all(); + /* Place a freeze on tunables' registration. This is done to avoid multiple re-registration during the creation of temp diff --git a/db/comdb2.h b/db/comdb2.h index a23e824d08..457a76ab5e 100644 --- a/db/comdb2.h +++ b/db/comdb2.h @@ -3673,4 +3673,6 @@ void csc2_allow_bools(void); void csc2_disallow_bools(void); int csc2_used_bools(void); +void get_disable_skipscan_all(); + #endif /* !INCLUDED_COMDB2_H */ diff --git a/db/sqlinterfaces.c b/db/sqlinterfaces.c index 3feed2c6d7..2db8a6c339 100644 --- a/db/sqlinterfaces.c +++ b/db/sqlinterfaces.c @@ -2594,6 +2594,13 @@ static int reload_analyze(struct sqlthdstate *thd, struct sqlclntstate *clnt, extern volatile int analyze_running_flag; if (analyze_running_flag) return 0; + + /* a change in disableskipscan comes on replicant as a sc_analyze scdone log + * read here the llmeta entries for that tunable (instead of deep down in + * sqlite3AnalysisLoad) + */ + get_disable_skipscan_all(); + int rc, got_curtran; rc = got_curtran = 0; if (!clnt->dbtran.cursor_tran) { diff --git a/sqlite/src/analyze.c b/sqlite/src/analyze.c index a12e06a8ff..b5b2b598b1 100644 --- a/sqlite/src/analyze.c +++ b/sqlite/src/analyze.c @@ -145,7 +145,6 @@ #if defined(SQLITE_BUILDING_FOR_COMDB2) #include int is_comdb2_index_disableskipscan(const char *); -void get_disable_skipscan_all(); #endif /* defined(SQLITE_BUILDING_FOR_COMDB2) */ #if defined(SQLITE_ENABLE_STAT4) @@ -2442,10 +2441,6 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ assert( iDb>=0 && iDbnDb ); assert( db->aDb[iDb].pBt!=0 ); -#if defined(SQLITE_BUILDING_FOR_COMDB2) - /* AZ: put disabler loader here */ - get_disable_skipscan_all(); -#endif /* defined(SQLITE_BUILDING_FOR_COMDB2) */ /* Clear any prior statistics */ assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){