Skip to content

Commit 2af4f6e

Browse files
committed
rename reflocked + add protocol.txt line
now lrutail_reflocked.. gross but more descriptive. will still make people thing something went wrong, oh well.
1 parent 13340b1 commit 2af4f6e

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

doc/protocol.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ integers separated by a colon (treat this as a floating point number).
582582
| slab_reassign_running | bool | If a slab page is being moved |
583583
| slabs_moved | 64u | Total slab pages moved |
584584
| crawler_reclaimed | 64u | Total items freed by LRU Crawler |
585+
| lrutail_reflocked | 64u | Times LRU tail was found with active ref. |
586+
| | | Items moved to head to avoid OOM errors. |
585587
|-----------------------+---------+-------------------------------------------|
586588

587589
Settings statistics

items.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ typedef struct {
2929
uint64_t expired_unfetched;
3030
uint64_t evicted_unfetched;
3131
uint64_t crawler_reclaimed;
32-
uint64_t reflocked;
32+
uint64_t lrutail_reflocked;
3333
} itemstats_t;
3434

3535
static item *heads[LARGEST_ID];
@@ -107,7 +107,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags,
107107
/* do a quick check if we have any expired items in the tail.. */
108108
int tries = 5;
109109
/* Avoid hangs if a slab has nothing but refcounted stuff in it. */
110-
int tries_reflocked = 1000;
110+
int tries_lrutail_reflocked = 1000;
111111
int tried_alloc = 0;
112112
item *search;
113113
item *next_it;
@@ -136,10 +136,10 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags,
136136
if (refcount_incr(&search->refcount) != 2) {
137137
/* Avoid pathological case with ref'ed items in tail */
138138
do_item_update_nolock(search);
139-
tries_reflocked--;
139+
tries_lrutail_reflocked--;
140140
tries++;
141141
refcount_decr(&search->refcount);
142-
itemstats[id].reflocked++;
142+
itemstats[id].lrutail_reflocked++;
143143
/* Old rare bug could cause a refcount leak. We haven't seen
144144
* it in years, but we leave this code in to prevent failures
145145
* just in case */
@@ -152,7 +152,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags,
152152
if (hold_lock)
153153
item_trylock_unlock(hold_lock);
154154

155-
if (tries_reflocked < 1)
155+
if (tries_lrutail_reflocked < 1)
156156
break;
157157

158158
continue;
@@ -477,7 +477,7 @@ void do_item_stats_totals(ADD_STAT add_stats, void *c) {
477477
totals.evicted += itemstats[i].evicted;
478478
totals.reclaimed += itemstats[i].reclaimed;
479479
totals.crawler_reclaimed += itemstats[i].crawler_reclaimed;
480-
totals.reflocked += itemstats[i].reflocked;
480+
totals.lrutail_reflocked += itemstats[i].lrutail_reflocked;
481481
}
482482
APPEND_STAT("expired_unfetched", "%llu",
483483
(unsigned long long)totals.expired_unfetched);
@@ -489,8 +489,8 @@ void do_item_stats_totals(ADD_STAT add_stats, void *c) {
489489
(unsigned long long)totals.reclaimed);
490490
APPEND_STAT("crawler_reclaimed", "%llu",
491491
(unsigned long long)totals.crawler_reclaimed);
492-
APPEND_STAT("reflocked", "%llu",
493-
(unsigned long long)totals.reflocked);
492+
APPEND_STAT("lrutail_reflocked", "%llu",
493+
(unsigned long long)totals.lrutail_reflocked);
494494
}
495495

496496
void do_item_stats(ADD_STAT add_stats, void *c) {
@@ -525,8 +525,8 @@ void do_item_stats(ADD_STAT add_stats, void *c) {
525525
"%llu", (unsigned long long)itemstats[i].evicted_unfetched);
526526
APPEND_NUM_FMT_STAT(fmt, i, "crawler_reclaimed",
527527
"%llu", (unsigned long long)itemstats[i].crawler_reclaimed);
528-
APPEND_NUM_FMT_STAT(fmt, i, "reflocked",
529-
"%llu", (unsigned long long)itemstats[i].reflocked);
528+
APPEND_NUM_FMT_STAT(fmt, i, "lrutail_reflocked",
529+
"%llu", (unsigned long long)itemstats[i].lrutail_reflocked);
530530
}
531531
}
532532

