1. 21 Mar, 2019 2 commits
  2. 20 Mar, 2019 1 commit
  3. 18 Mar, 2019 1 commit
  4. 10 Mar, 2019 1 commit
  5. 09 Mar, 2019 1 commit
  6. 12 Feb, 2019 1 commit
    • zhaozhao.zz's avatar
      ACL: add masteruser configuration for replication · ea9d3aef
      zhaozhao.zz authored
      In mostly production environment, normal user's behavior should be
      limited.
      
      Now in redis ACL mechanism we can do it like that:
      
          user default on +@all ~* -@dangerous nopass
          user admin on +@all ~* >someSeriousPassword
      
      Then the default normal user can not execute dangerous commands like
      FLUSHALL/KEYS.
      
      But some admin commands are in dangerous category too like PSYNC,
      and the configurations above will forbid replica from sync with master.
      
      Finally I think we could add a new configuration for replication,
      it is masteruser option, like this:
      
          masteruser admin
          masterauth someSeriousPassword
      
      Then replica will try AUTH admin someSeriousPassword and get privilege
      to execute PSYNC. If masteruser is NULL, replica would AUTH with only
      masterauth like before.
      ea9d3aef
  7. 25 Jan, 2019 1 commit
  8. 21 Jan, 2019 3 commits
  9. 17 Jan, 2019 1 commit
  10. 09 Jan, 2019 2 commits
  11. 31 Oct, 2018 1 commit
  12. 05 Oct, 2018 1 commit
  13. 27 Sep, 2018 1 commit
  14. 19 Sep, 2018 1 commit
  15. 11 Sep, 2018 2 commits
  16. 17 Jul, 2018 1 commit
    • Oran Agra's avatar
      fix rare replication stream corruption with disk-based replication · d5559898
      Oran Agra authored
      The slave sends \n keepalive messages to the master while parsing the rdb,
      and later sends REPLCONF ACK once a second. rarely, the master recives both
      a linefeed char and a REPLCONF in the same read, \n*3\r\n$8\r\nREPLCONF\r\n...
      and it tries to trim two chars (\r\n) from the query buffer,
      trimming the '*' from *3\r\n$8\r\nREPLCONF\r\n...
      
      then the master tries to process a command starting with '3' and replies to
      the slave a bunch of -ERR and one +OK.
      although the slave silently ignores these (prints a log message), this corrupts
      the replication offset at the slave since the slave increases the replication
      offset, and the master did not.
      
      other than the fix in processInlineBuffer, i did several other improvments
      while hunting this very rare bug.
      
      - when redis replies with "unknown command" it includes a portion of the
        arguments, not just the command name. so it would be easier to understand
        what was recived, in my case, on the slave side,  it was -ERR, but
        the "arguments" were the interesting part (containing info on the error).
      - about a year ago i added code in addReplyErrorLength to print the error to
        the log in case of a reply to master (since this string isn't actually
        trasmitted to the master), now changed that block to print a similar log
        message to indicate an error being sent from the master to the slave.
        note that the slave is marked as CLIENT_SLAVE only after PSYNC was received,
        so this will not cause any harm for REPLCONF, and will only indicate problems
        that are gonna corrupt the replication stream anyway.
      - two places were c->reply was emptied, and i wanted to reset sentlen
        this is a precaution (i did not actually see such a problem), since a
        non-zero sentlen will cause corruption to be transmitted on the socket.
      d5559898
  17. 16 Jul, 2018 1 commit
    • Oran Agra's avatar
      slave buffers were wasteful and incorrectly counted causing eviction · bf680b6f
      Oran Agra authored
      A) slave buffers didn't count internal fragmentation and sds unused space,
         this caused them to induce eviction although we didn't mean for it.
      
      B) slave buffers were consuming about twice the memory of what they actually needed.
      - this was mainly due to sdsMakeRoomFor growing to twice as much as needed each time
        but networking.c not storing more than 16k (partially fixed recently in 237a38737).
      - besides it wasn't able to store half of the new string into one buffer and the
        other half into the next (so the above mentioned fix helped mainly for small items).
      - lastly, the sds buffers had up to 30% internal fragmentation that was wasted,
        consumed but not used.
      
      C) inefficient performance due to starting from a small string and reallocing many times.
      
      what i changed:
      - creating dedicated buffers for reply list, counting their size with zmalloc_size
      - when creating a new reply node from, preallocate it to at least 16k.
      - when appending a new reply to the buffer, first fill all the unused space of the
        previous node before starting a new one.
      
      other changes:
      - expose mem_not_counted_for_evict info field for the benefit of the test suite
      - add a test to make sure slave buffers are counted correctly and that they don't cause eviction
      bf680b6f
  18. 03 Jul, 2018 2 commits
    • Jack Drogon's avatar
      Fix typo · 93238575
      Jack Drogon authored
      93238575
    • antirez's avatar
      Set repl_down_since to zero on state change. · 677d10b2
      antirez authored
      PR #5081 fixes an "interesting" bug about Redis Cluster failover but in
      general about the updating of repl_down_since, that is used in order to
      count the time a slave was left disconnected from its master.
      
      While the fix provided resolves the specific issue, in general the
      validity of repl_down_since is limited to states that are different
      than the state CONNECTED, and the disconnected time is set when the
      state is DISCONNECTED. However from CONNECTED to other states, the state
      machine must always go to DISCONNECTED first. So it makes sense to set
      the field to zero (since it is meaningless in that context) when the
      state is set to CONNECTED.
      677d10b2
  19. 30 Jun, 2018 1 commit
  20. 26 Jun, 2018 4 commits
  21. 06 Jun, 2018 1 commit
  22. 16 Jan, 2018 2 commits
  23. 05 Dec, 2017 1 commit
    • antirez's avatar
      add linkClient(): adds the client and caches the list node. · 62a4b817
      antirez authored
      We have this operation in two places: when caching the master and
      when linking a new client after the client creation. By having an API
      for this we avoid incurring in errors when modifying one of the two
      places forgetting the other. The function is also a good place where to
      document why we cache the linked list node.
      
      Related to #4497 and #4210.
      62a4b817
  24. 30 Nov, 2017 1 commit
  25. 24 Nov, 2017 1 commit
  26. 01 Nov, 2017 1 commit
    • zhaozhao.zz's avatar
      PSYNC2: safe free backlog when reach the time limit · 6ddf0ea2
      zhaozhao.zz authored
      When we free the backlog, we should use a new
      replication ID and clear the ID2. Since without
      backlog we can not increment master_repl_offset
      even do write commands, that may lead to inconsistency
      when we try to connect a "slave-before" master
      (if this master is our slave before, our replid
      equals the master's replid2). As the master have our
      history, so we can match the master's replid2 and
      second_replid_offset, that make partial sync work,
      but the data is inconsistent.
      6ddf0ea2
  27. 20 Sep, 2017 2 commits
    • antirez's avatar
      PSYNC2: More refinements related to #4316. · bb3b5ddd
      antirez authored
      bb3b5ddd
    • zhaozhao.zz's avatar
      PSYNC2: make persisiting replication info more solid · b541ccef
      zhaozhao.zz authored
      This commit is a reinforcement of commit c1c99e9f.
      
      1. Replication information can be stored when the RDB file is
      generated by a mater using server.slaveseldb when server.repl_backlog
      is not NULL, or set repl_stream_db be -1. That's safe, because
      NULL server.repl_backlog will trigger full synchronization,
      then master will send SELECT command to replicaiton stream.
      2. Only do rdbSave* when rsiptr is not NULL,
      if we do rdbSave* without rdbSaveInfo, slave will miss repl-stream-db.
      3. Save the replication informations also in the case of
      SAVE command, FLUSHALL command and DEBUG reload.
      b541ccef
  28. 19 Sep, 2017 2 commits
    • antirez's avatar
      PSYNC2: Fix the way replication info is saved/loaded from RDB. · c1c99e9f
      antirez authored
      This commit attempts to fix a number of bugs reported in #4316.
      They are related to the way replication info like replication ID,
      offsets, and currently selected DB in the master client, are stored
      and loaded by Redis. In order to avoid inconsistencies the changes in
      this commit try to enforce that:
      
      1. Replication information are only stored when the RDB file is
      generated by a slave that has a valid 'master' client, so that we can
      always extract the currently selected DB.
      2. When replication informations are persisted in the RDB file, all the
      info for a successful PSYNC or nothing is persisted.
      3. The RDB replication informations are only loaded if the instance is
      configured as a slave, otherwise a master can start with IDs that relate
      to a different history of the data set, and stil retain such IDs in the
      future while receiving unrelated writes.
      c1c99e9f
    • antirez's avatar
      PSYNC2: Create backlog on slave partial sync as well. · b75ae0bb
      antirez authored
      A slave may be started with an RDB file able to provide enough slave to
      perform a successful partial SYNC with its master. However in such a
      case, how outlined in issue #4268, the slave backlog will not be
      started, since it was only initialized on full syncs attempts. This
      creates different problems with successive PSYNC attempts that will
      always result in full synchronizations.
      
      Thanks to @fdingiit for discovering the issue.
      b75ae0bb