-
Notifications
You must be signed in to change notification settings - Fork 61
Fix datarace when reading handlers in SharedHandler #91
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
base: master
Are you sure you want to change the base?
Conversation
MbolotSuse
left a comment
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.
This seems to be close to what the code was previously doing: a3ff816. I think we need more consideration on this one before making changes.
|
Before the code was holding the lock while it ran each handler (and there are various metrics in the loop that suggest people have been concerned with how long it takes to update an object by applying an array of (mutating webhook?) handlers to it. Now the use of the lock suggests that it's waiting for the array of handlers to be built, and then it uses it. But the fact of the race condition in the helm-lock tests suggest that something else is modifying the array while the lasso sharedhandler loops through it, so it's safer to make a shallow copy of it and loop through that. If the underlying |
ericpromislow
left a comment
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.
Well, I wrote this code, but I think it's correct, and not onerously expensive.
|
We could avoid making a copy for every |
* Wrap the main and count queries in ListByOptions with a transaction (rancher#112) * Ensure that all db-related failures roll back the transaction. There's only one remaining instance in lasso of a function that takes an instance of `db.TXClient`, finds an error situation that doesn't happen due to a database call (`Exec` or `ExecStmt`), and doesn't rollback the transaction before returning a non-nil error. --------- Co-authored-by: Max Sokolovsky <max.sokolovsky@suse.com>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
* sql: silence informer errors on unwatchable resources Listable-but-unwatchable resources such as nodes metrics.k8s.io/v1beta1 allow an Informer to be started, but it will by default log all watch failures. Add a boolean flag to silence those errors. Signed-off-by: Silvio Moioli <silvio@moioli.net> * adapt tests Signed-off-by: Silvio Moioli <silvio@moioli.net> --------- Signed-off-by: Silvio Moioli <silvio@moioli.net>
* vai: log errors on add client-go unfortunately "swallows" them Signed-off-by: Silvio Moioli <silvio@moioli.net> * vai: log errors on delete Signed-off-by: Silvio Moioli <silvio@moioli.net> * Apply suggestions from code review Co-authored-by: Tom Lebreux <me@tomlebreux.com> * Update pkg/cache/sql/store/store.go Co-authored-by: Tom Lebreux <me@tomlebreux.com> --------- Signed-off-by: Silvio Moioli <silvio@moioli.net> Co-authored-by: Tom Lebreux <me@tomlebreux.com>
* Support searching by metadata.label fields: * Add labels when adding/replacing objects. * Add labels to the query language * Add a unit test for label tests. * Stick with terse in-place table alias names rather than interpolate descriptive named constants. Also: Move all the label operations from store to listoption_indexer. * Run go generate after refactoring label handling. * Move label handling out of store.go and into the listoption indexer. * Fix the number of args in the mocked calls to creating the indices tables. - tx.Exec takes only one argument. * Split 'ListOptionIndexer.afterUpsert' into two funcs with more descriptive names. * Split the 'afterX' methods into two parts, with better names. * Refactor the query-generator into its own method. * Split 'ListByOptions' into two functions to simplify testing. * Add tests for converting other ops to sql stmts, fixing breakage. * Add more tests, fix NOT-EXISTS for labels. * Code quality changes: - Fixed rendering NOT-EXISTS queries. - Wrap query error in a 'db.QueryError' object. - Use consistent error message when failing to get a unstructured object. - Don't include ORDER-BY clauses in COUNT queries. - Don't bother pulling the various fields out of the `queryInfo` struct - Pull the count queryInfo parts out only when needed. * Simplify the way the final queryInfo struct is built. In particular, don't clear the count query values if no count query needs to be made -- just leave the default struct values, and the query executor won't run a count-query. * No need to map nil to an empty array when there's no count query. * Process comparisons in the query strings. * Allow exist-tests on filters only on labels. * Fix the labels-not-exists (and not-equals) sql expressions. Conceptually it's simpler to do a '<key> NOT IN (SELECT o1.key...)' to find the rows that don't have the target label. * Use 'LEFT OUTER JOIN' on label tables only where necessary. For example, if the test is to find all rows where `metadata.labels.animal = "cows"`, we can ignore any rows that don't have associated labels, because they will never match. * LABEL <label> NOT IN (...) tests also succeed where the <label> isn't present. * Add unit tests on multiple filters with only positive-tests on labels. There are negative tests on non-label fields -- the goal here is to verify that we never do an OUTER JOIN when we don't need one. * Always LEFT-OUTER-JOIN when testing labels. * Two simplifications when querying on labels: - Always LEFT-OUTER-JOIN to retain fields that have no associated labels (for negative operators) - Always SELECT-DISTINCT in case some results return duplicate entries. And always SELECT DISTINCT when * Fix multiple filters involving label tests. When we have multiple filter sub-queries, these get ANDed together. But we need to do a self-join for each instance of a label-type filter. Added unit tests to verify that this is what we're generating.
…s. (rancher#122) * Replace primary/secondary sort fields with an array of sort directives. * Return an error if # sort-fields != # sort-orders * Rebase against main to pull in separated sql generator and matcher. * Add unit tests checking that sort-fields match up with sort-orders.
* Include release/0.1 branch in renovate Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com> * Add release GHA Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com> * Add Versioning Doc Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com> * Correct branch in renovate Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com> --------- Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
…ncher#134) Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
…20.5 (rancher#133) Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
622f79c to
87cab81
Compare
|
This needs to be redone against |
Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>
87cab81 to
60991a3
Compare
|
Does this really need 19 commits changing 49 files? And you also want to merge this against |
No description provided.