MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / propagateMasterStaleKeys

Function propagateMasterStaleKeys

src/replication.cpp:5533–5571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5531}
5532
5533static void propagateMasterStaleKeys()
5534{
5535 listIter li;
5536 listNode *ln;
5537 listRewind(g_pserver->masters, &li);
5538 robj *rgobj[2];
5539
5540 rgobj[0] = createEmbeddedStringObject("DEL", 3);
5541
5542 while ((ln = listNext(&li)) != nullptr)
5543 {
5544 redisMaster *mi = (redisMaster*)listNodeValue(ln);
5545 if (mi->staleKeyMap != nullptr)
5546 {
5547 if (mi->master != nullptr)
5548 {
5549 for (auto &pair : *mi->staleKeyMap)
5550 {
5551 if (pair.second.empty())
5552 continue;
5553
5554 client *replica = replicaFromMaster(mi);
5555 if (replica == nullptr)
5556 continue;
5557
5558 for (auto &spkey : pair.second)
5559 {
5560 rgobj[1] = spkey.get();
5561 replicationFeedSlave(replica, pair.first, rgobj, 2, false);
5562 }
5563 }
5564 delete mi->staleKeyMap;
5565 mi->staleKeyMap = nullptr;
5566 }
5567 }
5568 }
5569
5570 decrRefCount(rgobj[0]);
5571}
5572
5573void replicationNotifyLoadedKey(redisDb *db, robj_roptr key, robj_roptr val, long long expire) {
5574 if (!g_pserver->fActiveReplica || listLength(g_pserver->slaves) == 0)

Callers 1

replicationCronFunction · 0.85

Calls 8

listRewindFunction · 0.85
listNextFunction · 0.85
replicaFromMasterFunction · 0.85
replicationFeedSlaveFunction · 0.85
decrRefCountFunction · 0.85
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected