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. */
| 1810 | * to take RDB files around, this violates certain policies in certain |
| 1811 | * environments. */ |
| 1812 | void removeRDBUsedToSyncReplicas(void) { |
| 1813 | serverAssert(GlobalLocksAcquired()); |
| 1814 | |
| 1815 | /* If the feature is disabled, return ASAP but also clear the |
| 1816 | * RDBGeneratedByReplication flag in case it was set. Otherwise if the |
| 1817 | * feature was enabled, but gets disabled later with CONFIG SET, the |
| 1818 | * flag may remain set to one: then next time the feature is re-enabled |
| 1819 | * via CONFIG SET we have have it set even if no RDB was generated |
| 1820 | * because of replication recently. */ |
| 1821 | if (!g_pserver->rdb_del_sync_files) { |
| 1822 | RDBGeneratedByReplication = 0; |
| 1823 | return; |
| 1824 | } |
| 1825 | |
| 1826 | if (allPersistenceDisabled() && RDBGeneratedByReplication) { |
| 1827 | client *slave; |
| 1828 | listNode *ln; |
| 1829 | listIter li; |
| 1830 | |
| 1831 | int delrdb = 1; |
| 1832 | listRewind(g_pserver->slaves,&li); |
| 1833 | while((ln = listNext(&li))) { |
| 1834 | slave = (client*)ln->value; |
| 1835 | if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START || |
| 1836 | slave->replstate == SLAVE_STATE_WAIT_BGSAVE_END || |
| 1837 | slave->replstate == SLAVE_STATE_SEND_BULK) |
| 1838 | { |
| 1839 | delrdb = 0; |
| 1840 | break; /* No need to check the other replicas. */ |
| 1841 | } |
| 1842 | } |
| 1843 | if (delrdb) { |
| 1844 | struct stat sb; |
| 1845 | if (lstat(g_pserver->rdb_filename,&sb) != -1) { |
| 1846 | RDBGeneratedByReplication = 0; |
| 1847 | serverLog(LL_NOTICE, |
| 1848 | "Removing the RDB file used to feed replicas " |
| 1849 | "in a persistence-less instance"); |
| 1850 | bg_unlink(g_pserver->rdb_filename); |
| 1851 | } |
| 1852 | } |
| 1853 | } |
| 1854 | } |
| 1855 | |
| 1856 | void sendBulkToSlave(connection *conn) { |
| 1857 | serverAssert(GlobalLocksAcquired()); |
no test coverage detected