A threadsafe problem

22 views
Skip to first unread message

Shunbin

unread,
Nov 24, 2016, 5:00:07 AM11/24/16
to Redis DB
Our project uses a Redis instance as the persistent database(located localhost, AOF enabled, no master/slave, no cluster, version 2.8.24), 
and Tomcat 6 as the application server. They communicates through Jedis(versioin 2.5.1). It published half a year ago, ran smoothly.

However, When the Redis instance became fat(about 10G), an unexpected phenomenon happened. It seemed our redis instance confused 
keys and values at a very low probability. For instance,

set key1, value1
set key2, value2
......
set keyN, valueN

Most of the time, getting keyX returned valueX as expected. But sometimes it returned valueY. It seems a
threadsafe problem. But we use Jedis like this pattern:

private void doRequest(HttpServletRequest req, HttpServletResponse resp) {
Jedis jedis = new Jedis();
try {
//do things
} finally {
jedis.close();
}
}

It should be threadsafe.

Analyzed the server's logs we noticed that all the illegal writes happened when a AOF rewrite triggered. 
At that time a lot of socket read timeout exceptions of Jedis reported. 
Maybe a large latency of redis motivated this threadsafe bug.

We have let no-appendfsync-on-rewrite to yes. Now no such bug occurred, but still unresolved.

Salvatore Sanfilippo

unread,
Nov 24, 2016, 5:09:50 AM11/24/16
to redi...@googlegroups.com
Hello, this looks like a problem in your client that shows up in a
time-dependent manner, so happens when Redis happens to be slower.
Redis is single-threaded in regard of processing operations so can't
have this bug.

Cheers,
Salvatore
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.



--
Salvatore 'antirez' Sanfilippo
open source developer - Redis Labs https://redislabs.com

"If a system is to have conceptual integrity, someone must control the
concepts."
— Fred Brooks, "The Mythical Man-Month", 1975.
Reply all
Reply to author
Forward
0 new messages