Skip to content
Snippets Groups Projects
Commit 691715b5 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Kirill Yukhin
Browse files

replication: show errno in replication info

Box.info.replication shows applier/relay's latest error message.
But it didn't include errno description for system errors, even
though it was included in the logs. Now box.info shows the errno
description as well, when possible.

Closes #4402

Conflicts:
	test/replication/suite.cfg
parent 22bbb34f
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "box/box.h" #include "box/box.h"
#include "lua/utils.h" #include "lua/utils.h"
#include "fiber.h" #include "fiber.h"
#include "tt_static.h"
static void static void
lbox_pushvclock(struct lua_State *L, const struct vclock *vclock) lbox_pushvclock(struct lua_State *L, const struct vclock *vclock)
...@@ -65,6 +66,20 @@ lbox_pushvclock(struct lua_State *L, const struct vclock *vclock) ...@@ -65,6 +66,20 @@ lbox_pushvclock(struct lua_State *L, const struct vclock *vclock)
luaL_setmaphint(L, -1); /* compact flow */ luaL_setmaphint(L, -1); /* compact flow */
} }
static inline void
lbox_push_replication_error_message(struct lua_State *L, struct error *e,
int idx)
{
lua_pushstring(L, "message");
lua_pushstring(L, e->errmsg);
lua_settable(L, idx - 2);
if (e->saved_errno == 0)
return;
lua_pushstring(L, "system_message");
lua_pushstring(L, strerror(e->saved_errno));
lua_settable(L, idx - 2);
}
static void static void
lbox_pushapplier(lua_State *L, struct applier *applier) lbox_pushapplier(lua_State *L, struct applier *applier)
{ {
...@@ -103,11 +118,8 @@ lbox_pushapplier(lua_State *L, struct applier *applier) ...@@ -103,11 +118,8 @@ lbox_pushapplier(lua_State *L, struct applier *applier)
lua_settable(L, -3); lua_settable(L, -3);
struct error *e = diag_last_error(&applier->reader->diag); struct error *e = diag_last_error(&applier->reader->diag);
if (e != NULL) { if (e != NULL)
lua_pushstring(L, "message"); lbox_push_replication_error_message(L, e, -1);
lua_pushstring(L, e->errmsg);
lua_settable(L, -3);
}
} }
} }
...@@ -135,11 +147,8 @@ lbox_pushrelay(lua_State *L, struct relay *relay) ...@@ -135,11 +147,8 @@ lbox_pushrelay(lua_State *L, struct relay *relay)
lua_settable(L, -3); lua_settable(L, -3);
struct error *e = diag_last_error(relay_get_diag(relay)); struct error *e = diag_last_error(relay_get_diag(relay));
if (e != NULL) { if (e != NULL)
lua_pushstring(L, "message"); lbox_push_replication_error_message(L, e, -1);
lua_pushstring(L, e->errmsg);
lua_settable(L, -3);
}
break; break;
} }
default: unreachable(); default: unreachable();
......
-- test-run result file version 2
test_run = require('test_run').new()
| ---
| ...
--
-- gh-4402: replication info table should contain not only
-- Tarantool's error, but also a system error (errno's message)
-- when possible.
--
box.schema.user.grant('guest', 'replication')
| ---
| ...
test_run:cmd('create server replica with rpl_master=default, script="replication/replica.lua"')
| ---
| - true
| ...
test_run:cmd('start server replica')
| ---
| - true
| ...
i = box.info
| ---
| ...
replica_id = i.id % 2 + 1
| ---
| ...
d = i.replication[replica_id].downstream
| ---
| ...
d ~= nil and d.status == 'follow' or i
| ---
| - true
| ...
test_run:cmd('stop server replica')
| ---
| - true
| ...
test_run:cmd("cleanup server replica")
| ---
| - true
| ...
test_run:cmd("delete server replica")
| ---
| - true
| ...
i = box.info
| ---
| ...
d = i.replication[replica_id].downstream
| ---
| ...
d ~= nil and d.system_message ~= nil and d.message ~= nil or i
| ---
| - true
| ...
box.schema.user.revoke('guest', 'replication')
| ---
| ...
test_run = require('test_run').new()
--
-- gh-4402: replication info table should contain not only
-- Tarantool's error, but also a system error (errno's message)
-- when possible.
--
box.schema.user.grant('guest', 'replication')
test_run:cmd('create server replica with rpl_master=default, script="replication/replica.lua"')
test_run:cmd('start server replica')
i = box.info
replica_id = i.id % 2 + 1
d = i.replication[replica_id].downstream
d ~= nil and d.status == 'follow' or i
test_run:cmd('stop server replica')
test_run:cmd("cleanup server replica")
test_run:cmd("delete server replica")
i = box.info
d = i.replication[replica_id].downstream
d ~= nil and d.system_message ~= nil and d.message ~= nil or i
box.schema.user.revoke('guest', 'replication')
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"on_schema_init.test.lua": {}, "on_schema_init.test.lua": {},
"long_row_timeout.test.lua": {}, "long_row_timeout.test.lua": {},
"join_without_snap.test.lua": {}, "join_without_snap.test.lua": {},
"gh-4402-info-errno.test.lua": {},
"gh-4606-admin-creds.test.lua": {}, "gh-4606-admin-creds.test.lua": {},
"*": { "*": {
"memtx": {"engine": "memtx"}, "memtx": {"engine": "memtx"},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment