From 16b282f4b0ac4c24b592f9dd83177f61c90e088b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 29 Nov 2022 11:55:18 +0100 Subject: [PATCH] MINOR: stick-table: show the shard number in each entry's "show table" output Stick-tables support sharding to multiple peers but there was no way to know to what shard an entry was going to be sent. Let's display this in the "show table" output to ease debugging. --- doc/management.txt | 10 ++++++++++ src/stick_table.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/management.txt b/doc/management.txt index dc60d4cdbc..d68c124b36 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -3544,6 +3544,16 @@ show table [ data. [data. ...]] | [ key abusers-ip.txt ( or | awk '/key/{ print a[split($2,a,"=")]; }' ) + When the stick-table is synchronized to a peers section supporting sharding, + the shard number will be displayed for each key (otherwise '0' is reported). + This allows to know which peers will receive this key. + Example: + $ echo "show table http_proxy" | socat stdio /tmp/sock1 | fgrep shard= + 0x7f23b0c822a8: key=10.0.0.2 use=0 exp=296398 shard=9 gpc0=0 + 0x7f23a063f948: key=10.0.0.6 use=0 exp=296075 shard=12 gpc0=0 + 0x7f23b03920b8: key=10.0.0.8 use=0 exp=296766 shard=1 gpc0=0 + 0x7f23a43c09e8: key=10.0.0.12 use=0 exp=295368 shard=8 gpc0=0 + show tasks Dumps the number of tasks currently in the run queue, with the number of occurrences for each function, and their average latency when it's known diff --git a/src/stick_table.c b/src/stick_table.c index 57c8c15d47..3ca2c887f5 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -4456,7 +4456,7 @@ static int table_dump_entry_to_buffer(struct buffer *msg, dump_binary(msg, (const char *)entry->key.key, t->key_size); } - chunk_appendf(msg, " use=%d exp=%d", entry->ref_cnt - 1, tick_remain(now_ms, entry->expire)); + chunk_appendf(msg, " use=%d exp=%d shard=%d", entry->ref_cnt - 1, tick_remain(now_ms, entry->expire), entry->shard); for (dt = 0; dt < STKTABLE_DATA_TYPES; dt++) { void *ptr;