OpenAtomFoundation / pika

Pika is a Redis-Compatible database developed by Qihoo's infrastructure team.
BSD 3-Clause "New" or "Revised" License
5.76k stars 1.19k forks source link

The return value of the pika's "delete within seconds" function is incorrect. #2762

Closed chejinge closed 1 week ago

chejinge commented 1 week ago

Is this a regression?

Yes

Description

测试脚本: import redis import sys import random

charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"

def genstring(size: int) -> str: s = "" for in range(size): index = int(random.random()*len(charset)) s += charset[index] return s

def insert_zset_data(client: redis.Redis, key): mem1 = gen_string(20) mem2 = gen_string(20) print("mem1: ", mem1) print("mem2: ", mem2) pipe = client.pipeline(transaction=False) pipe.zadd(key, {mem1: 100}) pipe.delete(key) pipe.zadd(key, {mem2: 101}) pipe.execute()

def main(): if len(sys.argv) < 4: print("Usage: python meta_version.py ") return host = sys.argv[1] port = int(sys.argv[2]) password = sys.argv[3] client = redis.Redis(host=host, port=port, password=password) insert_zset_data(client, "test_zset")

if name == "main": main()

测试结果: mem1: tbXTWdRZIgg4lLFUCK6a mem2: 0bN1D0iwE5Ujqt7CfwzI

image

已经秒删的key还能ZREVRANK出来

Please provide a link to a minimal reproduction of the bug

No response

Screenshots or videos

No response

Please provide the version you discovered this bug in (check about page for version information)

No response

Anything else?

No response

chejinge commented 1 week ago

分析: pika的命令执行及返回结果: image redis的命令执行及返回结果: image ZREVRANK:如果成员是有序集 key 的成员,返回成员的排名。 如果成员不是有序集 key 的成员,返回 nil 。 说明pika没有秒删成功 元素还是存在的 subkey 单独增加删除。compact可能误删 解决办法: 延迟删除就是判断是subkeey假定他会删,延迟几分钟后再删