]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stick-table: show the shard number in each entry's "show table" output
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Nov 2022 10:55:18 +0000 (11:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Nov 2022 11:00:49 +0000 (12:00 +0100)
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
src/stick_table.c

index dc60d4cdbc45fc78b63cba1a5f569e921439114e..d68c124b364f88d68eedcb8b7b661a3f7f8cd3c0 100644 (file)
@@ -3544,6 +3544,16 @@ show table <name> [ data.<type> <operator> <value> [data.<type> ...]] | [ key <k
           | fgrep 'key=' | cut -d' ' -f2 | cut -d= -f2 > 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
index 57c8c15d4797a4e1688f5d96b0ae201eb5f24492..3ca2c887f54e789d033184260c09be43965cdb94 100644 (file)
@@ -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;