diff --git a/src/ngx_lua_resty_lmdb_module.c b/src/ngx_lua_resty_lmdb_module.c index 5d3222c..76d9f55 100644 --- a/src/ngx_lua_resty_lmdb_module.c +++ b/src/ngx_lua_resty_lmdb_module.c @@ -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, @@ -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, @@ -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 */ diff --git a/t/10-validation-tag-plain.t b/t/11-validation-tag-plain.t similarity index 99% rename from t/10-validation-tag-plain.t rename to t/11-validation-tag-plain.t index e52061f..8d214c5 100644 --- a/t/10-validation-tag-plain.t +++ b/t/11-validation-tag-plain.t @@ -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]