Commit Graph

4776 Commits

Author SHA1 Message Date
Luke Chen d23931d5b6 Merge remote-tracking branch 'origin' into testRemoteLogManagerRemoteMetrics 2024-05-10 11:17:34 +08:00
Luke Chen bd53f8e430 test 2024-05-10 11:13:11 +08:00
Kuan-Po (Cooper) Tseng 7e9ab4b2c6
KAFKA-16484 Support to define per broker/controller property by ClusterConfigProperty (#15715)
Introduce a new field id in annotation ClusterConfigProperty. The main purpose of new field is to define specific broker/controller(kraft) property. And the default value is -1 which means the ClusterConfigProperty will apply to all broker/controller.

Note that under Type.KRAFT mode, the controller id starts from 3000, and then increments by one each time. Other modes the broker/controller id starts from 0 and then increments by one.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-10 10:31:45 +08:00
Luke Chen 95476aaa70 test 2024-05-09 14:24:04 +08:00
Luke Chen 3ecdc109f8 test 2024-05-09 14:23:04 +08:00
Luke Chen ab2cf377f5 add more logs 2024-05-09 14:06:35 +08:00
Luke Chen f29484b517 Merge remote-tracking branch 'origin' into testRemoteLogManagerRemoteMetrics 2024-05-09 08:46:06 +08:00
Luke Chen 15020758f0 test 2024-05-09 08:42:54 +08:00
Luke Chen 8adfc6be42 remove integration 2024-05-09 08:35:40 +08:00
Luke Chen a0ee103041 test 2024-05-09 08:27:37 +08:00
Sanskar Jhajharia c64a315fd5
MINOR: Made the supportedOperation variable name more verbose (#15892)
As a part of 2e8d69b78c, we had introduced the TransactionAbortableException in AK. On more detailed analysis we figured out that the enum SupportedOperation was a bit misleading. Hence updated the same to TransactionSupportedOperation to allow a better and more defined function signature

Reviewers: Justine Olshan <jolshan@confluent.io>
2024-05-08 10:14:12 -07:00
Jorge Esteban Quilcate Otoya 2a5efe4a33
KAFKA-16685: Add parent exception to RLMTask warning logs (#15880)
KAFKA-16685: Add parent exception to RLMTask warning logs

Reviewers: Josep Prat <josep.prat@aiven.io>
2024-05-08 14:27:03 +02:00
Luke Chen 244103af95 teset 2024-05-08 20:24:25 +08:00
TingIāu "Ting" Kì f74f596bc7
KAFKA-16640 Replace TestUtils#resource by scala.util.Using (#15881)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-08 15:56:27 +08:00
Kamal Chandraprakash 8655094e6c
KAFKA-16511: Fix the leaking tiered segments during segment deletion (#15817)
When there are overlapping segments in the remote storage, then the deletion may fail to remove the segments due to isRemoteSegmentWithinLeaderEpochs check. Once the deletion starts to fail for a partition, then segments won't be eligible for cleanup. The one workaround that we have is to move the log-start-offset using the kafka-delete-records script.

Reviewers: Luke Chen <showuon@gmail.com>, Satish Duggana <satishd@apache.org>
2024-05-08 15:21:23 +08:00
Luke Chen f9991935e3 test 2024-05-08 13:15:49 +08:00
Luke Chen 3dab6159e8 test 2024-05-08 13:06:53 +08:00
TingIāu "Ting" Kì a0f1658bb1
KAFKA-16678 Remove variable "unimplementedquorum" (#15879)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-08 12:30:34 +08:00
Luke Chen 3c25e02524 test 2024-05-08 08:05:34 +08:00
Luke Chen f4a38eb5c9 KAFKA-16399: address review comments and fix flaky tests 2024-05-07 18:00:06 +08:00
Lianet Magrans ea485a7061
KAFKA-16665: Allow to initialize newly assigned partition's positions without allowing fetching while callback runs (#15856)
Fix to allow to initialize positions for newly assigned partitions, while the onPartitionsAssigned callback is running, even though the partitions remain non-fetchable until the callback completes.

Before this PR, we were not allowing initialization or fetching while the callback was running. The fix here only allows to initialize the newly assigned partition position, and keeps the existing logic for making sure that the partition remains non-fetchable until the callback completes.

The need for this fix came out in one of the connect system tests, that attempts to retrieve a newly assigned partition position with a call to consumer.position from within the onPartitionsAssigned callback (WorkerSinkTask). With this PR, we allow to make such calls (test added), which is the behaviour of the legacy consumer.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2024-05-07 10:40:00 +02:00
Dongnuo Lyu 459eaec666
KAFKA-16615; JoinGroup API for upgrading ConsumerGroup (#15798)
The patch implements JoinGroup API for the new consumer groups. It allow members using the classic rebalance protocol with the consumer embedded protocol to join a new consumer group.

Reviewers: David Jacot <djacot@confluent.io>
2024-05-06 23:59:10 -07:00
TingIāu "Ting" Kì 0de3b7c40b
KAFKA-16593 Rewrite DeleteConsumerGroupsTest by ClusterTestExtensions (#15766)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-07 14:04:32 +08:00
David Jacot 0df340d64d
KAFKA-16470 kafka-dump-log --offsets-decoder should support new records (#15652)
When the consumer group protocol is used in a cluster, it is, at the moment, impossible to see all records stored in the __consumer_offsets topic with kafka-dump-log --offsets-decoder. It does not know how to handle all the new records.

This patch refactors the OffsetsMessageParser used internally by kafka-dump-log to use the RecordSerde used by the new group coordinator. It ensures that the tool is always in sync with the coordinator implementation. The patch also changes the format to using the toString'ed representations of the records instead of having custom logic to dump them. It ensures that all the information is always dumped. The downside of the latest is that inner byte arrays (e.g. assignment in the classic protocol) are no longer deserialized. Personally, I feel like that it is acceptable and it is actually better to stay as close as possible to the actual records in this tool. It also avoids issues like https://issues.apache.org/jira/browse/KAFKA-15603.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-07 08:49:31 +08:00
David Arthur fe8ccbc92c
KAFKA-16539 Fix IncrementalAlterConfigs during ZK migration (#15744)
This patch fixes two issues with IncrementalAlterConfigs and the ZK migration. First, it changes the handling of IncrementalAlterConfigs to check if the controller is ZK vs KRaft and only forward for KRaft. Second, it adds a check in KafkaZkClient#setOrCreateEntityConfigs to ensure a ZK broker is not directly modifying configs in ZK if there is a KRaft controller. This closes the race condition between KRaft taking over as the active controller and the ZK brokers learning about this.

*Forwarding*

During the ZK migration, there is a time when the ZK brokers are running with migrations enabled, but KRaft has yet to take over as the controller. Prior to KRaft taking over as the controller, the ZK brokers in migration mode were unconditionally forwarding IncrementalAlterConfigs (IAC) to the ZK controller. This works for some config types, but breaks when setting BROKER and BROKER_LOGGER configs for a specific broker. The behavior in KafkaApis for IAC was to always forward if the forwarding manager was defined. Since ZK brokers in migration mode have forwarding enabled, the forwarding would happen, and the special logic for BROKER and BROKER_LOGGER would be missed, causing the request to fail.

With this fix, the IAC handler will check if the controller is KRaft or ZK and only forward for KRaft.

*Protected ZK Writes*

As part of KIP-500, we moved most (but not all) ZK mutations to the ZK controller. One of the things we did not move fully to the controller was entity configs. This is because there was some special logic that needed to run on the broker for certain config updates. If a broker-specific config was set, AdminClient would route the request to the proper broker. In KRaft, we have a different mechanism for handling broker-specific config updates.

Leaving this ZK update on the broker side would be okay if we were guarding writes on the controller epoch, but it turns out KafkaZkClient#setOrCreateEntityConfigs does unprotected "last writer wins" updates to ZK. This means a ZK broker could update the contents of ZK after the metadata had been migrated to KRaft. No good! To fix this, this patch adds a check on the controller epoch to KafkaZkClient#setOrCreateEntityConfigs but also adds logic to fail the update if the controller is a KRaft controller.

The new logic in setOrCreateEntityConfigs adds STALE_CONTROLLER_EPOCH as a new exception that can be thrown while updating configs.

Reviewers:  Luke Chen <showuon@gmail.com>, Akhilesh Chaganti <akhileshchg@users.noreply.github.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-07 08:29:57 +08:00
Nikolay 6a8977e212
KAFKA-14588 [3/N] ConfigCommandTest rewritten in java (#15850)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-06 18:44:34 +08:00
Chia Chuan Yu 55a00be4e9
MINOR: Replaced Utils.join() with JDK API. (#15823)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-06 15:13:01 +08:00
PoAn Yang 970ac07881
KAFKA-16659 KafkaConsumer#position() does not respect wakup when group protocol is CONSUMER (#15853)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-06 08:45:11 +08:00
Johnny Hsu 25118cec14
MINOR: remove redundant check in KafkaClusterTestKit (#15858)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-05 11:47:40 +08:00
José Armando García Sancio bfe81d6229
KAFKA-16207; KRaft's internal log listener to update voter set (#15671)
Adds support for the KafkaRaftClient to read the control records KRaftVersionRecord and VotersRecord in the snapshot and log. As the control records in the KRaft partition are read, the replica's known set of voters are updated. This change also contains the necessary changes to include the control records when a snapshot is generated by the KRaft state machine.

It is important to note that this commit changes the code and the in-memory state to track the sets of voters but it doesn't change any data that is externally exposed. It doesn't change the RPCs, data stored on disk or configuration.

When the KRaft replica starts the PartitionListener reads the latest snapshot and then log segments up to the LEO, updating the in-memory state as it reads KRaftVersionRecord and VotersRecord. When the replica (leader and follower) appends to the log, the PartitionListener catches up to the new LEO. When the replica truncates the log because of a diverging epoch, the PartitionListener also truncates the in-memory state to the new LEO. When the state machine generate a new snapshot the PartitionListener trims any prefix entries that are not needed. This is all done to minimize the amount of data tracked in-memory and to make sure that it matches the state on disk.

To implement the functionality described above this commit also makes the following changes:

Adds control records for KRaftVersionRecord and VotersRecord. KRaftVersionRecord describes the finalized kraft.version supported by all of the replicas. VotersRecords describes the set of voters at a specific offset.

Changes Kafka's feature version to support 0 as the smallest valid value. This is needed because the default value for kraft.version is 0.

Refactors FileRawSnapshotWriter so that it doesn't directly call the onSnapshotFrozen callback. It adds NotifyingRawSnapshotWriter for calling such callbacks. This reorganization is needed because in this change both the KafkaMetadataLog and the KafkaRaftClient need to react to snapshots getting frozen.

Cleans up KafkaRaftClient's initialization. Removes initialize from RaftClient - this is an implementation detail that doesn't need to be exposed in the interface. Removes RaftConfig.AddressSpec and simplifies the bootstrapping of the static voter's address. The bootstrapping of the address is delayed because of tests. We should be able to simplify this further in future commits.

Update the DumpLogSegment CLI to support the new control records KRaftVersionRecord and VotersRecord.

Fix the RecordsSnapshotReader implementations so that the iterator includes control records. RecordsIterator is extended to support reading the new control records.
Improve the BatchAccumulator implementation to allow multiple control records in one control batch. This is needed so that KRaft can make sure that VotersRecord is included in the same batch as the control record (KRaftVersionRecord) that upgrades the kraft.version to 1.

Add a History interface and default implementation TreeMapHistory. This is used to track all of the sets of voters between the latest snapshot and the LEO. This is needed so that KafkaRaftClient can query for the latest set of voters and so that KafkaRaftClient can include the correct set of voters when the state machine generates a new snapshot at a given offset.

Add a builder pattern for RecordsSnapshotWriter. The new builder pattern also implements including the KRaftVersionRecord and VotersRecord control records in the snapshot as necessary. A KRaftVersionRecord should be appended if the kraft.version is greater than 0 at the snapshot's offset. Similarly, a VotersRecord should be appended to the snapshot with the latest value up to the snapshot's offset.

Reviewers: Jason Gustafson <jason@confluent.io>
2024-05-04 12:43:16 -07:00
Luke Chen 16e21bda67 KAFKA-16399: fix broken tests 2024-05-04 16:37:26 +08:00
Kirk True 9b8aac22ec
KAFKA-16427 KafkaConsumer#position() does not respect timeout when group protocol is CONSUMER (#15843)
The AsyncKafkaConsumer implementation of position(TopicPartition, Duration) was not updating its internal Timer, causing it to execute the loop forever. Adding a call to update the Timer at the bottom of the loop fixes the issue.

An integration test was added to catch this case; it fails without the newly added call to Timer.update(long).

Reviewers: Lianet Magrans <lianetmr@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-04 10:29:27 +08:00
Alyssa Huang 1fd39150aa
KAFKA-16655: Deflake ZKMigrationIntegrationTest.testDualWrite #15845
Reviewers: Colin P. McCabe <cmccabe@apache.org>, Johnny Hsu <44309740+johnnychhsu@users.noreply.github.com>
2024-05-03 10:44:37 -07:00
Luke Chen 1c8d40e8ed KAFKA-16399: remove unused import 2024-05-03 14:42:23 +08:00
PoAn Yang 87390f961f
KAFKA-16572 allow defining number of disks per broker in ClusterTest (#15745)
Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-03 14:24:59 +08:00
Luke Chen ae3442f848 KAFKA-16399: update javadoc 2024-05-02 18:54:33 +08:00
Luke Chen 97e2b47c68 KAFKA-16399: address reviewer's comments 2024-05-02 17:44:55 +08:00
Nikolay cdc4caa578
KAFKA-14588 UserScramCredentialsCommandTest rewritten in Java (#15832)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Igor Soarez <soarez@apple.com>
2024-05-02 10:35:10 +01:00
Luke Chen 309c3a3dc8 Merge remote-tracking branch 'origin' into KAFKA-16399 2024-05-02 14:45:29 +08:00
Kuan-Po (Cooper) Tseng 89d8045a15
KAFKA-16647 Remove setMetadataDirectory from BrokerNode/ControllerNode (#15833)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-02 09:04:15 +08:00
TaiJuWu d9c36299db
KAFKA-16614 Disallow @ClusterTemplate("") (#15800)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-02 07:15:22 +08:00
PoAn Yang 4825c89d14
KAFKA-16588 broker shutdown hangs when log.segment.delete.delay.ms is zero (#15773)
Instead of entering pending forever, this PR invoke next schedule after 1ms. However, the side effect is busy-waiting. Hence, This PR also update the docs to remind users about that - the issue about smaller log.segment.delete.delay.ms

Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-01 17:11:20 +08:00
Ken Huang da5f4424dc
MINOR: Clean up TestUtils.scala (#15808)
This PR do the following cleanup for TestUtils.scala

1) remove unused methods
2) move methods used by single test class out of

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-01 04:13:29 +08:00
Luke Chen e2a23fa885 Merge remote-tracking branch 'origin' into KAFKA-16399 2024-04-30 10:46:25 +08:00
Kuan-Po (Cooper) Tseng 6d436a8f98
KAFKA-16627 Remove ClusterConfig parameter in BeforeEach and AfterEach (#15824)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-30 08:40:28 +08:00
Johnny Hsu 78c7f08e20
MINOR: Reuse KafkaConfig to create MetadataLogConfig (#15788)
Reviewers: Omnia Ibrahim <o.g.h.ibrahim@gmail.com>, Kuan-Po (Cooper) Tseng <brandboat@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-30 08:04:16 +08:00
Johnny Hsu 150a78ab90
KAFKA-15897 fix kafka.server.ControllerRegistrationManagerTest#testWrongIncarnationId (#15828)
ControllerRegistrationManagerTest is flaky due to the poll in L221. The potential root cause is a race condition between the first poll (L221) and the second poll (L229). Before the second poll, we mock a response (L226), which should be processed by the second poll. However, if the first poll take this away, the second poll would get nothing, and this could lead to an error.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-30 07:55:12 +08:00
Nikolay 81c24d6bf8
KAFKA-15588 ConfigCommandIntegrationTest rewritten in java (#15645)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-30 01:46:08 +08:00
Omnia Ibrahim e1bfaec49d
KAFKA-15853 Move metrics configs out of KafkaConfig (#15822)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-30 01:19:05 +08:00
Kuan-Po (Cooper) Tseng 5de5d967ad
KAFKA-16560 Refactor/cleanup BrokerNode/ControllerNode/ClusterConfig (#15761)
* Make ClusterConfig immutable
* Make BrokerNode immutable
* Refactor out build argument in ControllerNode
* Add setPrefix and replace put property with set map in ClusterConfig
* Remove rollingBrokerRestart from ClusterInstance interface
* Refactor KRaftClusterTest#doOnStartedKafkaCluster

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-28 02:00:56 +08:00