Skip to content

Commit 5c3b0ad

Browse files
authored
keep del when del-set-sequence exist
what I did: when del-set-sequence exist in consumer table, I keep the del event been execute even a set of the same key is already seen after the del. why I did: in the old code, the del is setting an key without fv, so if a set with fv after, it will only execute a set, so the multimap m_toSync can not seen the del event, sometimes the lost del may result errors if something is depending on the del event.
1 parent bcf48b2 commit 5c3b0ad

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

common/consumer_state_table_pops.lua

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ local keys = redis.call('SPOP', KEYS[1], ARGV[1])
66
local n = table.getn(keys)
77
for i = 1, n do
88
local key = keys[i]
9+
local fieldvalues = {}
910
-- Check if there was request to delete the key, clear it in table first
1011
local num = redis.call('SREM', KEYS[3], key)
1112
if num == 1 then
1213
redis.call('DEL', tablename..key)
14+
table.insert(ret, {key, fieldvalues})
1315
end
1416
-- Push the new set of field/value for this key in table
1517
local fieldvalues = redis.call('HGETALL', stateprefix..tablename..key)
16-
table.insert(ret, {key, fieldvalues})
17-
for i = 1, #fieldvalues, 2 do
18-
redis.call('HSET', tablename..key, fieldvalues[i], fieldvalues[i + 1])
18+
if table.getn(fieldvalues) > 0 then
19+
table.insert(ret, {key, fieldvalues})
20+
for i = 1, #fieldvalues, 2 do
21+
redis.call('HSET', tablename..key, fieldvalues[i], fieldvalues[i + 1])
22+
end
1923
end
2024
-- Clean up the key in temporary state table
2125
redis.call('DEL', stateprefix..tablename..key)

0 commit comments

Comments
 (0)