Commit Graph

15283 Commits

Author SHA1 Message Date
Lucas Brutschy fc2e3dfce9
MINOR: Disallow unused local variables (#18963)
Recently, we found a regression that could have been detected by static
analysis, since a local variable wasn't being passed to a method during
a refactoring, and was left unused. It was fixed in
[7a749b5](7a749b589f),
but almost slipped into 4.0. Unused variables are typically detected by
IDEs, but this is insufficient to prevent these kinds of bugs. This
change enables unused local variable detection in checkstyle for Kafka.

A few notes on the usage:
- There are two situations in which people actually want to have a local
variable but not use it. First, there are `for (Type ignored:
collection)` loops which have to loop `collection.length` number of
times, but that do not use `ignored` in the loop body. These are
typically still easier to read than a classical `for` loop. Second, some
IDEs detect it if a return value of a function such as `File.delete` is
not being used. In this case, people sometimes store the result in an
unused local variable to make ignoring the return value explicit and to
avoid the squiggly lines.
- In Java 22, unsued local variables can be omitted by using a single
underscore `_`. This is supported by checkstyle. In pre-22 versions,
IntelliJ allows such variables to be named `ignored` to suppress the
unused local variable warning. This pattern is often (but not
consistently) used in the Kafka codebase. This is, however, not
supported by checkstyle.

Since we cannot switch to Java 22, yet, and we want to use automated
detection using checkstyle, we have to resort to prefixing the unused
local variables with `@SuppressWarnings("UnusedLocalVariable")`. We have
to apply this in 11 cases across the Kafka codebase. While not being
pretty, I'd argue it's worth it to prevent bugs like the one fixed in
[7a749b5](7a749b589f).

Reviewers: Andrew Schofield <aschofield@confluent.io>, David Arthur
<mumrah@gmail.com>, Matthias J. Sax <matthias@confluent.io>, Bruno
Cadonna <cadonna@apache.org>, Kirk True <ktrue@confluent.io>
2025-03-10 09:37:35 +01:00
Azhar Ahmed 832dfa36da
KAFKA-18637: Fix max connections per ip and override reconfigurations (#19099)
Reviewers: Christo Lolov <lolovc@amazon.com>, TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>
2025-03-10 07:27:48 +00:00
Mahsa Seifikar 75260cf92c
MINOR: Improve grammar and clarity in upgrade.html (#19141)
This PR addresses minor grammar and clarity issues in upgrade.html doc.

Reviewers: mingdaoy <mingdaoy@gmail.com>, Colin P. McCabe <cmccabe@apache.org>, TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>, Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-10 14:27:20 +08:00
Nick Guo 3ebe21c8f1
MINOR: correct user reference in quota configuration from 'userA' to 'user1' (#19140)
Reviewers: TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 23:44:56 +08:00
Ken Huang b129ed4566
MINOR: Use immutable KIP link (#19153)
Reviewers: TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 23:42:33 +08:00
Ken Huang d5413fdb48
KAFKA-17856 Move ConfigCommandTest and ConfigCommandIntegrationTest to tool module (#17767)
Reviewers: TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 21:05:36 +08:00
PoAn Yang a5e5e2dcd5
KAFKA-18706 Move AclPublisher to metadata module (#18802)
Move AclPublisher to org.apache.kafka.metadata.publisher package.

Reviewers: Christo Lolov <lolovc@amazon.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 21:00:33 +08:00
ClarkChen 1584d49470
KAFKA-18944 Remove unused setters from ClusterConfig (#19166)
Remove unused `saslServerProperties`, `saslClientProperties`,
`adminClientProperties`, `producerProperties`, and `consumerProperties`
in ClusterConfig.

First, I quickly fixed the unused adminClientProperties, and then I will
move on to https://github.com/apache/kafka/pull/19094 to fix the related
issues.

Pass AdminClientRebootstrapTest
<img width="1398" alt="Screenshot 2025-03-09 at 12 54 57 PM"
src="https://github.com/user-attachments/assets/73c50376-6602-493d-8abd-0eb2bb304114"
/>

Pass ClusterConfigTest
<img width="1117" alt="Screenshot 2025-03-09 at 12 55 28 PM"
src="https://github.com/user-attachments/assets/b4da59da-dfdf-4698-9077-5086854360ab"
/>

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 17:49:28 +08:00
ClarkChen 2a0dbd8e0b
KAFKA-18909 Move DynamicThreadPool to server module (#19081)
* Add `DynamicThreadPool.java` to the server module.
* Remove the old DynamicThreadPool object in the `DynamicBrokerConfig.scala`.

Reviewers: TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 17:42:51 +08:00
Ming-Yen Chung 119d043c49
KAFKA-18700 Migrate SnapshotPath, Entry, OffsetAndEpoch, LogFetchInfo, and LogAppendInfo to record classes (#19062)
Migrate the following data carrier class to records to eliminate
constructors, `equals`, `hashCode`, and `toString`.
* `Entry` in `LogHistory`
* `SnapshotPath`

Additionally, migrate the following classes as discussed:
* OffsetAndEpoch
* LogFetchInfo
* LogAppendInfo

In Java, accessing a field in record class requires parentheses.
In Scala, parentheses are not needed because Scala allows omitting them
when calling parameterless methods; hence, there is no need to change
the Scala code.

Reviewers: Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 09:52:02 +08:00
TengYao Chi adbd2823ed
MINOR: Adjust ToC of zk2kraft and fix wrong section number of docker (#19146)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-03-09 08:55:50 +08:00
Mahsa Seifikar 947c414a8c
MINOR: Fix missing argument in kafka-features.sh upgrade doc (#19160)
Running `bin/kafka-features.sh upgrade --release-version 4.0` results in
the following error. This PR fixes the issue by adding the required
argument.

`kafka-features: error: one of the arguments --bootstrap-server
--bootstrap-controller is required.`

Reviewers: Colin P. McCabe <cmccabe@apache.org>
2025-03-07 13:57:58 -08:00
Colin Patrick McCabe 343bc995f4
KAFKA-18920: The kcontrollers must set kraft.version in ApiVersionsResponse (#19127)
The kafka controllers need to set kraft.version in their
ApiVersionsResponse messages according to the current kraft.version
reported by the Raft layer. Instead, currently they always set it to 0.

Also remove FeatureControlManager.latestFinalizedFeatures. It is not
needed and it does a lot of copying.

Reviewers: Jun Rao <junrao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-07 13:46:46 -08:00
Cheryl Simmons 6940bef6e8
MINOR: Small fit and finish changes to Producer config doc strings (#19125)
- Adding a space, article and punctuation to the Producer config doc
strings for consistency and readability.

Reviewers: TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>, Justine Olshan <jolshan@confluent.io>
2025-03-07 11:07:35 -08:00
Calvin Liu db38bef076
KAFKA-18940: fix electionWasClean (#19156)
The electionWasClean should also consider if the election is done
through ELR. Otherwise, the metric uncleanLeaderElection will wrongly
count the ELR election
https://issues.apache.org/jira/browse/KAFKA-18940

Reviewers: Jun Rao <junrao@gmail.com>
2025-03-07 11:04:06 -08:00
Apoorv Mittal 8b955b54da
MINOR: Wrapping exceptions in usage for groups and metrics utility (#19151)
If specified an invalid option then an exception trace appears with
`kafka-client-metrics.sh` and `kafka-groups.sh` utilities. Then once has
to explicitly remove the invalid argument and append `--help` to fetch
correct options. The PR fixes below error message to one with `cause`
and `usage`. This behaviour is similar to `kafka-console-consumer.sh`
and `kafka-console-share-consumer.sh`

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-03-07 16:30:16 +00:00
Kevin Wu d04cddeb71
MINOR: Allow for configurable delay for periodic tasks (#19143)
This patch allows for the immediatePeriodNs to be passed in when creating a periodic task

Reviewers: Colin P. McCabe <cmccabe@apache.org>
2025-03-07 11:24:34 -05:00
Lucas Brutschy 618ea2c1ca
KAFKA-18285: Add describeStreamsGroup to Admin API (#19116)
Adds `describeStreamsGroup` to Admin API.

This exposes the result of the `DESCRIBE_STREAMS_GROUP` RPC in the Admin
API.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-03-07 15:56:07 +01:00
leaf-soba 53b2935c51
KAFKA-18461 Add Objects.requireNotNull to Snapshot (#18684)
Add explicit not-null checks in Snapshot so we get a better error message in the event that a Snapshot object is accessed after erase has been called.

Reviewers: David Arthur <mumrah@gmail.com>
2025-03-07 09:48:09 -05:00
xijiu a6064e0800
KAFKA-17607: Add CI step to verify LICENSE-binary (#18299)
Add the verify_license.py script to our build to detect missing licenses.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ken Huang <s7133700@gmail.com>, David Arthur <mumrah@gmail.com>
2025-03-07 09:45:23 -05:00
Dániel Urbán 40db001588
KAFKA-18929: Log a warning when time based segment delete is blocked by a future timestamp (#19137)
When producers send future timestamps, time retention based log segments
may get blocked from removal for an extended period of time. Log
cleaning should should warn in the logs when this scenario occurs.

Reviewers: Viktor Somogyi-Vass <viktorsomogyi@gmail.com>
2025-03-07 14:31:22 +01:00
Jorge Esteban Quilcate Otoya 269e8892ad
KAFKA-15931: Reopen TransactionIndex if channel is closed (#15241)
Cached TransactionIndex may get closed if interrupted, causing following calls to always fail with ClosedChannelException, and forcing process to be restarted. In order to avoid this issue, a new method is exposed by TransactionIndex to validate state of channel; and index is reopened if closed.

Reviewers: Luke Chen <showuon@gmail.com>, Kamal Chandraprakash<kamal.chandraprakash@gmail.com>, Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com>
2025-03-07 19:31:21 +08:00
David Jacot 8cf2f9a61a
KAFKA-18046; High CPU usage when using Log4j2 (#19138)
This patch is a first step towards resolving KAFKA-18046. Apache Kafka
4.0 ships with log4j2 so the issue raised in the ticket causing high CPU
usage on the fetch path due to LoggerFactory.getLogger() being called on
the handling of all fetch responses is not good. Hence, I propose to fix
that one by caching the Logger used by the `CompletedFetch` class.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>
2025-03-07 00:03:32 -08:00
Colin Patrick McCabe f31208d443
MINOR: zk2kraft: add more information about kafka-configs.sh (#19100)
Add information about setting dynamic log levels and dynamic
configurations on KRaft controllers.

Reviewers: Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-07 11:27:18 +08:00
ClarkChen 870db5d811
KAFKA-18915: Migrate AdminClientRebootstrapTest to use new test infra (#19094)
Migrate AdminClientRebootstrapTest to the new test infra and remove the
old Scala test.

Reviewers: TengYao Chi <kitingiao@gmail.com>, David Arthur <mumrah@gmail.com>
2025-03-06 16:05:51 -05:00
Matthias J. Sax d85946da19
MINOR: reduce per-batch logging to TRACE level (#19101)
Logging on a per-batch bases is very chatty, and should only be done at
TRACE level to avoid spamming DEBUG logs.

Reviewers: Justine Olshan <jolshan@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
2025-03-06 11:06:26 -08:00
Iamoshione a9bc7c5889
KAFKA-18766:Docs: Make usage of allow.everyone.if.no.acl.found config clearer (#19077)
In the documentation today, we have the following sentence:

By default, if no ResourcePatterns match a specific Resource R, then R
has no associated ACLs, and therefore no one other than super users is
allowed to access R. If you want to change that behavior, you can
include the following in server.properties.

Reviewers: TengYao Chi <kitingiao@gmail.com>, Andrew Schofield <aschofield@confluent.io>
 

Although, it is correct, I have observed users being confused by it. I
think could me made clearer that default is deny and this property is a
way to change default.
Change

Replace the above with the following:

 

Default Behavior Without ACLs:

If a resource (R) does not have any ACLs defined—that is, if no ACL
matches the resource—Kafka will restrict access to that resource. In
this situation, only super users are allowed to access it.

Changing the Default Behavior:

If you prefer that resources without any ACLs be accessible by all users
(instead of just super users), you can change the default behavior. To
do this, add the following line to your server.properties file:

 

allow.everyone.if.no.acl.found=true

With this setting enabled, if a resource does not have any ACLs defined,
Kafka will allow access to everyone. If a resource has one or more ACLs
defined, those ACL rules will be enforced as usual, regardless of the
setting.
2025-03-06 18:03:41 +00:00
Andrew Schofield 1da30bdedf
KAFKA-18900: Experimental share consumer acknowledge mode config (#19113)
User testing of the `KafkaShareConsumer` interface has revealed some
areas which confuse people. One of these is that way that it decides
whether you want to use implicit or explicit acknowledgement of records
by observing which calls the application issues. We are taking the
opportunity to refine the interface before it is finalised.

This PR introduces an experimental configuration called
`internal.share.acknowledgement.mode` which can be used to make the
application declare which kind of acknowledgement it wishes to use. We
plan to try out the configuration, assess whether it has helped, and
then create a proper consumer configuration that makes this area better.
That would require a lot of change in the tests, which explains why this
initial PR only has a small number of tests.

Reviewers: David Arthur <mumrah@gmail.com>
2025-03-06 17:57:11 +00:00
David Arthur 88f8255732
MINOR Increase JUnit max forks and memory for CI (#18560)
Increase the max number of forks for each JUnit task to 4. Also increase
the amount of memory given to forked workers to 3g.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-03-06 12:48:21 -05:00
Ismael Juma a738df4aaa
KAFKA-18648: Make `records` in `FetchResponse` nullable again (#19131)
As Jun raised in
https://github.com/apache/kafka/pull/18726#discussion_r1972525165,
we actually do have a few code paths where `records` remains `null`
in the FetchResponse with broker version 3.9 and older:

* Compression codec for topic is ZSTD and fetch version < 10:
https://github.com/apache/kafka/blob/3.9/core/src/main/scala/kafka/server/KafkaApis.scala#L835
* Down-conversion of zstandard-compressed:
https://github.com/apache/kafka/blob/3.9/core/src/main/scala/kafka/server/KafkaApis.scala#L884
* Generic uncaught exception through:
https://github.com/apache/kafka/blob/3.9/clients/src/main/java/org/apache/kafka/common/requests/FetchRequest.java#L365

To ensure 4.0 clients don't fail to deserialize fetch responses from
brokers with the affected versions, we make `records` nullable again.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Jun Rao <junrao@gmail.com>
2025-03-06 09:12:36 -08:00
Ismael Juma e9ed67d34a
MINOR: Update log4j2 to 2.24.3 (#19135)
2.24.2 includes a critical fix:

"This release fixes a critical bug in Log4j API initialization code,
which can cause LogManager.getLogger() to return null under certain
conditions. See https://github.com/apache/logging-log4j2/issues/3143 for
details."

2.24.3 includes an important fix for our usage:

"Fix ConcurrentModificationException, if multiple threads modify loggers
concurrently.
This bug affects users that modify logger levels programmatically."

Release notes:
* https://github.com/apache/logging-log4j2/releases/tag/rel%2F2.24.2
* https://github.com/apache/logging-log4j2/releases/tag/rel%2F2.24.3

Reviewers: David Jacot <djacot@confluent.io>, Chia-Ping Tsai
<chia7712@gmail.com
2025-03-06 09:11:29 -08:00
Alieh Saeedi 7a976c651e
KAFKA-18887: Implement Streams Admin APIs (#19120)
Implement Admin API extensions beyond list/describe group (delete group,
offset-related APIs).

* adds methods for describing and manipulating offsets, as described in
KIP-1071
* adds corresponding unit tests

These are doing the exact same thing as the corresponding consumer group
counter-parts.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-03-06 17:55:21 +01:00
Lucas Brutschy 7fcee6f459
MINOR: transformValues test improvement (#19106)
Follow-up to 295760d3eb. Also check the
set of state stores as suggested in reviews.

Reviewers: Bruno Cadonna <cadonna@apache.org>
2025-03-06 17:54:30 +01:00
Sushant Mahajan b89c819f63
MINOR: Added evolving annotation to DeleteShareGroupsResult. (#19133)
* Added `InterfaceStability.Evolving` annotation to`DeleteShareGroupsResult`.
* Fixed some java doc.

Co-authored-by: Andrew Schofield <aschofield@confluent.io>

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Andrew Schofield <aschofield@confluent.io>
2025-03-06 16:17:37 +00:00
David Arthur c9804344de
HOTFIX Disable branch protections on trunk (#19139)
This reverts the branch protections added in #19122

Reviewers: David Jacot <david.jacot@gmail.com>
2025-03-06 10:33:56 -05:00
Chirag Wadhwa 899cdb598a
KAFKA-18811: Added command configs to admin client as well in VerifiableShareConsumer (#19130)
This PR includes a new flag in VerifiableShareConsumer.java called
command.config to include a properties file for admin client
related configs

Co-authored-by: Andrew Schofield <aschofield@confluent.io>

Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Andrew Schofield <aschofield@confluent.io>
2025-03-06 13:27:15 +00:00
TengYao Chi 6ad9ca518c
MINOR: Cleanup import-control-core.xml (#19095)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-03-06 19:45:08 +08:00
David Jacot b4cc88f6c4
MINOR: Update upgrade steps (#19132)
Using `bin/kafka-features.sh upgrade --metadata 4.0` to finalize the
upgrade is deprecated and furthermore it does not bump all the other
feature flags. Hence we should recommend to use `bin/kafka-features.sh
upgrade --release-version 4.0` in the documentation. This change was
introduced in [KIP-1022: Formatting and Updating
Features](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1022%3A+Formatting+and+Updating+Features).

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>
2025-03-06 02:22:03 -08:00
mingdaoy 21358342f4
MINOR: Improve the example of kafka-metadata-shell.sh (#19107)
Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-06 17:32:07 +08:00
Ken Huang 041d8019d6
KAFKA-18910 Remove kafka.utils.json (#19112)
Reviewers: TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-06 14:11:20 +08:00
dengziming 50510bb19d
HOTFIX: Do not use highest version when version is valid (#19109)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-03-06 10:15:58 +08:00
David Arthur 56fc8e9d2a
HOTFIX Fix asf.yaml strict [2/n] (#19126)
Change the `strict` value back to false. Follow-up of #19124

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-03-05 17:49:29 -05:00
David Arthur ebf22ddab6
HOTFIX Fix asf.yaml strict [1/n] (#19124)
Per ASF Infra's instructions, we need to reapply this .asf.yaml change.

We'll do that by setting it to "true", then back to "false"

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-03-05 17:32:14 -05:00
David Arthur da7d56a5cc
MINOR Add a required status check for trunk (#19122)
Add a single job that runs after the whole CI pipeline and make it a
required check before merging a PR. This will prevent us from merging
PRs which have not run through the CI.

Reviewers: Justine Olshan <jolshan@confluent.io>
2025-03-05 14:48:46 -05:00
David Arthur d86cb59790 Revert "KAFKA-18887: Implement Streams Admin APIs (#19049)"
This reverts commit 017692e86c.
2025-03-05 10:49:11 -05:00
Sushant Mahajan 485699a187
MINOR: Delete DeleteGroupsResult class. (#19057)
In this PR, we perform this refactor as the class is not needed since
there is no need to refer to child classes by common ref and the
duplicated code is minimal.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-03-05 14:38:18 +00:00
Alieh Saeedi 017692e86c
KAFKA-18887: Implement Streams Admin APIs (#19049)
Implement Admin API extensions beyond list/describe group (delete group, offset-related APIs).

* adds methods for describing and manipulating offsets, as described in KIP-1071
* adds corresponding unit tests

These are doing the exact same thing as the corresponding consumer group counter-parts.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-03-05 15:32:09 +01:00
co63oc 3d7ac0c3d1
MINOR: Fix typos in multiple files (#19102)
Fix typos in multiple files

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-03-05 14:27:32 +00:00
S.Y. Wang 6ecf6817ad
KAFKA-18919 Clarify that KafkaPrincipalBuilder classes must also implement KafkaPrincipalSerde (#19104)
In KRaft mode, custom KafkaPrincipalBuilder instances must implement KafkaPrincipalSerde. This PR updates all related documentation to highlight this requirement.

Reviewers: Ken Huang <s7133700@gmail.com>, David Jacot <djacot@confluent.io>, TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-05 21:25:09 +08:00
Xuan-Zhang Gong 18eca0229d
KAFKA-18882 Remove BaseKey, TxnKey, and UnknownKey (#19054)
Reviewers: Ken Huang <s7133700@gmail.com>, TengYao Chi <kitingiao@gmail.com>, PoAn Yang <payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-05 21:16:18 +08:00