This function puts a replica in the online state, and should be called just * after a replica received the RDB file for the initial synchronization, and * we are finally ready to send the incremental stream of commands. * * It does a few things: * 1) Close the replica's connection async if it doesn't need replication * commands buffer stream, since it actually isn't a valid replica. * 2)
| 1770 | * sending it to the replica. |
| 1771 | * 4) Update the count of "good replicas". */ |
| 1772 | void putSlaveOnline(client *replica) { |
| 1773 | replica->replstate = SLAVE_STATE_ONLINE; |
| 1774 | |
| 1775 | replica->repl_put_online_on_ack = 0; |
| 1776 | replica->repl_ack_time = g_pserver->unixtime; /* Prevent false timeout. */ |
| 1777 | |
| 1778 | if (replica->flags & CLIENT_REPL_RDBONLY) { |
| 1779 | serverLog(LL_NOTICE, |
| 1780 | "Close the connection with replica %s as RDB transfer is complete", |
| 1781 | replicationGetSlaveName(replica)); |
| 1782 | freeClientAsync(replica); |
| 1783 | return; |
| 1784 | } |
| 1785 | if (connSetWriteHandler(replica->conn, sendReplyToClient, true) == C_ERR) { |
| 1786 | serverLog(LL_WARNING,"Unable to register writable event for replica bulk transfer: %s", strerror(errno)); |
| 1787 | freeClient(replica); |
| 1788 | return; |
| 1789 | } |
| 1790 | refreshGoodSlavesCount(); |
| 1791 | /* Fire the replica change modules event. */ |
| 1792 | moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, |
| 1793 | REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, |
| 1794 | NULL); |
| 1795 | serverLog(LL_NOTICE,"Synchronization with replica %s succeeded", |
| 1796 | replicationGetSlaveName(replica)); |
| 1797 | |
| 1798 | if (!(replica->slave_capa & SLAVE_CAPA_ACTIVE_EXPIRE) && g_pserver->fActiveReplica) |
| 1799 | { |
| 1800 | serverLog(LL_WARNING, "Warning: replica %s does not support active expiration. This client may not correctly process key expirations." |
| 1801 | "\n\tThis is OK if you are in the process of an active upgrade.", replicationGetSlaveName(replica)); |
| 1802 | serverLog(LL_WARNING, "Connections between active replicas and traditional replicas is deprecated. This will be refused in future versions." |
| 1803 | "\n\tPlease fix your replica topology"); |
| 1804 | } |
| 1805 | } |
| 1806 | |
| 1807 | /* We call this function periodically to remove an RDB file that was |
| 1808 | * generated because of replication, in an instance that is otherwise |
no test coverage detected