fix: Update the Schema GetHashCode for Dictionary lookups #2390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
The
GetHashCode
for theSchema
data contract was updated in June with additional properties to accomodate the DataContract work. However, theCachedSchemaRegistryClient
is not able to retrieve items stored in its dictionary cache because of theReferences
addition and how List<>'s are handled.We saw severe slow down (around 15 seconds at times) registering a schema with 13 references (and their recursive references) because it was trying to query schemas that it already had in the Dictionary. When the changes proposed were made, the schemas that had been already retrieved were able to be pulled from the cache again (down to 1-2 seconds for large schemas, under a second for most).
Feel free to update as you wish but the code you need to ensure works is at
src/Confluent.SchemaRegistry/CachedSchemaRegistryClient.cs
The if statement above would never get a schemaId from the
idBySchema
lookup.Checklist
I don't see any unit tests surrounding this code anywhere or I would.
References
JIRA:
Test & Review
Serialize an object and debug the CachedSchemaRegistryClient to ensure that when a schema has been retrieved and/or registered it is able to be pulled from the dictionary.
Open questions / Follow-ups