-
Notifications
You must be signed in to change notification settings - Fork 124
fix: panic with concurrent schema parsing #502
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
Conversation
b066d96 to
8151732
Compare
448ee72 to
c1dc105
Compare
c3a2bd3 to
68aaa7c
Compare
concurrent_parse_test.go
Outdated
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestConcurrentParse(t *testing.T) { |
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.
Please add this to schema_test.go. The naming separates it from what it is trying to test.
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.
I have moved the test, also I have moved the schema to a file, it still reproduces the issue.
Issue: #481
This pull request introduces a new test for concurrent schema parsing, adds a method to merge schema caches, and updates the schema parsing logic to utilize an internal cache. The most important changes are as follows:
Testing Enhancements:
concurrent_parse_test.go: Added a new testTestConcurrentParseto validate concurrent schema parsing by running multiple goroutines that parse a test schema. This ensures the thread-safety and correctness of the parsing function.Schema Cache Enhancements:
schema.go: Added a new methodAddAllto theSchemaCachestruct, which allows merging all schemas from one cache into another. This is useful for combining schema caches without duplicating entries.Schema Parsing Logic Enhancements:
schema_parse.go: Updated theParseBytesWithCachefunction to use an internalSchemaCachefor intermediate parsing steps. This change helps in isolating the parsing process and then merging the results back into the original cache, improving the modularity and maintainability of the code.