Skip to content

Commit

Permalink
Fix(tests): enable incremental sync for hybrid case (#13746)
Browse files Browse the repository at this point in the history
* fix(tests): enable inc sync for 01-sync_spec.lua

* fix(incremental): dont delete old entity from LMDB if we clear it already

* dont modify crud type even though we dont delete old entity from lmdb

* localize ns_delta.wipe

* localize ns_delta.wipe - part 2

* fix that cp will not init clustering

* refactor old_entity logic

* cp should always support full sync protocol

* Revert "cp should always support full sync protocol"

This reverts commit 6803958.

* Revert "fix that cp will not init clustering"

This reverts commit b84f261.

* Revert "fix(tests): enable inc sync for 01-sync_spec.lua"

This reverts commit 54d0f54.

---------

Co-authored-by: chronolaw <chrono_cpp@me.com>
  • Loading branch information
chobits and chronolaw authored Oct 16, 2024
1 parent cdac487 commit 2f55282
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 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 @@ -242,15 +243,14 @@ local function do_sync()
return nil, err
end

local crud_event_type = "create"
local crud_event_type = old_entity and "update" or "create"

if old_entity then
-- If we will wipe lmdb, we don't need to delete it from lmdb.
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
end

crud_event_type = "update"
end

local res, err = insert_entity_for_txn(t, delta_type, delta_row, nil)
Expand All @@ -267,7 +267,8 @@ local function do_sync()
return nil, err
end

if old_entity then
-- If we will wipe lmdb, we don't need to delete it from lmdb.
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 +293,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 2f55282

Please sign in to comment.