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-18644: improve generic type names for internal FK-join classes #18700

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

mjsax
Copy link
Member

@mjsax mjsax commented Jan 24, 2025

Naming of generic types is not consistent, and hard to read. Standardizing to use KLeft/VLeft for the left/primary table, and KRight/VRight for right/foreign table, and using VOut as join result type.

@mjsax mjsax added the streams label Jan 24, 2025
@mjsax mjsax force-pushed the kafka-18644-dls-type-safely-fk-generics branch from 02ae4b0 to e7bb9fa Compare January 24, 2025 23:16
//from older SubscriptionWrapper versions to newer versions.
throw new UnsupportedVersionException("SubscriptionWrapper is of an incompatible version.");
}
final SubscriptionWrapper<KLeft> value = subscriptionWrapper(valueAndTimestamp);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactoring proposed by IntelliJ -- guess it make sense to extract into a helper method -- easier to read overall, as semantics are a little clearer.

@@ -50,17 +50,17 @@ public CombinedKeySchema(final Supplier<String> foreignKeySerdeTopicSupplier,
foreignKeySerializer = foreignKeySerde == null ? null : foreignKeySerde.serializer();
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "resource"})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppression some IntellIj warnings about "potential resource leaks" for not using try-with-resource for the "Closable" Serdes we get.

Similar elsewhere.

@mjsax
Copy link
Member Author

mjsax commented Jan 26, 2025

Java 17:

FAILED ❌ CooperativeConsumerCoordinatorTest > testOutdatedCoordinatorAssignment()
FAILED ❌ SharePartitionManagerTest > testReplicaManagerFetchShouldProceed()
FAILED ❌ SharePartitionManagerTest > testDelayedInitializationShouldCompleteFetchRequest()
FAILED ❌ RemoteIndexCacheTest > testIndexFileAlreadyExistOnDiskButNotInCache()
Found 3 flaky test failures:
FLAKY ⚠️  KafkaShareConsumerTest > testVerifyFetchAndAcknowledgeSync()
FLAKY ⚠️  AbstractCoordinatorTest > testWakeupAfterSyncGroupReceivedExternalCompletion()
FLAKY ⚠️  StickyAssignorTest > testLargeAssignmentAndGroupWithNonEqualSubscription(boolean).hasConsumerRack = false

Java 23:

Found 3 test failures:
FAILED ❌ SharePartitionManagerTest > testReplicaManagerFetchShouldProceed()
FAILED ❌ SharePartitionManagerTest > testDelayedInitializationShouldCompleteFetchRequest()
FAILED ❌ MetricsDuringTopicCreationDeletionTest > "testMetricsDuringTopicCreateDelete(String).quorum=kraft"
Found 1 flaky test failures:
FLAKY ⚠️  StickyAssignorTest > testLargeAssignmentAndGroupWithNonEqualSubscription(boolean).hasConsumerRack = false

Copy link
Member

@lucasbru lucasbru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one comment for your consideration.

public class CombinedKey<KF, KP> {
private final KF foreignKey;
private final KP primaryKey;
public class CombinedKey<KRight, KLeft> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that right is left and left is right. But not sure if I have a solution as we cannot swap them. How about standardizing on KForeign and KPrimary? That seemed rather clear to me, but I may be lacking context.

Copy link
Member Author

@mjsax mjsax Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order is on-purpose, because that is the actually order of both arguments of CombinedKey, ie, especially how we serialize it (but also constructor argument order; and the constructor argument order is also the way it is, to express the serialization order), what is important as we apply range-scans on RocksDB using the combined-key. I was also first thinking about maybe swapping it, but in the end, I did keep as is, because it might be better to align the order?

About the names. I did the change on-purpose, because the variable names, already have good names, it it IMHO make it's very clear?

    private final KRight foreignKey;
    private final KLeft primaryKey;

plus:

CombinedKey(final KRight foreignKey, final KLeft primaryKey) 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on keeping the order as it is serialized, that's why I said we shouldn't swap them. I think I have a slight preference for using KForeign and KPrimary, but I'm also fine with keeping KRight/KLeft. It's true that you can use the variable names to discern that.

@mjsax mjsax force-pushed the kafka-18644-dls-type-safely-fk-generics branch from e7bb9fa to 9bbe1ca Compare January 31, 2025 04:24
@mjsax
Copy link
Member Author

mjsax commented Jan 31, 2025

Java 17

Found 1 test failures:
FAILED ❌ CooperativeConsumerCoordinatorTest > testOutdatedCoordinatorAssignment()
Found 2 flaky test failures:
FLAKY ⚠️  AbstractCoordinatorTest > testWakeupAfterSyncGroupReceivedExternalCompletion()
FLAKY ⚠️  TransactionsWithTieredStoreTest > testFencingOnTransactionExpiration(String, String).quorum=kraft.groupProtocol=consumer

Java 23

Found 3 test failures:
FAILED ❌ ConfigCommandIntegrationTest > testUpdateInvalidBrokerConfigs [2] Type=Raft-Combined, MetadataVersion=4.0-IV3,BrokerSecurityProtocol=PLAINTEXT,BrokerListenerName=ListenerName(EXTERNAL),ControllerSecurityProtocol=PLAINTEXT,ControllerListenerName=ListenerName(CONTROLLER)
FAILED ❌ TransactionsTest > testFencingOnTransactionExpiration(String, String).quorum=kraft.groupProtocol=classic
FAILED ❌ ClientQuotasRequestTest > testClientQuotasWithDefaultName [1] Type=Raft-Isolated, MetadataVersion=4.0-IV3,BrokerSecurityProtocol=PLAINTEXT,BrokerListenerName=ListenerName(EXTERNAL),ControllerSecurityProtocol=PLAINTEXT,ControllerListenerName=ListenerName(CONTROLLER)
Found 1 flaky test failures:
FLAKY ⚠️  TransactionsWithTieredStoreTest > testFencingOnTransactionExpiration(String, String).quorum=kraft.groupProtocol=classic

@mjsax mjsax merged commit 7719b5f into apache:trunk Feb 4, 2025
7 of 9 checks passed
@mjsax mjsax deleted the kafka-18644-dls-type-safely-fk-generics branch February 4, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants