Skip to content

Commit 5ef184b

Browse files
committed
exmdb: config directive "exmdb_deep_backtrace"
References: DESK-2595
1 parent b8b62ff commit 5ef184b

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

doc/exmdb_provider.4gx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ with exclusive locking).
2020
.br
2121
Default: \fIno\fP
2222
.TP
23+
\fBexmdb_deep_backtrace\fP
24+
(Developer option.) Record and report transaction problems with a multi-level
25+
backtrace instead of a single-level location indicator.
26+
.br
27+
Default: \fIno\fP
28+
.TP
2329
\fBexmdb_ics_log_file\fP
2430
Log ICS/synchronization requests (and their results) to this file.
2531
.br

exch/exmdb/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ using namespace exmdb;
3636
static std::shared_ptr<CONFIG_FILE> g_config_during_init;
3737

3838
static constexpr cfg_directive exmdb_gromox_cfg_defaults[] = {
39+
{"exmdb_deep_backtrace", "0", CFG_BOOL},
3940
{"exmdb_force_write_txn", "0", CFG_BOOL},
4041
{"exmdb_ics_log_file", ""},
4142
CFG_TABLE_END,
@@ -111,6 +112,7 @@ static bool exmdb_provider_reload(std::shared_ptr<config_file> gxcfg = nullptr,
111112
g_exmdb_search_pacing_time = pconfig->get_ll("exmdb_search_pacing_time");
112113
g_exmdb_max_sqlite_spares = pconfig->get_ll("exmdb_max_sqlite_spares");
113114
g_sqlite_busy_timeout_ns = pconfig->get_ll("sqlite_busy_timeout");
115+
gx_sql_deep_backtrace = gxcfg->get_ll("exmdb_deep_backtrace");
114116
gx_force_write_txn = gxcfg->get_ll("exmdb_force_write_txn");
115117
auto s = gxcfg->get_value("exmdb_ics_log_file");
116118
if (s != nullptr)

include/gromox/database.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,6 @@ static inline uint64_t gx_sql_col_uint64(sqlite3_stmt *s, int c)
105105
}
106106

107107
extern GX_EXPORT unsigned int gx_sqlite_debug, gx_force_write_txn;
108+
extern GX_EXPORT unsigned int gx_sql_deep_backtrace;
108109

109110
}

lib/dbhelper.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace gromox {
1414

15-
unsigned int gx_sqlite_debug, gx_force_write_txn;
15+
unsigned int gx_sqlite_debug, gx_force_write_txn, gx_sql_deep_backtrace;
1616

1717
static bool write_statement(const char *q)
1818
{
@@ -100,7 +100,10 @@ xtransaction gx_sql_begin3(const std::string &pos, sqlite3 *db, txn_mode mode)
100100
auto fn = sqlite3_db_filename(db, nullptr);
101101
if (fn != nullptr && *fn != '\0') {
102102
std::unique_lock lk(active_xa_lock);
103-
active_xa[fn] = pos;
103+
if (gx_sql_deep_backtrace)
104+
active_xa[fn] = simple_backtrace();
105+
else
106+
active_xa[fn] = pos;
104107
}
105108
return xtransaction(db);
106109
}
@@ -112,7 +115,7 @@ xtransaction gx_sql_begin3(const std::string &pos, sqlite3 *db, txn_mode mode)
112115
auto it = active_xa.find(fn);
113116
mlog(LV_ERR, "sqlite_busy on %s: held by %s, take from %s", znul(fn),
114117
it != active_xa.end() ? it->second.c_str() : "unknown",
115-
pos.c_str());
118+
gx_sql_deep_backtrace ? simple_backtrace().c_str() : pos.c_str());
116119
}
117120
return xtransaction(nullptr);
118121
}

0 commit comments

Comments
 (0)