EventStore / EventStoreDB-Client-Java

Official Asynchronous Java 8+ Client Library for EventStoreDB 20.6+
https://eventstore.com
Apache License 2.0
61 stars 19 forks source link

5.3.1 not working #267

Closed rickardoberg closed 4 months ago

rickardoberg commented 4 months ago

For some reason the 5.3.1 release doesn't work. Example code:

WriteResult result = client.appendToStream("stream1",
        EventData.builderAsJson(UUID.randomUUID(), "someEventType", mapper.writeValueAsBytes(new EventRecord(1, "foobar"))).build(),
        EventData.builderAsJson(UUID.randomUUID(),"someEventType", mapper.writeValueAsBytes(new EventRecord(2, "foobar"))).build(),
        EventData.builderAsJson(UUID.randomUUID(),"someEventType", mapper.writeValueAsBytes(new EventRecord(3, "foobar"))).build()
).orTimeout(10, TimeUnit.SECONDS).join();

This works great with 5.3.0 and hangs with 5.3.1. I tried downgrading to GRPC 1.59.0, same result. The semver fix that was in 5.3.1 seems ok too. So the only remaining change in 5.3.1 that might cause issues is the change of protoc version.

josephcummings commented 4 months ago

Thanks for raising this @rickardoberg

We will look into this ASAP.

May I ask what platform you are running on, by any chance are you running on ARM?

rickardoberg commented 4 months ago

Windows laptop, so no Apple.

YoEight commented 4 months ago

Hey @rickardoberg and thanks for reporting your issue.

Could you provide more information on your environment please? I ran your example as-is locally and it just works.

My setup is:

OS: Fedora 39 (Kernel 6.7.6) Arch: x86_64 Java: OpenJDK 11.0.22 2024-01-16 EventStoreDB: 23.10.1

YoEight commented 4 months ago

I tried to run your code snippet on Windows 11 and still got it to work.

OS: Windows 11 (23H2) Build 22631.3155 Arch: x86_64 Java: OpenJDK 11.0.22 2024-01-16 LTS (Microsoft OpenJDK build) EventStoreDB: 23.10.1

Note that on both cases (Linux and Windows), I started the server with those parameters:

 --insecure --enable-atom-pub-over-http

Also my connection string was esdb://localhost:2113?tls=false

Don't hesitate giving us as much information as possible so we can help you figuring out the situation.

rickardoberg commented 4 months ago

@YoEight thanks for investigating! Ok, this one is fascinating then. I have created a minimal project to illustrate the issue. eventstoretest.zip

OS: Windows 11 (23H2) Build 22631.3155 Arch: x86_64 Java: OpenJDK 11.0.22 2024-03-04 LTS (Microsoft OpenJDK build) EventStoreDB: 23.10.0-bookworm-slim Docker container (tested with 23.10.1-bookworm-slim as well, same result)

If I run that with 5.3.0 it passes, if I only change client version to 5.3.1 it fails.

YoEight commented 4 months ago

Thanks @rickardoberg for providing your project. I was able to reproduce your behavior and I would like you to add this in your pom.xml and tell me if it's working after the change.

       <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.25.3</version>
        </dependency>

Thank you for your patience.

rickardoberg commented 4 months ago

I can confirm that this is the only change needed to make it work. With the default 3.25.1 it hangs on 5.3.1, and with 3.25.3 it works.

YoEight commented 4 months ago

@rickardoberg I'm glad it's working.

We are using Gradle to build the client. For some reason, Gradle does something that Maven isn't doing.

The culprit is the generated gRPC code emits the com.google.protobuf.MapFieldReflectionAccessor type, which doesn't exist in the protobuf-java version (3.24.4) that the client uses. When calling the appendStream function it will load a gRPC class that has a com.google.protobuf.MapFieldReflectionAccessor field, throwing a ClassNotFoundException.

Because that exception happens in a different thread (the one running the client core logic), from the user perceptive, the client isn't making any progress (its main thread crashed after all!)

Thanks again for reporting this issue. A patch will be out as soon as possible.

josephcummings commented 4 months ago

Hi @rickardoberg

We have released a patch on v5.3.2 to address the bug.

I upgraded in your reproducible example and the test passes, please let us know if you see otherwise.

Thanks again for reporting this!