Skip to content

Make the timer event list in sorted order && Fix for issue #633 - #654

Closed
jokea wants to merge 2 commits into
redis:unstablefrom
jokea:timer
Closed

jokea wants to merge 2 commits into
redis:unstablefrom
jokea:timer

Conversation

@jokea

@jokea jokea commented Aug 30, 2012

Copy link
Copy Markdown
Contributor

I can't split the commits into two pull requests, so put them in a single one.

What the first commit does:

Insert the timer event in sorted order, so it's O(1) to get
the nearest timer. Insert and delete a timer is O(N).

And the second:

When system time changes back, the timer will not worker properly
hence some core functionality of redis will stop working(e.g. replication,
bgsave, etc). 

The patch saves the previous time and when a system clock skew is detected,
it will force expire all timers.

See issue #633 for details of the second commit.

jokea added 2 commits August 30, 2012 15:06
the nearest timer. Insert and delete a timer is O(N).
When system time changes back, the timer will not worker properly
hence some core functionality of redis will stop working(e.g. replication,
bgsave, etc). See issue redis#633 for details.

The patch saves the previous time and when a system clock skew is detected,
it will force expire all timers.
@AnuragBerdia

Copy link
Copy Markdown

Hi Jokea,
This may sound stupid, I have no idea how this(pull request) works in redis & github.
Any ideas, when will this be merged in redis main branch and released?

Thanks.

@antirez

antirez commented Sep 12, 2012

Copy link
Copy Markdown
Contributor

Hi, I put this issue in 2.6 milestone for review in the next days. Thanks.

@antirez

antirez commented Oct 4, 2012

Copy link
Copy Markdown
Contributor

Review started, I hope to merge today.

@antirez

antirez commented Oct 4, 2012

Copy link
Copy Markdown
Contributor

Hi folks,

I think commit 4274554 is fine and fixes an actual issue so I want to merge it into 2.6 and unstable.

For commit 941825c things are a bit different, basically from the point of view of Redis that has just one timer it does not offer a real advantage, but my add bugs, I found one for instance proof reading the code: the processTimeEvents() function no longer checks for maxid to process (plus restarting from head again if an event is processed), so if an event fires a callback that alters the list (for instance deleting its own time event, the one that fired the procedure) bad things may happen.

At this point I'm cherry-picking commit 4274554 and moving the milestone of this issue to 2.8 so that we can have time to reimplement the O(1) thing with a skiplist and with more checks to make sure everything will be safe.

Thanks,
Salvatore

@antirez

antirez commented Oct 4, 2012

Copy link
Copy Markdown
Contributor

Another note, this time about commit 4274554, currently the code is thread safe, so I would like to retain this capability and add a last_sec field in the eventloop structure itself so that every event loop has its own private field. In this way it is possible to use the library with multiple event loops from multiple threads.

@antirez

antirez commented Oct 4, 2012

Copy link
Copy Markdown
Contributor

Moved to 2.8

@jokea

jokea commented Oct 9, 2012

Copy link
Copy Markdown
Contributor Author

I agree with you that line 173-177 can be safely removed.
About the O(1) commit, since redis has only one timer, so there's not any overhead without it.

@antirez antirez removed this from the Redis 2.8 milestone May 15, 2017

@enjoy-binbin enjoy-binbin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One has been solved, and the O(1) commit, since there are not many time events, i guess we won’t consider it anymore.

sundb pushed a commit to sundb/redis that referenced this pull request Jul 28, 2025
Adds light-weight cluster bus header for pubsub message. Closes redis#557.

This also supports sending to and receiving non-light messages from
older versions of the engine.

The light-weight cluster bus message supports multiple pubsub messages
(payloads) for one pubsub channel. Receiving messages with multiple
payloads is supported but we're not yet sending such multi-payload
messages to other nodes.

---------

Signed-off-by: Roshan Khatri <[email protected]>
minchopaskal pushed a commit to minchopaskal/redis that referenced this pull request Oct 16, 2025
new build macro XXH_NO_STDLIB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants