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. */
| 1052 | * to take RDB files around, this violates certain policies in certain |
| 1053 | * environments. */ |
| 1054 | void 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 | |
| 1096 | void sendBulkToSlave(connection *conn) { |
| 1097 | client *slave = connGetPrivateData(conn); |
no test coverage detected