Skip to content

Conversation

@YousefHagag
Copy link
Contributor

@YousefHagag YousefHagag commented Feb 10, 2025

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 test TestConcurrentParse to 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 method AddAll to the SchemaCache struct, 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 the ParseBytesWithCache function to use an internal SchemaCache for 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.

@YousefHagag YousefHagag changed the title Fix panic with concurrent schema parsing fix: panic with concurrent schema parsing Feb 10, 2025
"github.com/stretchr/testify/require"
)

func TestConcurrentParse(t *testing.T) {
Copy link
Member

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.

Copy link
Contributor Author

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.

@nrwiersma nrwiersma merged commit b48c057 into hamba:main Feb 12, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants