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

Kafka ser/deser auto-detection bug during hot-reload #19931

Closed
FroMage opened this issue Sep 6, 2021 · 5 comments
Closed

Kafka ser/deser auto-detection bug during hot-reload #19931

FroMage opened this issue Sep 6, 2021 · 5 comments
Labels
area/kafka kind/bug Something isn't working

Comments

@FroMage
Copy link
Member

FroMage commented Sep 6, 2021

Describe the bug

There's a bug with hot-reload and https://quarkus.io/guides/kafka#serialization-autodetection

public class OrderSerializer extends ObjectMapperSerializer<Order> {
    public OrderSerializer() {
        super();
    }
}

How to Reproduce?

// Incorrectly a Deserialiser as pasted from the guide
public class OrderSerializer extends ObjectMapperDeserializer<Order> {
    public OrderSerializer() {
        super(Order.class);
    }
}
public class OrderSerializer extends ObjectMapperSerializer<Order> {
    public OrderSerializer() {
        super();
    }
}
@FroMage FroMage added kind/bug Something isn't working area/kafka labels Sep 6, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 6, 2021

/cc @cescoffier, @ozangunalp

@ozangunalp ozangunalp self-assigned this Sep 6, 2021
@Ladicek
Copy link
Contributor

Ladicek commented Sep 6, 2021

@ozangunalp just FYI, I'm looking at this, see the Zulip conversation :-)

@ozangunalp
Copy link
Contributor

@Ladicek Thanks for the heads up, I was going to ping you anyways

@FroMage FroMage changed the title Kafka ser/deser auto-detection doesn't appear to work for me Kafka ser/deser auto-detection bug during hot-reload Sep 6, 2021
@Ladicek
Copy link
Contributor

Ladicek commented Sep 8, 2021

So I was able to trace this down to what seems like a classloading issue, or maybe bootstrap issue, I don't really know.

What I do know is that during hot reload, the io.quarkus.runtime.generated.Config class, which -- among others -- defines the "runtime defaults" config source, is regenerated correctly. As in, the static initializer of the class correctly creates the HashMap with all the right config keys/values, and passes it to the PropertiesConfigSource constructor, together with the string "Specified default values".

However, even after hot reload, the PropertiesConfigSource (specifically the one that's named Specified default values) instance used during configuration lookup didn't change. It's the same instance as before hot reload.

I placed a breakpoint into QuarkusConfigFactory#setConfig and inspected the class of the parameter (SmallRyeConfig), as well as the class of the this object one stack frame up (which is always io.quarkus.runtime.generated.Config, because I'm ignoring the config stuff during augmentation). They always come from the same classloader: QuarkusClassLoader:Quarkus Base Runtime ClassLoader: DEV@63e02bfa.

To me, this means that even though the Config class is regenerated correctly, that regenerated version is never picked up. The base classloader is AFAIR one that is reused across restarts. It seems that io/quarkus/runtime/generated/Config.class is present in the resettableElement element of the classloader, and I can see QuarkusClassLoader#reset being called (and io/quarkus/runtime/generated/Config.class is present in the generatedResources map), but that doesn't seem to make a difference.

CC @stuartwdouglas, as this is clearly way above my paygrade 😆

@stuartwdouglas
Copy link
Member

This is a duplicate of #17069

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 9, 2021
Also makes sure datasources restart if devservices properties are
changed.

Fixes quarkusio#17069
Fixes quarkusio#19931
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 9, 2021
Also makes sure datasources restart if devservices properties are
changed.

Fixes quarkusio#17069
Fixes quarkusio#19931
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 9, 2021
Also makes sure datasources restart if devservices properties are
changed.

Fixes quarkusio#17069
Fixes quarkusio#19931
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 10, 2021
Also makes sure datasources restart if devservices properties are
changed.

Fixes quarkusio#17069
Fixes quarkusio#19931
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 10, 2021
Also makes sure datasources restart if devservices properties are
changed.

Fixes quarkusio#17069
Fixes quarkusio#19931
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kafka kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants