Return null marker for caching even when no row matches the requirements #1841
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
When loading a plugin's configuration, if the database query returns some rows but none of the returned rows match in api_id and consumer_id, the function returns nil. In which case the query result isnt cached. This happens for global plugins:
When plugins are first loaded get_or_set is called on global plugins like
plugins:basic-auth
. If there exists no global entry for this plugin, but there is a api/consumer specific entry some rows are returned. Even though rows are returned, none of them will match resulting in the function returningnil
and the result not being cached. On every request to kong, kong tries to get_or_setplugins:basic-auth
but fails bringing down throughput. This also causes kong to start returning 500 on every request when database is down.Full changelog
Issues resolved
I found no reported issue related to this.