@@ -114,19 +114,19 @@ async def block(id):
114
114
tasks .append (block (i ))
115
115
await asyncio .gather (* tasks )
116
116
117
-
118
117
# produce is constantly waking up consumers. It is used to trigger the
119
118
# flow that creates wake ups on a differrent database in the
120
119
# middle of continuation transaction.
121
120
async def tasks_produce (num , iters ):
122
121
LPUSH_SCRIPT = """
123
122
redis.call('LPUSH', KEYS[1], "val")
124
123
"""
124
+
125
125
async def produce (id ):
126
126
c = df_server .client (db = 1 ) # important to be on a different db
127
127
for i in range (iters ):
128
128
# Must be a lua script and not multi-exec for some reason.
129
- await c .eval (LPUSH_SCRIPT , 1 , f"list{{{ id } }}" )
129
+ await c .eval (LPUSH_SCRIPT , 1 , f"list{{{ id } }}" )
130
130
131
131
tasks = []
132
132
for i in range (num ):
@@ -151,7 +151,6 @@ async def drain(id, iters):
151
151
await asyncio .gather (* tasks )
152
152
logging .info ("Finished consuming" )
153
153
154
-
155
154
num_keys = 32
156
155
num_iters = 200
157
156
async_task1 = asyncio .create_task (blmove_task_loose (num_keys ))
@@ -288,3 +287,58 @@ async def test_rename_huge_values(df_factory, type):
288
287
target_data = await StaticSeeder .capture (client )
289
288
290
289
assert source_data == target_data
290
+
291
+
292
+ @pytest .mark .asyncio
293
+ async def test_key_bump_ups (df_factory ):
294
+ master = df_factory .create (
295
+ proactor_threads = 2 ,
296
+ cache_mode = "true" ,
297
+ )
298
+ df_factory .start_all ([master ])
299
+ c_master = master .client ()
300
+
301
+ await c_master .execute_command ("DEBUG POPULATE 18000 KEY 32 RAND" )
302
+
303
+ info = await c_master .info ("stats" )
304
+ assert info ["bump_ups" ] == 0
305
+
306
+ keys = await c_master .execute_command ("SCAN 0" )
307
+ keys = keys [1 ][0 :10 ]
308
+
309
+ # Bump keys
310
+ for key in keys :
311
+ await c_master .execute_command ("GET " + key )
312
+ info = await c_master .info ("stats" )
313
+ assert info ["bump_ups" ] <= 10
314
+
315
+ # Multi get bump
316
+ await c_master .execute_command ("MGET " + " " .join (keys ))
317
+ info = await c_master .info ("stats" )
318
+ assert info ["bump_ups" ] >= 10 and info ["bump_ups" ] <= 20
319
+ last_bump_ups = info ["bump_ups" ]
320
+
321
+ for key in keys :
322
+ await c_master .execute_command ("DEL " + key )
323
+
324
+ # DEL should not bump up any key
325
+ info = await c_master .info ("stats" )
326
+ assert last_bump_ups == info ["bump_ups" ]
327
+
328
+ # Find key that has slot > 0 and bump it
329
+ while True :
330
+ keys = await c_master .execute_command ("SCAN 0" )
331
+ key = keys [1 ][0 ]
332
+
333
+ debug_key_info = await c_master .execute_command ("DEBUG OBJECT " + key )
334
+ slot_id = int (dict (map (lambda s : s .split (":" ), debug_key_info .split ()))["slot" ])
335
+ if slot_id == 0 :
336
+ # delete the key and continue
337
+ await c_master .execute_command ("DEL " + key )
338
+ continue
339
+
340
+ await c_master .execute_command ("GET " + key )
341
+ debug_key_info = await c_master .execute_command ("DEBUG OBJECT " + key )
342
+ new_slot_id = int (dict (map (lambda s : s .split (":" ), debug_key_info .split ()))["slot" ])
343
+ assert new_slot_id + 1 == slot_id
344
+ break
0 commit comments