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

KEFCore fails some tests in net8.0 and JDK 21 #510

Closed
masesdevelopers opened this issue Jun 25, 2024 · 4 comments · Fixed by #511 or #514
Closed

KEFCore fails some tests in net8.0 and JDK 21 #510

masesdevelopers opened this issue Jun 25, 2024 · 4 comments · Fixed by #511 or #514
Assignees
Labels
bug Something isn't working KNet KNet related issue

Comments

@masesdevelopers
Copy link
Contributor

masesdevelopers commented Jun 25, 2024

Within https://github.com/masesgroup/KEFCore/actions/runs/9655461268 many tests fails. Here the summary:

  • .NET: net8.0
  • OS
    • Windows
      • JDK: Corretto 21
    • Linux
      • Oracle 21
      • Zulu 21
      • Temurin 21
      • Microsoft 21
    • MacOS 13 and MacOS 14 (macos-latest)
      • Corretto 21
      • Microsoft 21
      • Temurin 21
      • Oracle 21
      • Zulu 21

The errors occurs always in net8.0, and sparsely for many JDK 21, when the array of bytes of key related to the Kafka record is retrieved from the JVM.
However the problem is raised in many way within KNet code, so the issue shall be solved there.

Originally posted by @masesdevelopers in masesgroup/KEFCore#243 (comment)

@masesdevelopers
Copy link
Contributor Author

#480 is still open, maybe specific tests will be added there

@masesdevelopers masesdevelopers self-assigned this Jun 25, 2024
@masesdevelopers masesdevelopers added bug Something isn't working KNet KNet related issue labels Jun 25, 2024
@masesdevelopers
Copy link
Contributor Author

Check this comment for some issues found

@masesdevelopers
Copy link
Contributor Author

Tests still have some issues reported in https://github.com/masesgroup/KEFCore/actions/runs/9703496875; some of them can be mitigated with masesgroup/KEFCore#243 (comment) since the broker/zookeeper fails in windows, however someone else seems specific to JDK 21 and especially regards memory management: e.g. Arithmetic overflow reported on byte array saved in previous steps, so something happens when memory is read, or wrote.

masesdevelopers added a commit to masesdevelopers/EntityFramework4Kafka that referenced this issue Jul 2, 2024
@masesdevelopers
Copy link
Contributor Author

Tests still have some issues reported in https://github.com/masesgroup/KEFCore/actions/runs/9703496875; some of them can be mitigated with masesgroup/KEFCore#243 (comment) since the broker/zookeeper fails in windows, however someone else seems specific to JDK 21 and especially regards memory management: e.g. Arithmetic overflow reported on byte array saved in previous steps, so something happens when memory is read, or wrote.

Finally seems the issue was identified and it is related to the access of information stored in the final fields (key, value) of org.apache.kafka.streams.KeyValue<K, V>, however it is not clear at all the reason why the, in JDK 21, the access to the memory creates so many issues: sometime the length read is negative (and indeed .NET reports Arithmetic overflow), sometime is very high creating an access violation since the code tries to access an inaccessible memory, sometime the length is too short, sometime the memory accessed during the copy is not the one of the expected array.

The solution identified is to create a new class, named org.mases.knet.developed.streams.KeyValueSupport<K, V>, which accept in input an instance of org.apache.kafka.streams.KeyValue<K, V> and give access to the key and value fields with methods:

public class KeyValueSupport<K, V> {
    org.apache.kafka.streams.KeyValue<K, V> _innerKV;

    public static <K, V> org.apache.kafka.streams.KeyValue<K, V> toKeyValue(KeyValueSupport<K, V> kvs) {
        return new org.apache.kafka.streams.KeyValue<K, V>(kvs.getKey(), kvs.getValue());
    }

    public KeyValueSupport(org.apache.kafka.streams.KeyValue<K, V> innerKV) {
        _innerKV = innerKV;
    }

    public K getKey() {
        return _innerKV.key;
    }

    public V getValue() {
        return _innerKV.value;
    }
}

Using this approach seems that the memory is accessed in the right way and the tests done locally does not report the issues described before.
Probably a better approach is to create a new class which implements org.apache.kafka.streams.state.KeyValueIterator and iterates managing org.mases.knet.developed.streams.KeyValueSupport<K, V>, till now leave this approach as a new option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working KNet KNet related issue
Projects
None yet
1 participant