1. 29 3月, 2018 1 次提交
  2. 28 3月, 2018 1 次提交
    • A
      Fix ae.c when a timer finalizerProc adds an event. · 8ac7af1c
      antirez 提交于
      While this feature is not used by Redis, ae.c implements the ability for
      a timer to call a finalizer callback when an timer event is deleted.
      This feature was bugged since the start, and because it was never used
      we never noticed a problem. However Anthony LaTorre was using the same
      library in order to implement a different system: he found a bug that he
      describes as follows, and which he fixed with the patch in this commit,
      sent me by private email:
      
          --- Anthony email ---
      
      've found one bug in the current implementation of the timed events.
      It's possible to lose track of a timed event if an event is added in
      the finalizerProc of another event.
      
      For example, suppose you start off with three timed events 1, 2, and
      3. Then the linked list looks like:
      
      3 -> 2 -> 1
      
      Then, you run processTimeEvents and events 2 and 3 finish, so now the
      list looks like:
      
      -1 -> -1 -> 2
      
      Now, on the next iteration of processTimeEvents it starts by deleting
      the first event, and suppose this finalizerProc creates a new event,
      so that the list looks like this:
      
      4 -> -1 -> 2
      
      On the next iteration of the while loop, when it gets to the second
      event, the variable prev is still set to NULL, so that the head of the
      event loop after the next event will be set to 2, i.e. after deleting
      the next event the event loop will look like:
      
      2
      
      and the event with id 4 will be lost.
      
      I've attached an example program to illustrate the issue. If you run
      it you will see that it prints:
      
      ```
      foo id = 0
      spam!
      ```
      
      But if you uncomment line 29 and run it again it won't print "spam!".
      
          --- End of email ---
      
      Test.c source code is as follows:
      
          #include "ae.h"
          #include <stdio.h>
      
          aeEventLoop *el;
      
          int foo(struct aeEventLoop *el, long long id, void *data)
          {
      	printf("foo id = %lld\n", id);
      
      	return AE_NOMORE;
          }
      
          int spam(struct aeEventLoop *el, long long id, void *data)
          {
      	printf("spam!\n");
      
      	return AE_NOMORE;
          }
      
          void bar(struct aeEventLoop *el, void *data)
          {
      	aeCreateTimeEvent(el, 0, spam, NULL, NULL);
          }
      
          int main(int argc, char **argv)
          {
      	el = aeCreateEventLoop(100);
      
      	//aeCreateTimeEvent(el, 0, foo, NULL, NULL);
      	aeCreateTimeEvent(el, 0, foo, NULL, bar);
      
      	aeMain(el);
      
      	return 0;
          }
      
      Anthony fixed the problem by using a linked list for the list of timers, and
      sent me back this patch after he tested the code in production for some time.
      The code looks sane to me, so committing it to Redis.
      8ac7af1c
  3. 26 3月, 2018 1 次提交
  4. 25 3月, 2018 2 次提交
    • A
      AOF: run tests with preamble off when it makes sense. · 2b2652d7
      antirez 提交于
      2b2652d7
    • A
      AOF: enable RDB-preamble rewriting by default. · 28d28ef3
      antirez 提交于
      There are too many advantages in doing this, RDB is faster to persist,
      more compact, much faster to load back. The main issues here are that
      the code is less tested because this was not the old default (so we are
      enabling it for the new 5.0 release), and that the AOF is no longer a
      trivially parsable format from now on. However the non-preamble mode
      will be supported in the future as well, if new data types will be
      added.
      28d28ef3
  5. 24 3月, 2018 2 次提交
  6. 22 3月, 2018 12 次提交
  7. 21 3月, 2018 5 次提交
  8. 20 3月, 2018 5 次提交
  9. 16 3月, 2018 6 次提交
  10. 15 3月, 2018 5 次提交
    • A
      RDB: make RDB check aware of LFU/LRU opcodes. · b1aae86f
      antirez 提交于
      b1aae86f
    • A
      RDB: LRU/LFU branches missed continue. · 8176a2ee
      antirez 提交于
      8176a2ee
    • A
      RDB: Ability to load LFU/LRU info. · 1ce50a7a
      antirez 提交于
      1ce50a7a
    • A
      RDB: Ability to save LFU/LRU info. · d7a5c0eb
      antirez 提交于
      This is a big win for caching use cases, since on reloading Redis will
      still have some idea about what is worth to evict and what not.
      However this only solves part of the problem because the information is
      only partially propagated to slaves (on write operations). Reads will
      not affect slaves LFU and LRU counters, so after a failover the eviction
      decisions are kinda random until keys start to collect some aging/freq info.
      
      However since new slaves are initially populated via RDB file transfer,
      this means that if we spin up a new slave from a master, and perform an
      immediate manual failover (for instance in order to upgrade the master),
      the slave will have eviction informations to use for some time.
      
      The LFU/LRU info is persisted only if the maxmemory policy is set to one
      of the relevant type, even if no actual "maxmemory"  memory limit is
      set.
      d7a5c0eb
    • A
      CG: XINFO STREAM. · 66143616
      antirez 提交于
      66143616