@@ -2549,7 +2549,12 @@ void RdbLoader::LoadItemsBuffer(DbIndex db_ind, const ItemsBuf& ib) {
2549
2549
if (item->load_config .append ) {
2550
2550
auto res = db_slice.FindMutable (db_cntx, item->key );
2551
2551
if (!IsValid (res.it )) {
2552
- LOG (ERROR) << " Count not to find append key '" << item->key << " ' in DB " << db_ind;
2552
+ // If the item has expired we may not find the key. Note if the key
2553
+ // is found, but expired since we started loading, we still append to
2554
+ // avoid an inconsistent state where only part of the key is loaded.
2555
+ if (item->expire_ms == 0 || db_cntx.time_now_ms < item->expire_ms ) {
2556
+ LOG (ERROR) << " Count not to find append key '" << item->key << " ' in DB " << db_ind;
2557
+ }
2553
2558
continue ;
2554
2559
}
2555
2560
pv_ptr = &res.it ->second ;
@@ -2578,8 +2583,10 @@ void RdbLoader::LoadItemsBuffer(DbIndex db_ind, const ItemsBuf& ib) {
2578
2583
continue ;
2579
2584
}
2580
2585
2581
- if (item->expire_ms > 0 && db_cntx.time_now_ms >= item->expire_ms )
2586
+ if (item->expire_ms > 0 && db_cntx.time_now_ms >= item->expire_ms ) {
2587
+ VLOG (1 ) << " Expire key on load: " << item->key ;
2582
2588
continue ;
2589
+ }
2583
2590
2584
2591
auto op_res = db_slice.AddOrUpdate (db_cntx, item->key , std::move (pv), item->expire_ms );
2585
2592
if (!op_res) {
@@ -2701,7 +2708,7 @@ bool RdbLoader::ShouldDiscardKey(std::string_view key, ObjSettings* settings) co
2701
2708
* load all the keys as they are, since the log of operations later
2702
2709
* assume to work in an exact keyspace state. */
2703
2710
if (ServerState::tlocal ()->is_master && settings->has_expired ) {
2704
- VLOG (2 ) << " Expire key: " << key;
2711
+ VLOG (2 ) << " Expire key on read : " << key;
2705
2712
return true ;
2706
2713
}
2707
2714
0 commit comments