-
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
fix(dbless): perform uniqueness checks on unique fields #11199
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fb97611
to
bfe963b
Compare
Further changes in the DB-less UUID generation algorithm may change this value. (Ooh, foreshadowing!) Signed-off-by: Hisham Muhammad <hisham@gobolinux.org>
DB-less mode wasn't performing proper uniqueness checks on primary and endpoint keys. This would cause entities to be silently dropped: in the event of conflicting keys, the last one lexically present in the input file would take precedence. The uniqueness check for primary keys needs to happen here, at an early stage where the maps `by_id` and `by_key` are built, otherwise entities are silently lost. Other uniqueness checks can happen later, at the flattening stage. See the following commit.
This will be useful later when we trigger uniqueness checks to fields of flattened entities.
bfe963b
to
82e6b99
Compare
This would cause uniqueness constraints to be missed if two entities have distinct endpoint keys but their cache keys rely on the uniqueness of other fields. When using a database, this would be usually be caught by explicit DB constraints, but here we subsume the cache key uniqueness constraint to the generated UUID. This has the nice property that it saves us from performing an extra explicit check for the uniqueness of composite cache keys, since id's are now being properly checked for uniqueness. Co-authored-by: Michael Martin <michael.martin@konghq.com>
82e6b99
to
2b2e4c4
Compare
locao
approved these changes
Jul 10, 2023
This PR seems break an EE function: https://github.com/Kong/kong-ee/pull/6023#discussion_r1265101739 New Fix #11236 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
DB-less mode wasn't performing proper uniqueness checks on declarative config inputs. This is especially problematic on
primary and endpoint keys. This would cause entities to be silently dropped: in the event of conflicting keys, the last one lexically present in the input file would take precedence.
For other unique fields, when using Hybrid mode you would eventually get a database error as the DB would have the uniqueness constraint set, but for pure DB-less you would get inconsistent data.
Checklist
Full changelog