Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sqlitecluster/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions sqlitecluster/SQLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ 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).
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;
Expand Down
3 changes: 3 additions & 0 deletions test/lib/RemoteSQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bool RemoteSQLite::_runRemoteQuery(const string& query, const map<string, Parame

bool RemoteSQLite::read(const string& query, SQResult& result, bool skipInfoWarn) const
{
incrementReadQueryCount();
return _runRemoteQuery(query, {}, result);
}

Expand All @@ -51,11 +52,13 @@ bool RemoteSQLite::writeIdempotent(const string& query, SQResult& result)

bool RemoteSQLite::read(const string& query, const map<string, Parameter>& params, SQResult& result, bool skipInfoWarn) const
{
incrementReadQueryCount();
return _runRemoteQuery(query, params, result);
}

string RemoteSQLite::read(const string& query, const map<string, Parameter>& params) const
{
incrementReadQueryCount();
SQResult result;
if (!_runRemoteQuery(query, params, result)) {
return "";
Expand Down
Loading