sql_cacher: add support for reads of sql_cached_value while table is being reloaded#3731
Open
davidtrihy-genesys wants to merge 2 commits intoOpenSIPS:masterfrom
Open
sql_cacher: add support for reads of sql_cached_value while table is being reloaded#3731davidtrihy-genesys wants to merge 2 commits intoOpenSIPS:masterfrom
davidtrihy-genesys wants to merge 2 commits intoOpenSIPS:masterfrom
Conversation
Contributor
Author
|
@liviuchircu as we discussed in the ticket |
e9a2b10 to
e1d8ffc
Compare
Contributor
Author
|
@liviuchircu rather than pushing commits to fix any compiler warnings on all the platforms, I'll let you review first and then I can address any additional ones that pop up |
Contributor
Author
|
The multi_arch build failed for an unrelated reason to my changes but I can't kick it off again so I consider this PR fully ready for review |
Contributor
Author
|
@liviuchircu just wondering if you want to still take this change? We've been running it now for a while and it's performing as expected |
This file contains hidden or 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
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
When calling
$sql_cached_valueduring a reload initiated by MI it locks the whole table and that read tries to acquire a lock and can only acquire it once the write has finished, this can block SIP processing unnecessarily as the cachedb implementations typically lock on their own values, eg. cachedb_local locks on each hash which corresponds to a row, this PR adds support to read during a full reload and only lock the row being read, if a reload is in progress you can read the previous version value during the reload if it is returnedDetails and Solution
Uses stdatomic to set a boolean flag once the write lock is acquired, this can then be tested during reads and be more permissive with values returned as long as the version is only current version - 1 otherwise it returns null
Compatibility
Changes the default behaviour to now be more permissive but adds a new param to
cache_tablecalledfull_caching_lock_scopewhich can be set torowortable, defaults torowand setting it totableprovides support for the current way it works