-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(clustering/rpc): tunings and fixes for rubustness #13771
Conversation
eada306
to
522dbf3
Compare
427835a
to
a566ec6
Compare
150fa2d
to
c625a60
Compare
9281822
to
b7963e4
Compare
b7963e4
to
a7ba490
Compare
|
||
-- If the item belongs to a specific workspace, | ||
-- use it directly without using the default one. | ||
local ws_id = item.ws_id or workspace_id(schema, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: need to add a test to check the ws_id value if the schema is non-workspaceable. https://konghq.atlassian.net/browse/KAG-5706
This comment is not a block.
kong/db/declarative/import.lua
Outdated
for _, wid in ipairs {ws_id, GLOBAL_WORKSPACE_TAG} do | ||
local key = unique_field_key(entity_name, wid, "cache_key", cache_key) | ||
|
||
-- store item_key or nil into lmdb | ||
t:set(key, idx_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker, just a comment for other reviewers.
TODO: we only want to save the entity with key containing specific ws_id, not a GLOBAL workspace id like*
, which does not consume too much memory space for lmdb. https://konghq.atlassian.net/browse/KAG-5704
kong/db/declarative/import.lua
Outdated
-- * <entity_name>|*|*|<pk_string> => serialized item | ||
-- * <entity_name>|<ws_id>|*|<pk_string> => actual item key | ||
-- | ||
-- * <entity_name>|*|<unique_field_name>|sha256(field_value) => actual item key | ||
-- * <entity_name>|<ws_id>|<unique_field_name>|sha256(field_value) => actual item key | ||
-- | ||
-- * <entity_name>|*|<foreign_field_name>|<foreign_key>|<pk_string> => actual item key | ||
-- * <entity_name>|<ws_id>|<foreign_field_name>|<foreign_key>|<pk_string> => actual item key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker, -> https://github.com/Kong/kong/pull/13771/files#r1821977274
@@ -359,7 +359,8 @@ local sync_emitter = { | |||
|
|||
emit_entity = function(self, entity_name, entity_data) | |||
self.out_n = self.out_n + 1 | |||
self.out[self.out_n] = { type = entity_name , row = entity_data, version = self.sync_version, } | |||
self.out[self.out_n] = { type = entity_name , row = entity_data, version = self.sync_version, | |||
ws_id = kong.default_workspace, } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check it later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here ws_id
is a fallback, if row(entity) has the field ws_id
, do_sync()
will use it but not delta.ws_id.
if not res then | ||
return nil, err | ||
end | ||
end | ||
|
||
local res, err = insert_entity_for_txn(t, delta_type, delta_row, nil) | ||
local res, err = insert_entity_for_txn(t, delta_type, delta_row, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
row.ws_id ? delta.ws_id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hooks.lua
, delta item will always has the field ws_id
, so opts.workspace
is a fallback.
local deltas = {
{
type = name,
pk = pk,
ws_id = ws_id,
entity = is_delete and ngx_null or entity,
},
}
* fix(clustering/sync): set ws_id in do_sync() * comments
* fix(clustering/sync): delta.version may be null * isempty * default_ws_changed
* rename db id to pk * change id to pk in Lua * change pk to json * schema:extract_pk_values
Co-authored-by: Datong Sun <datong.sun@konghq.com>
* change db filed name * rename in rpc.sync * rename in export
…#13815) * fix(incremental sync): fix cache_key handling for select_by_cache_key * fix some comments * fix: remove unnecessary comment
* refactor(dbless): clean logic of selec_by_field * check schema_field
f35c3d3
to
63c17e2
Compare
Cherry-pick failed for Please cherry-pick the changes locally. git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-13771-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-13771-to-master-to-upstream
git checkout -b cherry-pick-13771-to-master-to-upstream
ancref=$(git merge-base 5cab556adc6b0c74c11b83baeb2b81010881e8dc b37bdd165487396379420cef355d16f3fb8a8583)
git cherry-pick -x $ancref..b37bdd165487396379420cef355d16f3fb8a8583 |
Cherry-picked in https://github.com/Kong/kong-ee/pull/10460 |
Summary
Please squash and merge.
KAG-5617
Related tickets:
KAG-5602
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
Fix #[issue number]