t/binary.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings;
5-
use Test::More tests => 3603;
5+
use Test::More tests => 3615;
66
use FindBin qw($Bin);
77
use lib "$Bin/lib";
88
use MemcachedTest;

t/refhang.t

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ chop $mget;
3131
my $stats = mem_stats($sock, "items");
3232
isnt($stats->{"items:31:evicted"}, "0", "check evicted");
3333

34-
my $reflocked = $stats->{"items:31:reflocked"};
35-
is($reflocked, "0", "check no slab reflocked");
34+
my $lrutail_reflocked = $stats->{"items:31:lrutail_reflocked"};
35+
is($lrutail_reflocked, "0", "check no slab lrutail_reflocked");
3636

3737
$stats = mem_stats($sock);
38-
is($stats->{"reflocked"}, "0", "check no total reflocked");
38+
is($stats->{"lrutail_reflocked"}, "0", "check no total lrutail_reflocked");
3939

4040
# Don't intend to read the results, need to fill the socket.
4141
# TODO: This test would be smarter if we cranked down the socket buffers
@@ -51,10 +51,10 @@ for ($key = 121; $key < 240; $key++) {
5151

5252
$stats = mem_stats($sock, "items");
5353
is($stats->{"items:31:outofmemory"}, "0", "check no oom");
54-
isnt($stats->{"items:31:reflocked"}, "0", "count reflocked");
54+
isnt($stats->{"items:31:lrutail_reflocked"}, "0", "count lrutail_reflocked");
5555

5656
$stats = mem_stats($sock);
57-
isnt($stats->{"reflocked"}, "0", "count total reflocked");
57+
isnt($stats->{"lrutail_reflocked"}, "0", "count total lrutail_reflocked");
5858

5959
# Clear out all that 'hung' traffic
6060
while(<$hangsock> !~ /END/) { };
@@ -69,8 +69,8 @@ print $hangsock2 "get $revkeys\r\n";
6969

7070
for ($key = 240; $key < 260; $key++) {
7171
print $sock "set key$key 0 0 66560\r\n$value\r\n";
72-
is(scalar <$sock>, "SERVER_ERROR out of memory storing object\r\n", "oom fully reflocked");
72+
is(scalar <$sock>, "SERVER_ERROR out of memory storing object\r\n", "oom fully lrutail_reflocked");
7373
}
7474

7575
$stats = mem_stats($sock, "items");
76-
isnt($stats->{"items:31:outofmemory"}, "0", "count reflocked oom");
76+
isnt($stats->{"items:31:outofmemory"}, "0", "count lrutail_reflocked oom");

t/stats.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22

33
use strict;
4-
use Test::More tests => 95;
4+
use Test::More tests => 97;
55
use FindBin qw($Bin);
66
use lib "$Bin/lib";
77
use MemcachedTest;
@@ -62,7 +62,7 @@ my $sock = $server->sock;
6262
## STAT evictions 0
6363
## STAT reclaimed 0
6464
## STAT crawler_reclaimed 0
65-
## STAT reflocked 0
65+
## STAT lrutail_reflocked 0
6666
# note that auth stats are tested in auth specfic tests
6767

6868

@@ -74,7 +74,7 @@ is(scalar(keys(%$stats)), 51, "51 stats values");
7474
# Test initial state
7575
foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses
7676
bytes_written delete_hits delete_misses incr_hits incr_misses decr_hits
77-
decr_misses listen_disabled_num reflocked)) {
77+
decr_misses listen_disabled_num lrutail_reflocked)) {
7878
is($stats->{$key}, 0, "initial $key is zero");
7979
}
8080
is($stats->{accepting_conns}, 1, "initial accepting_conns is one");
@@ -199,7 +199,7 @@ is(0, $stats->{'cas_hits'});
199199
is(0, $stats->{'cas_badval'});
200200
is(0, $stats->{'evictions'});
201201
is(0, $stats->{'reclaimed'});
202-
is(0, $stats->{'reflocked'});
202+
is(0, $stats->{'lrutail_reflocked'});
203203

204204
print $sock "flush_all\r\n";
205205
is(scalar <$sock>, "OK\r\n", "flushed");

0 commit comments

Comments
 (0)