Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

[-] fix executing queries on standby databases with pooling, fixes #520 #551

Merged
merged 1 commit into from
Dec 8, 2022
Merged
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
14 changes: 7 additions & 7 deletions pgwatch2/pgwatch2.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ var InfluxSkipSSLCertVerify, InfluxSkipSSLCertVerify2 bool
var fileBasedMetrics = false
var adHocMode = false
var preset_metric_def_map map[string]map[string]float64 // read from metrics folder in "file mode"
/// internal statistics calculation
// / internal statistics calculation
var lastSuccessfulDatastoreWriteTimeEpoch int64
var datastoreWriteFailuresCounter uint64
var datastoreWriteSuccessCounter uint64
Expand Down Expand Up @@ -649,7 +649,7 @@ func DBExecInExplicitTX(conn *sqlx.DB, host_ident, sql string, args ...interface
}

ctx := context.Background()
txOpts := go_sql.TxOptions{}
txOpts := go_sql.TxOptions{ReadOnly: true}

tx, err := conn.BeginTxx(ctx, &txOpts)
if err != nil {
Expand Down Expand Up @@ -745,12 +745,12 @@ func DBExecReadByDbUniqueName(dbUnique, metricName string, stmtTimeoutOverride i
data, err = DBExecInExplicitTX(conn, dbUnique, sqlToExec, args...)
} else {
if IsPostgresDBType(md.DBType) {
data, err = DBExecRead(conn, dbUnique, sqlToExec, args...)
data, err = DBExecRead(conn, dbUnique, sqlToExec, args...)
} else {
for _,sql := range strings.Split(sqlToExec,";") {
if len(sql) > 0 {
data, err = DBExecRead(conn, dbUnique, sql, args...)
}
for _, sql := range strings.Split(sqlToExec, ";") {
if len(sql) > 0 {
data, err = DBExecRead(conn, dbUnique, sql, args...)
}
}
}
}
Expand Down