Skip to content

Commit

Permalink
fix(incremental): dont delete old entity from LMDB if we clear it alr…
Browse files Browse the repository at this point in the history
…eady
  • Loading branch information
chobits committed Oct 16, 2024
1 parent adcbbf0 commit c04f6fc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ local function do_sync()

local t = txn.begin(512)

if ns_delta.wipe then
local wipe = ns_delta.wipe
if wipe then
t:db_drop(false)
end

Expand All @@ -245,9 +246,12 @@ local function do_sync()
local crud_event_type = "create"

if old_entity then
local res, err = delete_entity_for_txn(t, delta_type, old_entity, nil)
if not res then
return nil, err
-- If we need to wipe lmdb, we don't need to not delete it from lmdb.
if not wipe then
local res, err = delete_entity_for_txn(t, delta_type, old_entity, nil)
if not res then
return nil, err
end
end

crud_event_type = "update"
Expand All @@ -267,7 +271,8 @@ local function do_sync()
return nil, err
end

if old_entity then
-- If we need to wipe lmdb, we don't need to delete old entity.
if old_entity and not wipe then
local res, err = delete_entity_for_txn(t, delta_type, old_entity, nil)
if not res then
return nil, err
Expand All @@ -292,7 +297,7 @@ local function do_sync()
return nil, err
end

if ns_delta.wipe then
if wipe then
kong.core_cache:purge()
kong.cache:purge()

Expand Down

0 comments on commit c04f6fc

Please sign in to comment.