Redis ltrim - possible race condition? -
is there possible race condition redis' ltrim , rpush?
for instance, suppose redis list has these items: [1, 2, 3, 4, 5]
and call ltrim list 4 -1
should slice list [5]
but let's say: a millisecond after ltrim has started , before ltrim finished, thread pushing items list:
rpush list 6 rpush list 7
when both 2 rpushes, , ltrims finished, resulting list consist of [5, 6, 7]?
could possibly [5]? in other words, there possibility of race condition ltrim creating temporary list [5], , overwrites [5,6,7] [5] after 2 rpushes done?
short answer: no, because commands atomic.
honest answer: don't think because think operations atomic; however, website doesn't explicitly state atomic i'm 99.99999999% sure are.
logical answer: redis single-threaded, there no other threads preempt ltrim command. race condition occur in single threaded application have explicitly jump out of ltrim operation before it's done , start doing else, doesn't make sense.
Comments
Post a Comment