MCPcopy Create free account
hub / github.com/F-Stack/f-stack / removeRDBUsedToSyncReplicas

Function removeRDBUsedToSyncReplicas

app/redis-6.2.6/src/replication.c:1054–1094  ·  view source on GitHub ↗

We call this function periodically to remove an RDB file that was * generated because of replication, in an instance that is otherwise * without any persistence. We don't want instances without persistence * to take RDB files around, this violates certain policies in certain * environments. */

Source from the content-addressed store, hash-verified

1052 * to take RDB files around, this violates certain policies in certain
1053 * environments. */
1054void removeRDBUsedToSyncReplicas(void) {
1055 /* If the feature is disabled, return ASAP but also clear the
1056 * RDBGeneratedByReplication flag in case it was set. Otherwise if the
1057 * feature was enabled, but gets disabled later with CONFIG SET, the
1058 * flag may remain set to one: then next time the feature is re-enabled
1059 * via CONFIG SET we have have it set even if no RDB was generated
1060 * because of replication recently. */
1061 if (!server.rdb_del_sync_files) {
1062 RDBGeneratedByReplication = 0;
1063 return;
1064 }
1065
1066 if (allPersistenceDisabled() && RDBGeneratedByReplication) {
1067 client *slave;
1068 listNode *ln;
1069 listIter li;
1070
1071 int delrdb = 1;
1072 listRewind(server.slaves,&li);
1073 while((ln = listNext(&li))) {
1074 slave = ln->value;
1075 if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START ||
1076 slave->replstate == SLAVE_STATE_WAIT_BGSAVE_END ||
1077 slave->replstate == SLAVE_STATE_SEND_BULK)
1078 {
1079 delrdb = 0;
1080 break; /* No need to check the other replicas. */
1081 }
1082 }
1083 if (delrdb) {
1084 struct stat sb;
1085 if (lstat(server.rdb_filename,&sb) != -1) {
1086 RDBGeneratedByReplication = 0;
1087 serverLog(LL_NOTICE,
1088 "Removing the RDB file used to feed replicas "
1089 "in a persistence-less instance");
1090 bg_unlink(server.rdb_filename);
1091 }
1092 }
1093 }
1094}
1095
1096void sendBulkToSlave(connection *conn) {
1097 client *slave = connGetPrivateData(conn);

Callers 1

replicationCronFunction · 0.85

Calls 4

allPersistenceDisabledFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
bg_unlinkFunction · 0.85

Tested by

no test coverage detected