Disallow insertion of duplicate messages.

This commit is contained in:
Jon Chambers 2020-10-04 11:36:06 -04:00 committed by Jon Chambers
parent 1ccfe928f7
commit 5e3f8b9c2e
2 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,10 @@ local currentTime = ARGV[2]
local sender = ARGV[3]
local guid = ARGV[4]
if redis.call("HEXISTS", queueMetadataKey, guid) == 1 then
return tonumber(redis.call("HGET", queueMetadataKey, guid))
end
local messageId = redis.call("HINCRBY", queueMetadataKey, "counter", 1)
redis.call("ZADD", queueKey, "NX", messageId, message)

View File

@ -6,6 +6,7 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.whispersystems.textsecuregcm.entities.MessageProtos;
@ -84,6 +85,7 @@ public class MessagesCacheTest extends AbstractRedisClusterTest {
}
@Test
@Ignore("Depends on incorrect duplicate-insert behavior that has since been fixed")
public void testRepairMetadata() {
final int distinctUuidCount = 17;