question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema registry HTTP error responses are cached

See original GitHub issue

We’ve recently been getting spates of tracebacks like the one below in an app of ours that uses Chr.Avro:

[("HResult": -2146233088), ("Message": "System.Net.Http.HttpRequestException: [https://schema-registry.***.com/] GatewayTimeout[https://schema-registry.***.com/] GatewayTimeout -1 
   at Confluent.SchemaRegistry.RestService.ExecuteOnOneInstanceAsync(Func`1 createRequest)
   at Confluent.SchemaRegistry.RestService.RequestAsync[T](String endPoint, HttpMethod method, Object[] jsonBody)
   at Confluent.SchemaRegistry.RestService.GetLatestSchemaAsync(String subject)
   at Confluent.SchemaRegistry.CachedSchemaRegistryClient.GetLatestSchemaAsync(String subject)
   at Chr.Avro.Confluent.AsyncSchemaRegistrySerializer`1.<SerializeAsync>b__24_0(String subject)
   at Chr.Avro.Confluent.AsyncSchemaRegistrySerializer`1.SerializeAsync(T data, SerializationContext context)
   at Confluent.Kafka.SyncOverAsync.SyncOverAsyncSerializer`1.Serialize(T data, SerializationContext context)
   at Confluent.Kafka.Producer`2.Produce(TopicPartition topicPartition, Message`2 message, Action`1 deliveryHandler)"), ...<snip>...
   at Confluent.SchemaRegistry.RestService.ExecuteOnOneInstanceAsync(Func`1 createRequest)
   at Confluent.SchemaRegistry.RestService.RequestAsync[T](String endPoint, HttpMethod method, Object[] jsonBody)
   at Confluent.SchemaRegistry.RestService.GetLatestSchemaAsync(String subject)
   at Confluent.SchemaRegistry.CachedSchemaRegistryClient.GetLatestSchemaAsync(String subject)
   at Chr.Avro.Confluent.AsyncSchemaRegistrySerializer`1.<SerializeAsync>b__24_0(String subject)
   at Chr.Avro.Confluent.AsyncSchemaRegistrySerializer`1.SerializeAsync(T data, SerializationContext context)
   at Confluent.Kafka.SyncOverAsync.SyncOverAsyncSerializer`1.Serialize(T data, SerializationContext context)
   at Confluent.Kafka.Producer`2.Produce(TopicPartition topicPartition, Message`2 message, Action`1 deliveryHandler)"), ("IsError": True), ("IsLocalError": True), ("IsBrokerError": False)]), ("Type": "Confluent.Kafka.ProduceException`2[[...<snip>...]]")]

After digging a bit, I think what is happening is that our application is–for reasons unrelated to this library or any C# code in general–receiving HTTP 504 responses in some of its initial attempts to contact the schema registry. When this happens, I think Chr.Avro caches this error result since here it is adding a single task to the cache, and after the initial add subsequent hits on the cache are awaiting that same task, leading to the HttpRequestException being raised on every access.

Of course, solving the 504s is a thing we should work on, but more specific to Chr.Avro: does it sound like I’m reading the code right, there? If so, would it make sense to try to come up with a way of skipping addition to the cache for HTTP 5xx response statuses?

Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
woodleecommented, Apr 9, 2020

Man, you are fast! Thank you so much for this.

1reaction
dstelljescommented, Apr 9, 2020

You’re right, Chr.Avro shouldn’t cache failed requests. I think we still want deduping (there shouldn’t be multiple in-flight requests for the same schema), but it looks like CachedSchemaRegistryClient will do that for us.

This and #77 are good candidates for a patch release; will try to make that happen yet this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SchemaRegistryClient cache not working, unnecessary ...
I am using Kafka to deserialize Avro messages. For that the programm should pull the corresponding Schema from the Schema registry. The ...
Read more >
Schema Registry API Reference
All API endpoints use a standard error message format for any requests that return an HTTP status indicating an error (any 400 or...
Read more >
Schema registry: Decrease payload for Kafka records
CachedSchemaRegistryClient is responsible to make HTTP call to schema registry and cache the response after getting schema id, which will be ...
Read more >
Schema Registry Configuration Options
This section contains Schema Registry configuration parameters organized by level ... response.http.headers.config="add Cache-Control: no-cache, no-store, ...
Read more >
HowTo: Produce Avro Messages to Kafka using Schema ...
Here, I will show you how to send avro messages from the client application and from Kafka Streams using Kafka Schema Registry.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found