Don't panic if a queue exists, but is empty when repairing metadata.
This commit is contained in:
parent
899b54c082
commit
bb087caddc
|
@ -1,13 +1,10 @@
|
||||||
local queueKey = KEYS[1]
|
local queueKey = KEYS[1]
|
||||||
local queueMetadataKey = KEYS[2]
|
local queueMetadataKey = KEYS[2]
|
||||||
|
|
||||||
local firstMessageWithScore = redis.call("ZRANGE", queueKey, 0, 0, "WITHSCORES")
|
local firstMessageId = tonumber(redis.call("ZRANGE", queueKey, 0, 0, "WITHSCORES")[2])
|
||||||
local lastMessageWithScore = redis.call("ZRANGE", queueKey, -1, -1, "WITHSCORES")
|
local lastMessageId = tonumber(redis.call("ZRANGE", queueKey, -1, -1, "WITHSCORES")[2])
|
||||||
|
|
||||||
if firstMessageWithScore ~= nil and lastMessageWithScore ~= nil then
|
|
||||||
local firstMessageId = tonumber(firstMessageWithScore[2])
|
|
||||||
local lastMessageId = tonumber(lastMessageWithScore[2])
|
|
||||||
|
|
||||||
|
if firstMessageId and lastMessageId then
|
||||||
for messageId = firstMessageId,lastMessageId do
|
for messageId = firstMessageId,lastMessageId do
|
||||||
if redis.call("ZRANGEBYSCORE", queueKey, messageId, messageId) then
|
if redis.call("ZRANGEBYSCORE", queueKey, messageId, messageId) then
|
||||||
-- This message actually exists, and its GUID may be pointing to the wrong ID
|
-- This message actually exists, and its GUID may be pointing to the wrong ID
|
||||||
|
|
|
@ -120,6 +120,12 @@ public class MessagesCacheTest extends AbstractRedisClusterTest {
|
||||||
assertTrue(messagesCache.getMessagesToPersist(DESTINATION_UUID, DESTINATION_DEVICE_ID, 100).isEmpty());
|
assertTrue(messagesCache.getMessagesToPersist(DESTINATION_UUID, DESTINATION_DEVICE_ID, 100).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRepairEmptyQueueMetadata() {
|
||||||
|
// We're happy as long as this doesn't throw an exception
|
||||||
|
messagesCache.repairMetadata(DESTINATION_UUID, DESTINATION_DEVICE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Parameters({"true", "false"})
|
@Parameters({"true", "false"})
|
||||||
public void testRemoveById(final boolean sealedSender) {
|
public void testRemoveById(final boolean sealedSender) {
|
||||||
|
|
Loading…
Reference in New Issue