Skip to content

Commit

Permalink
fix(module): reduce log level of absent LMDB tag (#49)
Browse files Browse the repository at this point in the history
KAG-3093

---------

Co-authored-by: Datong Sun <datong.sun@konghq.com>
  • Loading branch information
chronolaw and dndx authored Nov 24, 2023
1 parent d236fc5 commit 19a6da0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/ngx_lua_resty_lmdb_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,11 @@ ngx_lua_resty_lmdb_validate(ngx_cycle_t *cycle,
&lcf->validation_tag);

} else if (rc == MDB_NOTFOUND) {
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
"LMDB validation tag does not exist");
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
"LMDB validation tag does not exist, assuming empty database");

mdb_txn_abort(txn);
return NGX_DECLINED;

} else {
ngx_log_error(NGX_LOG_ERR, cycle->log, 0,
Expand Down Expand Up @@ -519,6 +522,7 @@ ngx_lua_resty_lmdb_write_tag(ngx_cycle_t *cycle,

static ngx_int_t ngx_lua_resty_lmdb_init(ngx_cycle_t *cycle)
{
ngx_int_t rc;
ngx_lua_resty_lmdb_conf_t *lcf;

lcf = (ngx_lua_resty_lmdb_conf_t *) ngx_get_conf(cycle->conf_ctx,
Expand All @@ -536,10 +540,13 @@ static ngx_int_t ngx_lua_resty_lmdb_init(ngx_cycle_t *cycle)

/* check lmdb validation tag */

if (ngx_lua_resty_lmdb_validate(cycle, lcf) != NGX_OK) {
rc = ngx_lua_resty_lmdb_validate(cycle, lcf);

if (rc != NGX_OK) {
ngx_lua_resty_lmdb_close_file(cycle, lcf);

ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
ngx_log_error((rc == NGX_DECLINED ? NGX_LOG_NOTICE : NGX_LOG_WARN),
cycle->log, 0,
"LMDB validation tag mismatch, wiping the database");

/* remove lmdb files to clean data */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ LMDB validation tag does not exist
LMDB validation tag mismatch, wiping the database
set LMDB validation tag: "3.3"
--- no_error_log
[emerg]
[warn]
[error]
[crit]

Expand Down

0 comments on commit 19a6da0

Please sign in to comment.