don't use object sharing inside I/O threads, as a fix for a well known instability of VM introduced with the new object sharing code
This commit is contained in:
parent
1a71fb9669
commit
0e5441d816
11
src/object.c
11
src/object.c
@ -213,8 +213,15 @@ robj *tryObjectEncoding(robj *o) {
|
|||||||
/* Check if we can represent this string as a long integer */
|
/* Check if we can represent this string as a long integer */
|
||||||
if (isStringRepresentableAsLong(s,&value) == REDIS_ERR) return o;
|
if (isStringRepresentableAsLong(s,&value) == REDIS_ERR) return o;
|
||||||
|
|
||||||
/* Ok, this object can be encoded */
|
/* Ok, this object can be encoded...
|
||||||
if (value >= 0 && value < REDIS_SHARED_INTEGERS) {
|
*
|
||||||
|
* Can I use a shared object? Only if the object is inside a given
|
||||||
|
* range and if this is the main thread, sinc when VM is enabled we
|
||||||
|
* have the constraint that I/O thread should only handle non-shared
|
||||||
|
* objects, in order to avoid race conditions (we don't have per-object
|
||||||
|
* locking). */
|
||||||
|
if (value >= 0 && value < REDIS_SHARED_INTEGERS &&
|
||||||
|
pthread_equal(pthread_self(),server.mainthread)) {
|
||||||
decrRefCount(o);
|
decrRefCount(o);
|
||||||
incrRefCount(shared.integers[value]);
|
incrRefCount(shared.integers[value]);
|
||||||
return shared.integers[value];
|
return shared.integers[value];
|
||||||
|
@ -760,6 +760,7 @@ void initServer() {
|
|||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
setupSigSegvAction();
|
setupSigSegvAction();
|
||||||
|
|
||||||
|
server.mainthread = pthread_self();
|
||||||
server.devnull = fopen("/dev/null","w");
|
server.devnull = fopen("/dev/null","w");
|
||||||
if (server.devnull == NULL) {
|
if (server.devnull == NULL) {
|
||||||
redisLog(REDIS_WARNING, "Can't open /dev/null: %s", server.neterr);
|
redisLog(REDIS_WARNING, "Can't open /dev/null: %s", server.neterr);
|
||||||
|
@ -327,6 +327,7 @@ struct sharedObjectsStruct {
|
|||||||
|
|
||||||
/* Global server state structure */
|
/* Global server state structure */
|
||||||
struct redisServer {
|
struct redisServer {
|
||||||
|
pthread_t mainthread;
|
||||||
int port;
|
int port;
|
||||||
int fd;
|
int fd;
|
||||||
redisDb *db;
|
redisDb *db;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user