From 82a8cb658b541f556f6ac4fd900e0456d1b6c224 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Fri, 31 May 2024 16:22:05 -0700 Subject: [PATCH 1/3] skipQueryLog param --- libstuff/libstuff.cpp | 4 ++-- libstuff/libstuff.h | 2 +- sqlitecluster/SQLite.cpp | 4 ++-- sqlitecluster/SQLite.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libstuff/libstuff.cpp b/libstuff/libstuff.cpp index 095d8e08e..b9a389cd8 100644 --- a/libstuff/libstuff.cpp +++ b/libstuff/libstuff.cpp @@ -2535,7 +2535,7 @@ void SQueryLogClose() { // -------------------------------------------------------------------------- // Executes a SQLite query -int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipWarn) { +int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipWarn, bool skipQueryLog) { #define MAX_TRIES 3 // Execute the query and get the results uint64_t startTime = STimeNow(); @@ -2666,7 +2666,7 @@ int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int6 } uint64_t elapsed = STimeNow() - startTime; - if ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000) { + if (!skipQueryLog && ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000)) { // Avoid logging queries so long that we need dozens of lines to log them. string sqlToLog = sql.substr(0, 20000); SRedactSensitiveValues(sqlToLog); diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index bdd503b60..78f19f382 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -591,7 +591,7 @@ void SQueryLogOpen(const string& logFilename); void SQueryLogClose(); // Returns an SQLite result code. -int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false); +int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false, bool skipQueryLog = false); int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false); bool SQVerifyTable(sqlite3* db, const string& tableName, const string& sql); bool SQVerifyTableExists(sqlite3* db, const string& tableName); diff --git a/sqlitecluster/SQLite.cpp b/sqlitecluster/SQLite.cpp index bbe69c248..015a8ecde 100644 --- a/sqlitecluster/SQLite.cpp +++ b/sqlitecluster/SQLite.cpp @@ -475,7 +475,7 @@ string SQLite::read(const string& query) const { return result[0][0]; } -bool SQLite::read(const string& query, SQResult& result) const { +bool SQLite::read(const string& query, SQResult& result, bool skipQueryLog) const { uint64_t before = STimeNow(); bool queryResult = false; _queryCount++; @@ -486,7 +486,7 @@ bool SQLite::read(const string& query, SQResult& result) const { queryResult = true; } else { _isDeterministicQuery = true; - queryResult = !SQuery(_db, "read only query", query, result); + queryResult = !SQuery(_db, "read only query", query, result, 2000 * STIME_US_PER_MS, false, skipQueryLog); if (_isDeterministicQuery && queryResult) { _queryCache.emplace(make_pair(query, result)); } diff --git a/sqlitecluster/SQLite.h b/sqlitecluster/SQLite.h index 509ff47fb..fd99090bd 100644 --- a/sqlitecluster/SQLite.h +++ b/sqlitecluster/SQLite.h @@ -75,7 +75,7 @@ class SQLite { // Performs a read-only query (eg, SELECT). This can be done inside or outside a transaction. Returns true on // success, and fills the 'result' with the result of the query. - bool read(const string& query, SQResult& result) const; + bool read(const string& query, SQResult& result, bool skipQueryLog = false) const; // Performs a read-only query (eg, SELECT) that returns a single value. string read(const string& query) const; From d418d675d28da45cfdef624b0619d59a59ae507a Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 3 Jun 2024 11:26:26 -0700 Subject: [PATCH 2/3] sqlite read changes to skipInfoWarn --- sqlitecluster/SQLite.cpp | 4 ++-- sqlitecluster/SQLite.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sqlitecluster/SQLite.cpp b/sqlitecluster/SQLite.cpp index 015a8ecde..738e1a846 100644 --- a/sqlitecluster/SQLite.cpp +++ b/sqlitecluster/SQLite.cpp @@ -475,7 +475,7 @@ string SQLite::read(const string& query) const { return result[0][0]; } -bool SQLite::read(const string& query, SQResult& result, bool skipQueryLog) const { +bool SQLite::read(const string& query, SQResult& result, bool skipInfoWarn) const { uint64_t before = STimeNow(); bool queryResult = false; _queryCount++; @@ -486,7 +486,7 @@ bool SQLite::read(const string& query, SQResult& result, bool skipQueryLog) cons queryResult = true; } else { _isDeterministicQuery = true; - queryResult = !SQuery(_db, "read only query", query, result, 2000 * STIME_US_PER_MS, false, skipQueryLog); + queryResult = !SQuery(_db, "read only query", query, result, 2000 * STIME_US_PER_MS, skipInfoWarn); if (_isDeterministicQuery && queryResult) { _queryCache.emplace(make_pair(query, result)); } diff --git a/sqlitecluster/SQLite.h b/sqlitecluster/SQLite.h index fd99090bd..ae9e7b711 100644 --- a/sqlitecluster/SQLite.h +++ b/sqlitecluster/SQLite.h @@ -75,7 +75,7 @@ class SQLite { // Performs a read-only query (eg, SELECT). This can be done inside or outside a transaction. Returns true on // success, and fills the 'result' with the result of the query. - bool read(const string& query, SQResult& result, bool skipQueryLog = false) const; + bool read(const string& query, SQResult& result, bool skipInfoWarn = false) const; // Performs a read-only query (eg, SELECT) that returns a single value. string read(const string& query) const; From 32704184fa20ec399df72f9ed6364dc320d4330e Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 3 Jun 2024 11:26:41 -0700 Subject: [PATCH 3/3] SQuery changes to skipInfoWarn --- libstuff/libstuff.cpp | 10 +++++----- libstuff/libstuff.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libstuff/libstuff.cpp b/libstuff/libstuff.cpp index b9a389cd8..42544bcb6 100644 --- a/libstuff/libstuff.cpp +++ b/libstuff/libstuff.cpp @@ -2535,7 +2535,7 @@ void SQueryLogClose() { // -------------------------------------------------------------------------- // Executes a SQLite query -int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipWarn, bool skipQueryLog) { +int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipInfoWarn) { #define MAX_TRIES 3 // Execute the query and get the results uint64_t startTime = STimeNow(); @@ -2666,7 +2666,7 @@ int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int6 } uint64_t elapsed = STimeNow() - startTime; - if (!skipQueryLog && ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000)) { + if (!skipInfoWarn && ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000)) { // Avoid logging queries so long that we need dozens of lines to log them. string sqlToLog = sql.substr(0, 20000); SRedactSensitiveValues(sqlToLog); @@ -2703,7 +2703,7 @@ int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int6 // Only OK and commit conflicts are allowed without warning because they're the only "successful" results that we expect here. // OK means it succeeds, conflicts will get retried further up the call stack. - if (error != SQLITE_OK && extErr != SQLITE_BUSY_SNAPSHOT && !skipWarn) { + if (error != SQLITE_OK && extErr != SQLITE_BUSY_SNAPSHOT && !skipInfoWarn) { string sqlToLog = sql.substr(0, 20000); SRedactSensitiveValues(sqlToLog); @@ -3062,9 +3062,9 @@ string SQ(double val) { return SToStr(val); } -int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold, bool skipWarn) { +int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold, bool skipInfoWarn) { SQResult ignore; - return SQuery(db, e, sql, ignore, warnThreshold, skipWarn); + return SQuery(db, e, sql, ignore, warnThreshold, skipInfoWarn); } string SUNQUOTED_TIMESTAMP(uint64_t when) { diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index 78f19f382..5a3cd5af2 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -591,8 +591,8 @@ void SQueryLogOpen(const string& logFilename); void SQueryLogClose(); // Returns an SQLite result code. -int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false, bool skipQueryLog = false); -int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false); +int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipInfoWarn = false); +int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipInfoWarn = false); bool SQVerifyTable(sqlite3* db, const string& tableName, const string& sql); bool SQVerifyTableExists(sqlite3* db, const string& tableName);