Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 401 by zarcard...@gmail.com: a low-frequency get may got wrong
item
https://code.google.com/p/memcached/issues/detail?id=401
What steps will reproduce the problem?
1. run memcached, set tail_repair_time to help quick reproduce:
[21:13:01]~/prog/memcached-1.4.22 $ ./memcached -m 5000 -o
tail_repair_time=10
2. run the program below(mc.go), line 39 show never print but it does.
1 package main
2
3 import (
4 "bytes"
5 "flag"
6 "fmt"
7 "runtime"
8 "time"
9
10 "github.com/bradfitz/gomemcache/memcache"
11 )
12
13 var addr = flag.String("addr", "localhost:11211", "addr of memcached")
14 var sleep = flag.Int("sleep", 4, "time to slee")
15
16 func main() {
17
18 flag.Parse()
19
20 runtime.GOMAXPROCS(runtime.NumCPU())
21
22 abc := memcache.New(*addr)
23 def := memcache.New(*addr)
24
25 abc.Set(&memcache.Item{
26 Key: "ctw9tjk",
27 Value: []byte("abc"),
28 })
29
30 for _ = range time.Tick(time.Duration(*sleep) * time.Second) {
31 go func() {
32 fmt.Println("start get")
33 item, err := abc.Get("ctw9tjk")
34 if err != nil {
35 fmt.Println("abc.Get", err)
36 return
37 }
38 if !bytes.Equal(item.Value, []byte("abc")) {
39 fmt.Printf("get ctw9tjk =>
{%v, %v}!!!!!!!!!!!!!!\n", item.Key, string(item.Value))
40 return
41 }
42 fmt.Printf("get ctw9tjk => {%v, %v}\n",
item.Key, string(item.Value))
43 }()
44
45 go func() {
46 fmt.Println("start set")
47 err := def.Set(&memcache.Item{
48 Key: "cqv87p7",
49 Value: []byte("def"),
50 })
51 fmt.Println("def.Set", err)
52 }()
53 }
54 }
What is the expected output? What do you see instead?
line 39 show never print, but it does:
[21:38:07]~/code/go $ ./mc -sleep=13
start get
start set
get ctw9tjk => {ctw9tjk, abc}
def.Set <nil>
start get
start set
def.Set <nil>
get ctw9tjk => {ctw9tjk, abc}
start set
start get
def.Set <nil>
get ctw9tjk => {ctw9tjk, abc}
start get
start set
def.Set <nil>
get ctw9tjk => {cqv87p7, def}!!!!!!!!!!!!!!
What version of the product are you using? On what operating system?
1.4.22, Darwin Kernel Version 14.1.0 on mac.
Please provide any additional information below.
the logic here exactly hitted:
https://github.com/memcached/memcached/blob/1.4.22/items.c#L150
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
---
You received this message because you are subscribed to the Google Groups "memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.