All tests pass single thread

This commit is contained in:
John Sully 2019-02-23 00:09:34 -05:00
parent 199269bff7
commit 3871725979
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. */
void disconnectSlaves(void) {
serverAssert(aeThreadOwnsLock());
std::vector<client*> vecfreeImmediate;
listNode *ln;
listIter li;
listNode *ln;
listRewind(server.slaves, &li);
while ((ln = listNext(&li))) {
client *c = (client*)ln->value;
if (c->iel == serverTL - server.rgthreadvar)
{
vecfreeImmediate.push_back(c);
client *c = (client*)listNodeValue(ln);
if (FCorrectThread(c)) {
freeClient(c);
}
else
{
else {
freeClientAsync(c);
}
}
for (client *c : vecfreeImmediate)
freeClient(c);
}
/* 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);
while((ln = listNext(&li))) {
client *c = listNodeValue(ln);
if (c->flags & CLIENT_CLOSE_ASAP)
continue;
mem += getClientOutputBufferMemoryUsage(c);
mem += sdsAllocSize(c->querybuf);
mem += sizeof(client);

View File

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

View File

@ -19,6 +19,7 @@ start_server {tags {"lazyfree"}} {
}
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 args {}
for {set i 0} {$i < 100000} {incr i} {