From 730bf8a8ab49897235a7807c1d57be81713c9d98 Mon Sep 17 00:00:00 2001 From: Gabriel Valforte Date: Fri, 17 Jul 2026 12:56:42 -0300 Subject: [PATCH 1/4] add new acessor getReadQueryCount --- sqlitecluster/SQLite.cpp | 5 +++++ sqlitecluster/SQLite.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/sqlitecluster/SQLite.cpp b/sqlitecluster/SQLite.cpp index 85e0709c0..377f23390 100644 --- a/sqlitecluster/SQLite.cpp +++ b/sqlitecluster/SQLite.cpp @@ -1519,6 +1519,11 @@ uint64_t SQLite::getDBCountAtStart() const return _dbCountAtStart; } +int64_t SQLite::getReadQueryCount() const +{ + return _readQueryCount; +} + void SQLite::setCommitEnabled(bool enable) { _sharedData.setCommitEnabled(enable); diff --git a/sqlitecluster/SQLite.h b/sqlitecluster/SQLite.h index 0a8c9c3a5..c2db1aa96 100644 --- a/sqlitecluster/SQLite.h +++ b/sqlitecluster/SQLite.h @@ -328,6 +328,10 @@ class SQLite { // public read-only accessor for _dbCountAtStart. uint64_t getDBCountAtStart() const; + // Read-only accessor for the number of read queries attempted in the current transaction (metrics/tests only). + // Virtual so RemoteSQLite can report the reads it forwards to the server instead of the local (unused) counter. + virtual int64_t getReadQueryCount() const; + int64_t getLastConflictIdentifier() const; string getLastConflictLocation() const; From 8a8cc44899036af36af59ef6acb5f7d87f6a4c82 Mon Sep 17 00:00:00 2001 From: Gabriel Valforte Date: Fri, 17 Jul 2026 12:57:14 -0300 Subject: [PATCH 2/4] add a read for queries forwarded to the server --- test/lib/RemoteSQLite.cpp | 8 ++++++++ test/lib/RemoteSQLite.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/test/lib/RemoteSQLite.cpp b/test/lib/RemoteSQLite.cpp index 1cfb9095d..5e1658a24 100644 --- a/test/lib/RemoteSQLite.cpp +++ b/test/lib/RemoteSQLite.cpp @@ -35,6 +35,7 @@ bool RemoteSQLite::_runRemoteQuery(const string& query, const map& params, SQResult& result, bool skipInfoWarn) const { + _forwardedReadCount++; return _runRemoteQuery(query, params, result); } string RemoteSQLite::read(const string& query, const map& params) const { + _forwardedReadCount++; SQResult result; if (!_runRemoteQuery(query, params, result)) { return ""; @@ -95,3 +98,8 @@ bool RemoteSQLite::write(const string& query, const map& para { return _runRemoteQuery(query, params, result); } + +int64_t RemoteSQLite::getReadQueryCount() const +{ + return _forwardedReadCount; +} diff --git a/test/lib/RemoteSQLite.h b/test/lib/RemoteSQLite.h index 6d40e77c5..659a84b11 100644 --- a/test/lib/RemoteSQLite.h +++ b/test/lib/RemoteSQLite.h @@ -30,9 +30,16 @@ class RemoteSQLite : public SQLite { bool write(const string& query, const map& params) override; bool write(const string& query, const map& params, SQResult& result) override; + // Reads run on the remote server, so the base class counter never advances. Report the number of + // read queries this proxy has forwarded instead, so tests can assert on read round-trips. + int64_t getReadQueryCount() const override; + private: mutable BedrockTester* _tester; + // Number of read queries forwarded to the server; each forwarded read is one round-trip. + mutable int64_t _forwardedReadCount = 0; + // Build a Query command with named bound parameters serialized into `sql-param-` headers and // send it via the tester's executeWaitMultipleData. This bypasses BedrockTester::readDB's // remoteMode/HCTree gate so RemoteSQLite always forwards to the server, which is the only behavior From babff0c8c630275440954e457dcc8ebcda86f3fd Mon Sep 17 00:00:00 2001 From: Gabriel Valforte Date: Fri, 17 Jul 2026 13:21:10 -0300 Subject: [PATCH 3/4] add a read counter that will reset per transaction --- sqlitecluster/SQLite.h | 8 ++++++-- test/lib/RemoteSQLite.cpp | 11 +++-------- test/lib/RemoteSQLite.h | 7 ------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sqlitecluster/SQLite.h b/sqlitecluster/SQLite.h index c2db1aa96..20ae8c5fc 100644 --- a/sqlitecluster/SQLite.h +++ b/sqlitecluster/SQLite.h @@ -329,9 +329,13 @@ class SQLite { uint64_t getDBCountAtStart() const; // Read-only accessor for the number of read queries attempted in the current transaction (metrics/tests only). - // Virtual so RemoteSQLite can report the reads it forwards to the server instead of the local (unused) counter. - virtual int64_t getReadQueryCount() const; + int64_t getReadQueryCount() const; +protected: + // For subclasses that override read() to record a read against the shared counter. + void incrementReadQueryCount() const { _readQueryCount++; } + +public: int64_t getLastConflictIdentifier() const; string getLastConflictLocation() const; diff --git a/test/lib/RemoteSQLite.cpp b/test/lib/RemoteSQLite.cpp index 5e1658a24..c9b6ae4f5 100644 --- a/test/lib/RemoteSQLite.cpp +++ b/test/lib/RemoteSQLite.cpp @@ -35,7 +35,7 @@ bool RemoteSQLite::_runRemoteQuery(const string& query, const map& params, SQResult& result, bool skipInfoWarn) const { - _forwardedReadCount++; + incrementReadQueryCount(); return _runRemoteQuery(query, params, result); } string RemoteSQLite::read(const string& query, const map& params) const { - _forwardedReadCount++; + incrementReadQueryCount(); SQResult result; if (!_runRemoteQuery(query, params, result)) { return ""; @@ -98,8 +98,3 @@ bool RemoteSQLite::write(const string& query, const map& para { return _runRemoteQuery(query, params, result); } - -int64_t RemoteSQLite::getReadQueryCount() const -{ - return _forwardedReadCount; -} diff --git a/test/lib/RemoteSQLite.h b/test/lib/RemoteSQLite.h index 659a84b11..6d40e77c5 100644 --- a/test/lib/RemoteSQLite.h +++ b/test/lib/RemoteSQLite.h @@ -30,16 +30,9 @@ class RemoteSQLite : public SQLite { bool write(const string& query, const map& params) override; bool write(const string& query, const map& params, SQResult& result) override; - // Reads run on the remote server, so the base class counter never advances. Report the number of - // read queries this proxy has forwarded instead, so tests can assert on read round-trips. - int64_t getReadQueryCount() const override; - private: mutable BedrockTester* _tester; - // Number of read queries forwarded to the server; each forwarded read is one round-trip. - mutable int64_t _forwardedReadCount = 0; - // Build a Query command with named bound parameters serialized into `sql-param-` headers and // send it via the tester's executeWaitMultipleData. This bypasses BedrockTester::readDB's // remoteMode/HCTree gate so RemoteSQLite always forwards to the server, which is the only behavior From b7611f2930232626b612d3a7e119f80b1b173d4f Mon Sep 17 00:00:00 2001 From: Gabriel Valforte Date: Fri, 17 Jul 2026 13:22:51 -0300 Subject: [PATCH 4/4] fix code style --- sqlitecluster/SQLite.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlitecluster/SQLite.h b/sqlitecluster/SQLite.h index 20ae8c5fc..5107a54dc 100644 --- a/sqlitecluster/SQLite.h +++ b/sqlitecluster/SQLite.h @@ -333,7 +333,10 @@ class SQLite { protected: // For subclasses that override read() to record a read against the shared counter. - void incrementReadQueryCount() const { _readQueryCount++; } + void incrementReadQueryCount() const + { + _readQueryCount++; + } public: int64_t getLastConflictIdentifier() const;