Commit Graph

4818 Commits

Author SHA1 Message Date
Mickael Maison 22f5113dba
KAFKA-15723 KRaft support in ListOffsetsRequestTest (#15980)
Co-authored-by: Zihao Lin <104664078@163.com>

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-18 03:54:18 +08:00
Ken Huang 7fea279ff9
KAFKA-16763 Upgrade to scala 2.12.19 and scala 2.13.14 (#15958)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-18 00:36:38 +08:00
José Armando García Sancio 056d232f4e
KAFKA-16526; Quorum state data version 1 (#15859)
Allow KRaft replicas to read and write version 0 and 1 of the quorum-state file. Which version is written is controlled by the kraft.version. With kraft.version 0, version 0 of the quorum-state file is written. With kraft.version 1, version 1 of the quorum-state file is written. Version 1 of the quorum-state file adds the VotedDirectoryId field and removes the CurrentVoters. The other fields removed in version 1 are not important as they were not overwritten or used by KRaft.

In kraft.version 1 the set of voters will be stored in the kraft partition log segments and snapshots.

To implement this feature the following changes were made to KRaft.

FileBasedStateStore was renamed to FileQuorumStateStore to better match the name of the implemented interface QuorumStateStore.

The QuorumStateStore::writeElectionState was extended to include the kraft.version. This version is used to determine which version of QuorumStateData to store. When writing version 0 the VotedDirectoryId is not persisted but the latest value is kept in-memory. This allows the replica to vote consistently while they stay online. If a replica restarts in the middle of an election it will forget the VotedDirectoryId if the kraft.version is 0. This should be rare in practice and should only happen if there is an election and failure while the system is upgrading to kraft.version 1.

The type ElectionState, the interface EpochState and all of the implementations of EpochState (VotedState, UnattachedState, FollowerState, ResignedState, CandidateState and LeaderState) are extended to support the new voted directory id.

The type QuorumState is changed so that local directory id is used. The type is also changed so that the latest value for the set of voters and the kraft version is query from the KRaftControlRecordStateMachine.

The replica directory id is read from the meta.properties and passed to the KafkaRaftClient. The replica directory id is guaranteed to be set in the local replica.

Adds a new metric for current-vote-directory-id which exposes the latest in-memory value of the voted directory id.

Renames VoterSet.VoterKey to ReplicaKey.

It is important to note that after this change, version 1 of the quorum-state file will not be written by kraft controllers and brokers. This change adds support reading and writing version 1 of the file in preparation for future changes.

Reviewers: Jun Rao <junrao@apache.org>
2024-05-16 09:53:36 -04:00
Chia-Ping Tsai 2c51594607
MINOR: rewrite TopicBasedRemoteLogMetadataManagerTest by ClusterTestExtensions (#15917)
Reviewers: Kamal Chandraprakash <kamal.chandraprakash@gmail.com>, Luke Chen <showuon@gmail.com>
2024-05-16 21:26:08 +08:00
Nikolay 7b1fe33d01
KAFKA-14588 [3/N] ConfigCommandTest rewritten in java (#15930)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-16 18:06:59 +08:00
Johnny Hsu dac569b967
KAFKA-16668 Add tags support in ClusterTestExtension (#15861)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-16 18:02:13 +08:00
Mickael Maison 5da4b238d6
MINOR: Remove unused method in ToolsUtils (#15967)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-16 15:40:50 +08:00
Chia-Ping Tsai aca5d249d6
MINOR: revisit LogValidatorTest#checkRecompression (#15948)
Reviewers: Jun Rao <junrao@apache.org>
2024-05-16 02:26:43 +08:00
Lucas Brutschy c218c4e1b5
KAFKA-16287: Implement example tests for common rebalance callback (#15408)
We need to add an example test to the PlaintextConsumerTest that tests a common
ConsumerRebalanceListener use case. For example, create an integration test that
invokes the Consumer API to commit offsets in the onPartitionsRevoked callback.

This test is implemented in a reasonably general way with a view to using it as a
template from which other tests can be created later. Eventually we will need to
have a comprehensive set of tests that cover all the basic use cases.

Reviewers: Lianet Magrans <lianetmr@gmail.com>, Bruno Cadonna <cadonna@apache.org>
2024-05-15 11:12:21 +02:00
David Jacot bf88013a28
MINOR: Rename `Record` to `CoordinatorRecord` (#15949)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-15 13:57:19 +08:00
Kuan-Po (Cooper) Tseng d59336a615
MINOR: Use ClusterTemplate in ApiVersionsRequestTest (#15936)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-14 21:19:57 +08:00
Greg Harris de105a8c14
KAFKA-16703 Close serverChannel in SocketServer if unable to bind to a port (#15923)
Reviewers: Gaurav Narula <gaurav_narula2@apple.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-14 14:47:00 +08:00
Max Riedel d61b34f2a7
KAFKA-14509: [3/4] Add integration test for consumerGroupDescribe API (#15727)
This patch adds integration tests for consumerGroupDescribe API.

Reviewers: David Jacot <djacot@confluent.io>
2024-05-13 11:32:50 -07:00
David Jacot f9169b7d3a
KAFKA-16735; Deprecate offsets.commit.required.acks (#15931)
This patch deprecates `offsets.commit.required.acks` in Apache Kafka 3.8 as described in KIP-1041: https://cwiki.apache.org/confluence/x/9YobEg.

Reviewers: Justine Olshan <jolshan@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-13 11:30:34 -07:00
Nikolay 6161fd0db2
KAFKA-14588 [2/N] ConfigCommandTest rewritten in java (#15873)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-13 19:45:28 +08:00
PoAn Yang 334d5d58bb
KAFKA-16677 Replace ClusterType#ALL and ClusterType#DEFAULT by Array (#15897)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-13 14:24:59 +08:00
Gaurav Narula 47841e0bb9
KAFKA-9401 Reduce contention for Fetch requests (#15836)
KIP-227 introduced in-memory caching of FetchSessions. Brokers with a large number of Fetch requests suffer from contention on trying to acquire a lock on FetchSessionCache.

This change aims to reduce lock contention for FetchSessionCache by sharding the cache into multiple segments, each responsible for an equal range of sessionIds. Assuming Fetch requests have a uniform distribution of sessionIds, the probability of contention on a segment is reduced by a factor of the number of segments.

We ensure backwards compatibility by ensuring total number of cache entries remain the same as configured and sessionIds are randomly allocated.

Reviewers: Igor Soarez <soarez@apple.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-05-11 23:19:59 +08:00
Chia-Ping Tsai 4dff60df67
MINOR: fix LogValidatorTest#checkNonCompressed (#15904)
Reviewers: Jun Rao <junrao@apache.org>
2024-05-11 09:50:52 +08:00
Sid Yagnik ef7b48e66a
Allowing WriteTxnMarkers API to run with AlterCluster permissions (#15837)
https://issues.apache.org/jira/browse/KAFKA-16513

https://cwiki.apache.org/confluence/display/KAFKA/KIP-1037%3A+Allow+WriteTxnMarkers+API+with+Alter+Cluster+Permission

Reviewers: Christo Lolov <christo_lolov@yahoo.com>,  Luke Chen <showuon@gmail.com>, Justine Olshan <jolshan@confluent.io>
2024-05-10 15:30:57 -07:00
Greg Harris 4e4f7d3231
KAFKA-15804: Close SocketServer channels when calling shutdown before enableRequestProcessing (#14729)
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Reviewers: Chris Egerton <chrise@aiven.io>, hudeqi <1217150961@qq.com>, Qichao Chu <qichao@uber.com>
2024-05-10 13:56:50 -07:00
Mario Pareja 147ea55dfe
MINOR: correct KAFKA_HEAP_OPTS server property in KafkaDockerWrapper(#15345)
Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>, Vedarth Sharma <142404391+VedarthConfluent@users.noreply.github.com>
2024-05-10 21:59:40 +05:30
Kuan-Po (Cooper) Tseng 58c7369be2
KAFKA-16660 reduce the check interval to speedup DelegationTokenRequestsTest (#15907)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-05-10 14:00:12 +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
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
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
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
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
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
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
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
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
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
TaiJuWu 4060d4370e
KAFKA-6527 Enable DynamicBrokerReconfigurationTest.testDefaultTopicConfig (#15796)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-27 08:00:29 +08:00
Omnia Ibrahim d88c15fc3e
KAFKA-15853 Move KRAFT configs out of KafkaConfig (#15775)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-27 07:02:31 +08:00
Gaurav Narula 025f9816f1
MINOR: fix javadoc warnings (#15527)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-26 08:31:52 +08:00
Omnia Ibrahim 6feae817d2
MINOR: Rename RaftConfig to QuorumConfig (#15797)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-26 03:08:31 +08:00
TaiJuWu ce9026f597
MINOR: Modified System.getProperty("line.separator") to java.lang.System.lineSeparator() (#15782)
Reviewers: Igor Soarez  <soarez@apple.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-26 02:32:11 +08:00
Mickael Maison 0a6d5ff23c
MINOR: Various cleanups in core (#15786)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Omnia Ibrahim <o.g.h.ibrahim@gmail.com>
2024-04-25 16:45:00 +02:00
TingIāu "Ting" Kì 864744ffd4
KAFKA-16610 Replace "Map#entrySet#forEach" by "Map#forEach" (#15795)
Reviewers: Apoorv Mittal <amittal@confluent.io>, Igor Soarez <soarez@apple.com>
2024-04-25 01:52:24 +01:00
PoAn Yang 81c222e977
KAFKA-16613 remove TestUtils#subscribeAndWaitForRecords (#15794)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-25 02:15:21 +08:00
Kamal Chandraprakash a8c0f2b98f
KAFKA-16605: Fix the flaky LogCleanerParameterizedIntegrationTest (#15787)
Even if the log start offset is updated, the log deletion might still not completed. Making the test more robust.

Reviewers: Luke Chen <showuon@gmail.com>
2024-04-24 17:52:52 +08:00
PoAn Yang a38185280c
KAFKA-16424: remove truncated logs after alter dir (#15616)
If there are some logs to be deleted during the log dir movement, we'll send for a scheduler to do the deletion later.
However, when the log dir movement completed, the future log is renamed, the async log deletion will fail with no file existed error.

Signed-off-by: PoAn Yang <payang@apache.org>

Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>, SoontaekLim <soontaek.lim@neya.kr>, Johnny Hsu <johnnyhsu@fb.com>
2024-04-24 17:51:29 +08:00
Omnia Ibrahim cfe5ab5cf2
KAFKA-15853 Move quota configs into server-common package (#15774)
Reviewers: Mickael Maison <mickael.maison@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-24 13:05:18 +08:00
Omnia Ibrahim 1b301b3020
KAFKA-15853 Move socket configs into org.apache.kafka.network.SocketServerConfigs (#15772)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-23 17:39:36 +08:00
Ken Huang fb529d8966
KAFKA-16548 Avoid decompressing/collecting all records when all we want to do is to find a single matched record from remote storage (#15765)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-22 21:23:11 +08:00
charliecheng630 1763fe19dd
KAFKA-16549 suppress the warnings from RemoteLogManager (#15767)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-22 20:42:17 +08:00
Lucas Brutschy ed47e37b28
KAFKA-16103: AsyncConsumer should await pending async commits on commitSync and close (#15613)
The javadoc for KafkaConsumer.commitSync says:

Note that asynchronous offset commits sent previously with the {@link #commitAsync(OffsetCommitCallback)}
(or similar) are guaranteed to have their callbacks invoked prior to completion of this method.

This is not always true in the async consumer, where there is no code at all to make sure that the callback is executed before commitSync returns.

Similarly, the async consumer is also missing logic to await callback execution in close. While the javadoc doesn't explicitly promise callback execution, it promises "completing commits", which one would reasonably expect to include callback execution. Also, the legacy consumer contains some code to execute callbacks before closing.

This change proposed a number of fixes to clean up the callback execution guarantees in the async consumer:

We keep track of the incomplete async commit
futures and wait for them to complete before returning from
commitSync or close (if there is time).
Since we need to block to make sure that our previous commits are
completed, we allow the consumer to wake up.
Some similar gaps are addressed in the legacy consumer, see #15693

Testing
Two new integration tests and a couple of unit tests.

Reviewers: Bruno Cadonna <cadonna@apache.org>, Kirk True <ktrue@confluent.io>, Lianet Magrans <lianetmr@gmail.com>
2024-04-22 13:26:15 +02:00
Omnia Ibrahim 5e96e5c898
KAFKA-15853 Refactor KafkaConfig to use PasswordEncoderConfigs (#15770)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-22 00:47:57 +08:00
TingIāu "Ting" Kì 98548c517d
KAFKA-16591 Clear all admins after close all them. (#15763)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-21 06:26:44 +08:00
Kuan-Po (Cooper) Tseng ced79ee12f
KAFKA-16552 Create an internal config to control InitialTaskDelayMs in LogManager to speed up tests (#15719)
Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-20 20:34:02 +08:00
hudeqi 613d4c8578
MINOR: fix hint in fetchOffsetForTimestamp (#15757)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-20 20:14:21 +08:00
Gaurav Narula 0308543d59
KAFKA-16082 Avoid resuming future replica if current replica is in the same directory (#15136)
It is observed that for scenario (3), i.e. a broker crashes while it
waits for the future replica to catch up for the second time and the
`dir1` is unavailable when the broker is restarted, the
broker tries to create the partition in `dir2` according to the metadata
in the controller. However, ReplicaManager also tries to resume the
stale future replica which was abandoned when the broker crashed. This
results in the renaming of the future replica to fail eventually because
the directory for the topic partition already exists in `dir2` and the
broker then marks `dir2` as offline.

This PR attempts to fix this behaviour by ignoring any future replicas
which are in the same directory as where the log exists. It further
marks the stale future replica for deletion.

Reviewers: Omnia Ibrahim <o.g.h.ibrahim@gmail.com>,  Igor Soarez <soarez@apple.com>, Proven Provenzano <pprovenzano@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-20 04:18:51 +08:00
Omnia Ibrahim ecb2dd4cdc
KAFKA-15853 Move KafkaConfig log properties and docs out of core (#15569)
Reviewers: Mickael Maison <mickael.maison@gmail.com>, Nikolay <nizhikov@apache.org>, Federico Valeri <fvaleri@redhat.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-20 04:14:23 +08:00
Calvin Liu 53ff1a5a58
KAFKA-15585: DescribeTopicPartitions client side change. (#15470)
Add the support for DescribeTopicPartitions API to AdminClient. For this initial implementation, we are simply loading all of the results into memory on the client side. 

Reviewers: Andrew Schofield <aschofield@confluent.io>, Kirk True <ktrue@confluent.io>, David Jacot <djacot@confluent.io>, Artem Livshits <alivshits@confluent.io>, David Arthur <mumrah@gmail.com>
2024-04-18 12:09:14 -04:00
Kamal Chandraprakash a3dcbd4e28
KAFKA-16073: Increment the local-log-start-offset before deleting segments in memory table (#15631)
Co-authored-by: hzh0425 <642256541@qq.com>

Reviewers: Luke Chen <showuon@gmail.com>, Jun Rao <junrao@gmail.com>
2024-04-17 09:41:29 -07:00
Omnia Ibrahim 363f4d2847
KAFKA-15853 Move consumer group and group coordinator configs out of core (#15684)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-17 20:41:22 +08:00
Michael Westerby 44196984bd
KAFKA-16363 Storage tool crashes if dir is unavailable (#15733)
Reviewers: Igor Soarez <soarez@apple.com>, Federico Valeri <fedevaleri@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-17 19:03:51 +08:00
Gaurav Narula 4954c578d4
KAFKA-16559 allow defining number of disks per broker in TestKitNodes (#15730)
Reviewers: Igor Soarez <soarez@apple.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-17 13:45:37 +08:00
lixinyang 6ed3bae2c1
MINOR: Fix a few typos in clients and core tests (#15725)
Reviewers: Mickael Maison <mickael.maison@gmail.com>, Luke Chen <showuon@gmail.com>, Igor Soarez<soarez@apple.com>
Co-authored-by: lixinyang <nickxyli@tencent.com>
2024-04-16 17:50:55 +02:00
Omnia Ibrahim 8c0458861c
KAFKA-15853 Move KafkaConfig Replication properties and docs out of … (#15575)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-16 15:28:35 +08:00
David Arthur e02ffd852f
KAFKA-16463 Delete metadata log on ZK broker startup (#15648)
This patch changes the behavior of the migrating ZK broker to always delete the local metadata log
during startup. This deletion is done immediately before creating the RaftManager which will
re-create the log directory and let the broker re-replicate the log from the active controller.

This new behavior is only present for ZK brokers that having migrations enabled. KRaft brokers,
even those with migrations enabled, will not delete their local metadata log. KRaft controllers are
not impacted by this change.

The rationale for this change is to make it easier for operators to re-attempt a ZK to KRaft
migration after having reverted back to ZK mode. If an operator has reverted back to ZK mode, there
will be an invalid metadata log on the disk of each broker. In order to re-attempt the migration in
the future, this log needs to be deleted. This can be pretty burdensome to the operator for large
clusters, especially since the log deletion must be done while the broker is offline.

Reviewers: Colin P. McCabe <cmccabe@apache.org>, Igor Soarez <soarez@apple.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-12 10:21:30 -07:00
Omnia Ibrahim 61baa7ac6b
KAFKA-15853 Move transactions configs out of core (#15670)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-13 00:29:51 +08:00
Igor Soarez 15c4ade06a
MINOR: Improve logging in AssignmentsManager (#15522)
At the moment it can be a bit difficult to troubleshoot issues related to the AssignmentsManager. Mainly because:

    Topic partitions are logged with topic ID and partition index but without the topic name.
    Directory IDs are logged without the directory path.
    Assignment reasons aren't tracked.

This patch addresses the three issues.

Reviewers: Luke Chen <showuon@gmail.com>
2024-04-12 14:13:40 +08:00
Sebastian Marsching a50ea8d4de
KAFKA-16473: Use correct cluster ID when formatting log dir. (#15658)
This fixes an issue that when starting a Docker container for the first time, the cluster ID used when formatting the log dir would not be $CLUSTER_ID but Some($CLUSTER_ID) (KAFKA-16473).

In order to be able to test the formatStorageCmd method which contained the bug, the method has been made package private.

Reviewers: cooper.tseng@suse.com, Vedarth Sharma <142404391+VedarthConfluent@users.noreply.github.com>, Manikumar Reddy <manikumar.reddy@gmail.com>
2024-04-12 11:30:27 +05:30
Colin Patrick McCabe b67a3fa79d
KAFKA-16509: CurrentControllerId metric is unreliable in ZK mode (#15695)
The CurrentControllerId metric added by KIP-1001 is unreliable in ZK
mode. Sometimes when there is no active ZK-based controller, it still
shows the previous controller ID. Instead, it should show -1 in that
situation.

This PR fixes that by using the controller ID from the
KafkaController.scala, which is obtained directly from the controller
znode. It also adds a new test, ControllerIdMetricTest.scala.

Reviewers: David Arthur <mumrah@gmail.com>
2024-04-11 09:34:27 -07:00
ghostspiders 4aba807530
KAFKA-15610 Fix CoreUtils.swallow() test gaps (#15410)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-11 18:58:40 +08:00
Cheng-Kai, Zhang 72b823e9bd
KAFKA-16482 Eliminate the IDE warnings of accepting ClusterConfig in BeforeEach (LeaderElectionCommandTest and ProducerIdsIntegrationTest) (#15676)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-11 18:42:14 +08:00
Dongnuo Lyu 619f27015f
KAFKA-16294: Add group protocol migration enabling config (#15411)
This patch adds the `group.consumer.migration.policy` config which controls how consumer groups can be converted from classic group to consumer group and vice versa. The config is kept as an internal one while we develop the feature.

Reviewers: Jeff Kim <jeff.kim@confluent.io>, David Jacot <djacot@confluent.io>
2024-04-10 10:59:26 -07:00
Omnia Ibrahim e2e2f82f2b
KAFKA-15853 Move Sasl and SSL configs out of core (#15656)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-10 21:57:52 +08:00
Igor Soarez f6c9feea76
KAFKA-16297: Race condition while promoting future replica (#15557)
If a future replica doesn't get promoted, any directory reassignment sent to the controller should be reversed.

The current logic is already addressing the case when a replica hasn't yet been promoted and the controller hasn't yet acknowledged the directory reassignment. However, it doesn't cover the case where the replica does not get promoted due to a directory failure after the controller has acknowledged the reassignment but before the future replica catches up again and is promoted to main replica.

Reviewers: Luke Chen <showuon@gmail.com>
2024-04-10 17:57:05 +08:00
Phuc-Hong-Tran a4d6456872
KAFKA-15538: Client support for java regex based subscription (#15585)
Fully implemented legacy subscription using Pattern for AsyncKafkaConsumer.
Enabled related tests for subscription using Pattern in PlaintextConsumerTest.

Reviewers: Lianet Magrans <lianetmr@gmail.com>, Kirk True <ktrue@confluent.io>, David Jacot <djacot@confluent.io>, Bruno Cadonna <cadonna@apache.org>
2024-04-10 09:20:46 +02:00
Chia-Ping Tsai 9a6760f130
KAFKA-16310 ListOffsets doesn't report the offset with maxTimestamp a… (#15621)
We do iterate the records to find the offsetOfMaxTimestamp instead of returning the cached one when handling ListOffsetsRequest.MAX_TIMESTAMP, since it is hard to align all paths to get correct offsetOfMaxTimestamp. The known paths are shown below.

1. convertAndAssignOffsetsNonCompressed -> we CAN get correct offsetOfMaxTimestamp when validating all records
2. assignOffsetsNonCompressed -> ditto
3. validateMessagesAndAssignOffsetsCompressed -> ditto
4. validateMessagesAndAssignOffsetsCompressed#buildRecordsAndAssignOffsets -> ditto
5. appendAsFollow#append#analyzeAndValidateRecords -> we CAN'T get correct offsetOfMaxTimestamp as iterating all records is expensive when fetching records from leader
6. LogSegment#recover -> ditto

Reviewers: Jun Rao <junrao@gmail.com>
2024-04-10 11:36:07 +08:00
PoAn Yang 983a94a89e
KAFKA-16487 Support to define server properties by ClusterTestDefaults (#15687)
Sometimes we want to define server properties for all test cases, and using BeforeEach to modify the ClusterConfig is the only way. The side effect is that the IDE does not like the style since IDE can't recognize custom ParameterResolver of ClusterConfig.

The alternative is that we can take ClusterInstance from constructor first, and then we modify the inner ClusterConfig in BeforeEach phase. However, that may confuse users about the life cycle of "configs".

In short, I prefer to define the server property by ClusterTestDefaults. It already includes some server-side default property, and we can enhance that to deal with more existent test case.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-10 11:09:24 +08:00
Igor Soarez 3ad648243c
KAFKA-13907 Fix hanging ServerShutdownTest.testCleanShutdownWithKRaftControllerUnavailable (#12174)
Add new method shutdown(Duration) to accept timeout argument. We can leverage the new method to run non-graceful shutdown in testing.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-10 00:43:12 +08:00
Kuan-Po (Cooper) Tseng 169ed60fe1
KAFKA-16477 Detect thread leaked client-metrics-reaper in tests (#15668)
After profiling the kafka tests, tons of client-metrics-reaper thread not cleanup after BrokerServer shutdown.
The thread client-metrics-reaper comes from ClientMetricsManager#expirationTimer, and BrokerServer#shudown doesn't close ClientMetricsManager which let the thread still runs in background.

Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2024-04-09 05:07:33 +08:00
vamossagar12 22f9eee89b
KAFKA-16481: Fixing flaky test kafka.server.ReplicaManagerTest#testRemoteLogReaderMetrics (#15677)
Adding NPE check in RLM.

Reviewers: Luke Chen <showuon@gmail.com>
2024-04-08 20:15:54 +08:00
Philip Nee 4e0578fb81
KAFKA-16156: beginningOrEndOffsets does not need to build an OffsetAndTimestamps object upon completion (#15525)
A subtle difference in the behavior of the two API causes the failures with Invalid negative timestamp.

In this PR, the list offsets response will be processed differently based on the API. For beginingOffsets/endOffsets - the offset response should be directly returned.

For offsetsForTimes - A OffsetAndTimestamp object is constructed for each requested TopicPartition before being returned.

The reason beginningOffsets and endOffsets - We are expecting a -1 timestamp from the response which subsequently causes the invalid timestamp exception because the original code tries to construct an OffsetAndTimestamp object upon returning.

In this PR, the following missing tasks are added:

short-circuit both beginningOrEndOffsets
Test both API (beginningOrEndOffsets, OffsetsForTime)
Seems like we don't have tests for this API: Note it is presented in other IntegrationTests but they are added to test Async consumer

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>, Lianet Magrans <lianetmr@gmail.com>
2024-04-08 13:04:58 +02:00
Erik van Oosten 8e61f04228
MINOR: Fix usage of none in javadoc (#15674)
- Use `Empty` instead of 'none' when referring to `Optional` values.
- `Headers.lastHeader` returns `null` when no header is found.
- Fix minor spelling mistakes.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-08 08:43:05 +08:00
Nikolay 4b2278ff9c
MINOR: Default test name added to core (#15667)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2024-04-07 21:43:16 +08:00
Omnia Ibrahim e798bed198
KAFKA-16234: Log directory failure re-creates partitions in another logdir automatically (#15335)
This pr fixes the bug created by #15263 which caused topic partition to be recreated whenever the original log dir is offline: Log directory failure re-creates partitions in another logdir automatically

Reviewers: Luke Chen <showuon@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>, Igor Soarez <soarez@apple.com>, Gaurav Narula <gaurav_narula2@apple.com>, Proven Provenzano <pprovenzano@confluent.io>
2024-04-06 14:36:26 +08:00