Skip to content
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: Remove shared mutable state between database instances #2777

Merged
merged 6 commits into from
Jun 26, 2024

Conversation

AndrewSisley
Copy link
Contributor

@AndrewSisley AndrewSisley commented Jun 25, 2024

Relevant issue(s)

Resolves #2774

Description

Removes shared mutable GQL state between database instances.

These global static GQL type variables are actually mutated by the GQL library we use at different points during database init, and schema update. This means that when multiple Defra instances are created in the same process they were sharing state. As well as just being an inherently bad thing, this also prevented us from running tests within packages in parallel using t.Parallel() as the race detector would complain.

Our integration tests now can all run with t.Parallel() and the --race flag (tested locally). I do not wish to make that change within this PR though for cleanliness/focus reasons. The --race flag is still flaky in the CI, this PR improves things but does not let us Parellize the tests fully. I believe that the shared state in https://github.com/graphql-go/graphql/blob/master/introspection.go is responsible for the remaining failures, I'd rather spend time moving away from the package entirely than to rework that, however I still think this PR represents an improvement and would like to merge.

@AndrewSisley AndrewSisley added bug Something isn't working area/query Related to the query component labels Jun 25, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.12 milestone Jun 25, 2024
@AndrewSisley AndrewSisley requested a review from a team June 25, 2024 21:05
@AndrewSisley AndrewSisley self-assigned this Jun 25, 2024
@AndrewSisley AndrewSisley changed the title fix: Remove shared mutable GQL state between database instances fix: Remove shared mutable state between database instances Jun 25, 2024
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.58%. Comparing base (5855969) to head (7b55fb8).

Current head 7b55fb8 differs from pull request most recent head 92aa500

Please upload reports for the commit 92aa500 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2777      +/-   ##
===========================================
+ Coverage    78.19%   78.58%   +0.40%     
===========================================
  Files          313      315       +2     
  Lines        23116    23810     +694     
===========================================
+ Hits         18074    18711     +637     
- Misses        3667     3719      +52     
- Partials      1375     1380       +5     
Flag Coverage Δ
all-tests 78.58% <100.00%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
internal/request/graphql/schema/collection.go 90.33% <100.00%> (ø)
internal/request/graphql/schema/generate.go 87.45% <100.00%> (+0.02%) ⬆️
internal/request/graphql/schema/manager.go 98.13% <100.00%> (+0.30%) ⬆️
internal/request/graphql/schema/types/base.go 100.00% <100.00%> (ø)
internal/request/graphql/schema/types/commits.go 100.00% <100.00%> (ø)
internal/request/graphql/schema/types/scalars.go 100.00% <100.00%> (ø)
internal/request/graphql/schema/types/types.go 100.00% <100.00%> (ø)

... and 21 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5855969...92aa500. Read the comment docs.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndrewSisley AndrewSisley merged commit c6c2373 into sourcenetwork:develop Jun 26, 2024
77 of 80 checks passed
@AndrewSisley AndrewSisley deleted the 2774-gql-concurrency branch June 26, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GQL types declared in request/graphql/schema/types pkg are mutatable and shared between defra instances
2 participants