All tests pass single thread

This commit is contained in:
John Sully 2019-02-23 00:09:34 -05:00
parent cfabd4f666
commit 554012085c
4 changed files with 21 additions and 14 deletions

View File

@ -1155,24 +1155,19 @@ static void freeClientArgv(client *c) {
* resync with us as well. */ * resync with us as well. */
void disconnectSlaves(void) { void disconnectSlaves(void) {
serverAssert(aeThreadOwnsLock()); serverAssert(aeThreadOwnsLock());
std::vector<client*> vecfreeImmediate;
listNode *ln;
listIter li; listIter li;
listNode *ln;
listRewind(server.slaves, &li); listRewind(server.slaves, &li);
while ((ln = listNext(&li))) { while ((ln = listNext(&li))) {
client *c = (client*)ln->value; client *c = (client*)listNodeValue(ln);
if (c->iel == serverTL - server.rgthreadvar) if (FCorrectThread(c)) {
{ freeClient(c);
vecfreeImmediate.push_back(c);
} }
else else {
{
freeClientAsync(c); freeClientAsync(c);
} }
} }
for (client *c : vecfreeImmediate)
freeClient(c);
} }
/* Remove the specified client from global lists where the client could /* Remove the specified client from global lists where the client could

View File

@ -986,6 +986,8 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
client *c = listNodeValue(ln); client *c = listNodeValue(ln);
if (c->flags & CLIENT_CLOSE_ASAP)
continue;
mem += getClientOutputBufferMemoryUsage(c); mem += getClientOutputBufferMemoryUsage(c);
mem += sdsAllocSize(c->querybuf); mem += sdsAllocSize(c->querybuf);
mem += sizeof(client); mem += sizeof(client);

View File

@ -543,6 +543,9 @@ int masterTryPartialResynchronization(client *c) {
buflen = snprintf(buf,sizeof(buf),"+CONTINUE\r\n"); buflen = snprintf(buf,sizeof(buf),"+CONTINUE\r\n");
} }
if (write(c->fd,buf,buflen) != buflen) { if (write(c->fd,buf,buflen) != buflen) {
if (FCorrectThread(c))
freeClient(c);
else
freeClientAsync(c); freeClientAsync(c);
return C_OK; return C_OK;
} }
@ -2011,6 +2014,9 @@ void replicationSetMaster(char *ip, int port) {
server.masterhost = sdsnew(ip); server.masterhost = sdsnew(ip);
server.masterport = port; server.masterport = port;
if (server.master) { if (server.master) {
if (FCorrectThread(server.master))
freeClient(server.master);
else
freeClientAsync(server.master); freeClientAsync(server.master);
} }
disconnectAllBlockedClients(); /* Clients blocked in master, now slave. */ disconnectAllBlockedClients(); /* Clients blocked in master, now slave. */
@ -2626,6 +2632,9 @@ void replicationCron(void) {
(time(NULL)-server.master->lastinteraction) > server.repl_timeout) (time(NULL)-server.master->lastinteraction) > server.repl_timeout)
{ {
serverLog(LL_WARNING,"MASTER timeout: no data nor PING received..."); serverLog(LL_WARNING,"MASTER timeout: no data nor PING received...");
if (FCorrectThread(server.master))
freeClient(server.master);
else
freeClientAsync(server.master); freeClientAsync(server.master);
} }

View File

@ -19,6 +19,7 @@ start_server {tags {"lazyfree"}} {
} }
test "FLUSHDB ASYNC can reclaim memory in background" { test "FLUSHDB ASYNC can reclaim memory in background" {
after 500 # Sometimes Redis is busy with a prior operation
set orig_mem [s used_memory] set orig_mem [s used_memory]
set args {} set args {}
for {set i 0} {$i < 100000} {incr i} { for {set i 0} {$i < 100000} {incr i} {