-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: Start listening after schema cache load #4880
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -156,6 +156,9 @@ maxDbTablesForFuzzySearch = 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| querySchemaCache :: AppConfig -> SQL.Transaction (SchemaCache, Maybe QueryTimings) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| querySchemaCache conf@AppConfig{..} = do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SQL.sql "set local schema ''" -- This voids the search path. The following queries need this for getting the fully qualified name(schema.name) of every db object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ <- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let sleepCall = SQL.Statement "select pg_sleep($1 / 1000.0)" (param HE.int4) HD.noResult True in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for_ configInternalSCQuerySleep (`SQL.statement` sleepCall) -- only used for testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tabs <- sqlTimedStmt gucTbls conf allTables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keyDeps <- sqlTimedStmt gucKDeps conf allViewsKeyDependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| m2oRels <- sqlTimedStmt gucRels mempty allM2OandO2ORels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -166,9 +169,6 @@ querySchemaCache conf@AppConfig{..} = do | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tzones <- if configDbTimezoneEnabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then sqlTimedStmt gucTzones mempty timezones | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else pure S.empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ <- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let sleepCall = SQL.Statement "select pg_sleep($1 / 1000.0)" (param HE.int4) HD.noResult True in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for_ configInternalSCQuerySleep (`SQL.statement` sleepCall) -- only used for testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
159
to
-171
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this moved here? Change looks like it should be done independently. I remember we had some tests relying on the fact this sleep was after all the schema cache queries.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is needed - otherwise
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I remember some tests depend on this sleep being last, so if we change it those tests would be ineffective and misleading. We should do a git blame for finding those tests and tune them (or remove) if necessary. Or as an alternative, introduce another sleep before the schema cache queries and leave this one in place.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I've searched through the tests for usage of this variable and cannot see anything that would require it after queries. It would only be relevant for tests that don't want to wait in case of errors in queries - but we don't have such tests, I think.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Now, the original test was modified on 92ac7e5. This leaves us with this current test: Lines 1336 to 1367 in ed0d9dc
Which IIRC it's kind of tricky because it involves concurrent notifications. @mkleczek Can you ensure this test is still effective? I would also be fine if it's modified to not depend on this sleep if possible (if done should be another PR).
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would like to understand how it is possible. The signature of schema loading function where sleep happens is: So it is an atomic transaction returning schema cache or error. There is no way for any interim state to be observable. So there is no way the order of operations would matter for any code outside of this transaction. I wouldn't introduce any other complexity without first understanding throughly the need for it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mkleczek Mind you that #2810 was before debouncing was introduced. We want to prove the test on 4bcb2d7#diff-d0a535c2686bd7fcd98f5fa5baca2b9dc84e59c6a2c0f350a0728ebd3e2017a7R949-R986 fails. Sleeping at the end:
Sleeping before:
Did my best to refresh my memory and explain, hopefully that will do. If this is not sufficient I'd suggest doing a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh... got it. I would say we need to think about some totally different way to test it. The problem with the approach we have today is that what we really are testing is PostgreSQL transaction isolation: The only proper way to test that no notifications are lost is to verify that two schema reloads happened. Checking final schema cache state is not enough I'm afraid.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct, what I did on #2810 was the minimal sufficient to prove the failure and fix.
We could add the Any other ideas?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something along the lines of: #4962 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qsTime <- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if isLogDebug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.