golang / groupcache

groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bugfix: When the fn function is executed, causing panic will cause the key to remain permanently. This leads to a series of problems.

liqingqiya opened this issue · comments

When the fn function is executed, causing panic will cause the key to remain permanently. This leads to a series of problems.

goroutine 1

	Group.Do 
		// add 
		g.m[key] = c

		// execute fn()
		c.val, c.err = fn()  // panic;

		// delete key
		delete(g.m, key)

goroutine 2

	Group.Do 
		// lookup  
		if c, ok := g.m[key]; ok {
			g.mu.Unlock()
			c.wg.Wait()			// wait forever
			return