Commit Graph

3311 Commits

Author SHA1 Message Date
Liam Miller-Cushon 1bb0c9a54b
MINOR: Fix an incorrect assignment in StreamsUncaughtExceptionHandlerIntegrationTest (#18837)
This constructor was not initializing a field with the constructor
argument, the extra `} {` was ending the constructor body and creating
an instance initializer block that assigned the field to itself.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-16 20:25:07 -07:00
Chris Flood 67fa3656cc
MINOR: Fix Streams Position thread-safety (#19480)
* Fixes a thread-safety bug in the Kafka Streams Position class
* Adds a multithreaded test to validate the fix and prevent regressions

Reviewers: John Roesler <vvcephei@apache.org>
2025-04-16 14:45:38 -05:00
xijiu 8bdd73c803
KAFKA-19137 Use `StandardCharsets.UTF_8` instead of `StandardCharsets.UTF_8.name()` (#19464)
Replace `StandardCharsets.UTF_8.name()` with `StandardCharsets.UTF_8` to
avoid UnsupportedEncodingException and optimize the related code at the
same time.

Reviewers: Ken Huang <s7133700@gmail.com>, PoAn Yang
<payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
2025-04-15 23:44:00 +08:00
Lucas Brutschy 9e620287f1
KAFKA-19118: Enable KIP-1071 in StandbyTaskCreationIntegrationTest (#19438)
Enable KIP-1071 parameter in `StandbyTaskCreationIntegrationTest`.

Required a fix: In `ChangelogTopic.setup`, we actually need to return
both the source-topic (optimized) and the non-source-topic changelog
topics, since otherwise we will not find the partition number later on.

Extended `EmbeddedKafkaCluster` to set the number of standby replicas
dynamically for the group. We need to initialize it to one for the
integration test to go through.

Reviewers: Bill Bejeck <bbejeck@apache.org>
2025-04-11 11:20:54 +02:00
Bruno Cadonna c11938c926
KAFKA-19124: Use consumer background event queue for Streams events (#19421)
In the first version of the integration of the stream thread with the
new Streams rebalance protocol, the consumer used a dedicated event
queue for Streams/specific background events to request the stream
thread to call the rebalance callbacks. That  led to an issue where the
consumer times out when unsubscribing.

This commit gets rid of the dedicated queue and incorporates the
Streams-specific background events into event queue used by the
consumer.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-04-10 21:06:06 +02:00
Lucas Brutschy c65a161cd8
KAFKA-19118: Enable KIP-1071 in InternalTopicIntegrationTest (#19425)
KIP-1071 creates internal topics broker-side, so this test checks
whether, when KIP-1071 is enabled, basically the same topics are
created.

It also adds a little helper method in `EmbeddedKafkaCluster`, so that
fewer code changes are required to enable KIP-1071. We use that helper
in the already enabled SmokeTestDriverIntegrationTest and revert some of
the changes there (making the cluster `final` again).

Reviewers: Bill Bejeck <bbejeck@apache.org>, PoAn Yang
 <payang@apache.org>
2025-04-10 16:57:38 +02:00
Florian Hussonnois eeb1214ba8
KAFKA-18962: Fix onBatchRestored call in GlobalStateManagerImpl (#19188)
Call the StateRestoreListener#onBatchRestored with numRestored and not
the totalRestored when reprocessing state

See: https://issues.apache.org/jira/browse/KAFKA-18962

Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>, Matthias
Sax <mjsax@apache.org>
2025-04-09 13:17:38 -07:00
Bruno Cadonna 2a370ed721
KAFKA-19037: Integrate consumer-side code with Streams (#19377)
The consumer adaptations for the new Streams rebalance protocol need to
be integrated into the Streams code. This commit does the following:
- creates an async Kafka consumer
  - with a Streams heartbeat request manager
  - with a Streams membership manager
- integrates consumer code with the Streams membership manager and the
Streams heartbeat request manager
- processes the events from the consumer network thread (a.k.a.
background thread)
  that request the invocation of the "on tasks revoked", "on  tasks
assigned", and "on all tasks lost"
  callbacks
- executes the callbacks
- sends to the consumer network thread the events signalling the
execution of the callbacks
- adapts SmokeTestDriverIntegrationTest to use the new Streams rebalance
protocol

This commit misses some unit test coverage, but it also unblocks other
work on trunk regarding the new Streams rebalance protocol.  The missing
unit tests will be added soon.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-04-09 13:26:51 +02:00
Chirag Wadhwa 5148174196
KAFKA-16718-2/n: KafkaAdminClient and GroupCoordinator implementation for DeleteShareGroupOffsets RPC (#18976)
This PR contains the implementation of KafkaAdminClient and
GroupCoordinator for DeleteShareGroupOffsets RPC.

- Added `deleteShareGroupOffsets` to `KafkaAdminClient`
- Added implementation for `handleDeleteShareGroupOffsetsRequest` in
`KafkaApis.scala`
- Added `deleteShareGroupOffsets` to `GroupCoordinator` as well.
internally this makes use of `persister.deleteState` to persist the
changes in share coordinator

Reviewers: Andrew Schofield <aschofield@confluent.io>, Sushant Mahajan <smahajan@confluent.io>
2025-04-09 07:31:06 +01:00
Ayoub Omari b963e58000
KAFKA-16407: Fix foreign key INNER join on change of FK from/to a null value (#19303)
Fixes both KAFKA-16407 and KAFKA-16434.

Summary of existing issues:

- We are ignoring new left record when its previous FK value is null
- We do not unset foreign key join result when FK becomes null

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-05 20:13:31 -07:00
PoAn Yang d6ff7b80dd
KAFKA-13747: refactor TopologyTest to test different store type parametrized (#19323)
Use `ParameterizedTest` to test both `IN_MEMORY` and `ROCKS_DB` store
type in `TopologyTest`.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-04 14:45:13 -07:00
lorcan 6af849f864
KAFKA-7952: use in memory stores for KTable test (#19218)
Switch to in-memory story for KTable-KTable left-join test.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-04 09:22:08 -07:00
nilmadhab mondal d35ab4d27a
KAFKA-18713: Fix FK Left-Join result race condition (#19005)
When a row in a FK-join left table is updated, we should send a "delete
subscription with no response" for the old FK to the right hand side, to
avoid getting two responses from the right hand side. Only the "new
subscription" for the new FK should request a response. If two responses
are requested, there is a race condition for which both responses could
be processed in the wrong order, leading to an incorrect join result.

This PR fixes the "delete subscription" case accordingly, to no request
a response.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-03 16:22:47 -07:00
TengYao Chi 5eb4e116bc
KAFKA-18067: Add a flag to disable producer reset during active task creator shutting down (#19269)
JIRA: KAFKA-18067

Fix producer client double-closing issue in Kafka Streams. 
During StreamThread shutdown, TaskManager closes first, which closes the
producer client. Later, calling `unsubscribe` on the main consumer may
trigger the `onPartitionsLost` callback, attempting to reset
StreamsProducer when EOS is enabled. This causes an already closed
producer to be closed twice while the newly created producer is never
closed.

In detail:
This patch adds a flag to control the producer reset and has a new
method to change this flag, which is only invoked in
`ActiveTaskCreator#close`.
This would guarantee that the disable reset producer will only occur
when StreamThread shuts down.

Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>, Matthias Sax <mjsax@apache.org>
2025-04-03 14:13:22 -07:00
Thomas Gebert db4e74b46e
MINOR: Add Functional Interface annotation to interfaces used by Lambdas (#19234)
Adds the FunctionalInterface annotation to relevant Kafka Streams
classes. While this is not strictly required for Java, it's still best
practice and also useful for better integration with other JVM
languages, for example Clojure, to allow using these interfaces as
lambdas.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-04-03 09:30:56 -07:00
Ken Huang d619cc5b88
KAFKA-19058 Running the streams/streams-scala module tests produces a streams-scala.log (#19324)
Remove streams-scala module log4j2 file appender.

Reviewers: PoAn Yang <payang@apache.org>, Matthias J. Sax <matthias@confluent.io>
2025-04-02 12:12:16 -07:00
Ritika Reddy eeffd8c475
KAFKA-19003: Add forceTerminateTransaction command to CLI tools (#19276)
This patch is part of KIP-939 [Support Participation in
2PC](https://cwiki.apache.org/confluence/display/KAFKA/KIP-939%3A+Support+Participation+in+2PC)

The kafka-transactions.sh tool will support a new command
--forceTerminateTransaction It has one required argument
--transactionalId that would take the transactional id for the
transaction to be terminated.

The command uses the existing Admin#fenceProducers method to forcefully
abort the transaction associated with the specified transactional ID.
Under the hood, it sends an InitProducerId request to the transaction
coordinator with the given transactional ID and keepPreparedTxn = false
by default. This is aligned with the functionality outlined in the KIP.

We will be creating a new public method in the Admin Client **public
TerminateTransactionResult forceTerminateTransaction(String
transactionalId)**, and re-use the existing fence producer method.

Reviewers: Artem Livshits <alivshits@confluent.io>, Justine Olshan <jolshan@confluent.io>
2025-04-02 11:51:26 -07:00
Bill Bejeck 87a299a081
KAFKA-18826: Add global thread metrics (#18953)
When implementing
[KIP-1091](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1091%3A+Improved+Kafka+Streams+operator+metrics)
metrics for the Global Stream thread was overlooked. This ticket adds
the Global Thread metrics so they are available via the KIP-1076 process
of adding external Kafka metrics.

The existing integration test has been updated to confirm GlobalThread
metrics are sent via the broker plugin.

Reviewers: Matthias Sax <mjsax@apache.org>
2025-04-02 09:17:49 -04:00
PoAn Yang c5f8ae0424
KAFKA-16260: Deprecate window.size.ms and window.inner.class.serde in StreamsConfig (#18297)
The `window.size.ms` and `window.inner.class.serde` are not a true
KafkaStreams config, and are ignored when set from a KStreams
application. Both belong on the client.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
Signed-off-by: PoAn Yang <payang@apache.org>
2025-03-31 14:15:37 +02:00
Vikas Singh 56d1dc1b6e
MINOR: Use readable interface to parse requests (#19163)
The generated request data type's constructors take Readable as an input. However, the parse method in the
AbstractRequest takes a ByteBuffer as input. So to create the corresponding request data objects, each individual
concrete Request classes wraps the ByteBuffer into a ByteBufferAccessor.

This is boilerplate code present in all the concrete request classes. This changes AbstractRequest's parse method so that subclasses can simply pass the `Readable` they get directly to request data classes.

The same change is made to the serialize method to maintain symmetry.

Reviewers: Ismael Juma <ismael@juma.me.uk>, José Armando García Sancio
<jsancio@apache.org>, Artem Livshits <alivshits@confluent.io>,
Truc Nguyen <trnguyen@confluent.io>
2025-03-26 10:13:13 -04:00
David Jacot 1ded681684
MINOR: Add 4.0.0 to streams system tests (#19239)
This patch adds 4.0.0 to streams system tests.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-03-21 01:41:09 -07:00
ClarkChen ec3c319c35
MINOR: Rewrite unchecked operations in Mock API (#19071)
We encountered unchecked or unsafe operations in
`GroupMetadataManagerTest.java`, `KTableImplTest.java`, and
`ConfigCommandIntegrationTest.java`.

* Rewrite getArgument of invocation in InvocationOnMock API because the
implementation of InvocationOnMock discards type anyway in in
`GroupMetadataManagerTest.java`.

* Remove unchecked annotations for using mock API without variable
assignment in `KTableImplTest.java`.

<img width="1422" alt="Screenshot 2025-03-02 at 8 50 55 AM"
src="https://github.com/user-attachments/assets/10ff1799-ebaa-499c-9acd-ca3b30484e6d"
/>
  
* Follow-up: https://github.com/mockito/mockito/issues/1609

Update on March 2.
* Fix unchecked cast for KTableImpl in `KTableImplTest.java`.
<img width="1259" alt="Screenshot 2025-03-02 at 5 17 47 PM"
src="https://github.com/user-attachments/assets/a5ffa3d7-4897-43ee-9b5f-26337e2560c5"
/>

Update on March 10.
* Use anyMap instead any for unchecked map type issues.
<img width="1691" alt="Screenshot 2025-03-10 at 9 36 38 AM"
src="https://github.com/user-attachments/assets/9aabc595-e7ba-4e04-81f6-f238d42af5a6"
/>

Pass all testing.
<img width="946" alt="Screenshot 2025-03-10 at 10 10 56 AM"
src="https://github.com/user-attachments/assets/793f67ea-09dc-44af-9d6c-de15531e9e72"
/>

Reviewers: TengYao Chi <kitingiao@gmail.com>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-03-18 00:47:34 +08:00
Matthias J. Sax 2181ddbb03
KAFKA-18943: Kafka Streams incorrectly commits TX during task revokation (#19164)
Fixes two issues:
 - only commit TX if no revoked tasks need to be committed
 - commit revoked tasks after punctuation triggered

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>, Anna Sophie Blee-Goldman <sophie@responsive.dev>, Bruno Cadonna <bruno@confluent.io>, Bill Bejeck <bill@confluent.io>
2025-03-13 09:37:11 -07:00
Alieh Saeedi ca834d1174
MINOR: remove incorrect deprecated annotations from internal Streams classes (#19195)
Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-03-12 17:49:00 -07:00
Bruno Cadonna 811761707c
MINOR: Downgrade log messages of swallowed exception to warnings (#19185)
Exceptions that are caught during closing a task dirty are swallowed.
The corresponding log messages are on error level which is misleading
since the exceptions do not cause any special handling or crash.

This commit downgrades the log messages of swallowed exceptions to
warnings and explains in the log messages that the exceptions are
swallowed.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-03-11 16:43:04 +01:00
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
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
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
David Arthur d86cb59790 Revert "KAFKA-18887: Implement Streams Admin APIs (#19049)"
This reverts commit 017692e86c.
2025-03-05 10:49:11 -05: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
Lucas Brutschy 295760d3eb
KAFKA-18917: TransformValues throws NPE (#19089)
When `transformValues` is used with a `Materialized` instance, but
without a queryable name, a `NullPointerException` is thrown. To
preserve the semantics present in 3.9, we need to avoid materialization
when a queryable name is not present.

Reviewers: Bruno Cadonna <cadonna@apache.org>
2025-03-04 17:49:47 +01:00
Bruno Cadonna ff94c44e70
HOTFIX: Revert "KAFKA-18067: Kafka Streams can leak Producer client under EOS (#17931)" (#19078)
This reverts commit e8837465a5.

The commit that is reverted prevents Kafka Streams from re-initializing
its transactional producer. If an exception that fences the
transactional producer occurs, the producer is not re-initialized during
the handling of the exception. That causes an infinite loop of
ProducerFencedExceptions with corresponding rebalances.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>, David Jacot
<djacot@confluent.io>
2025-03-03 11:58:56 +01:00
Janindu Pathirana 2e6e5304c0
KAFKA-18168: Adding checkpointing for GlobalKTable during restoration and closing (#18752)
To address the issue of not creating a checkpoint file during the
restoring and closing process, called the
GlobalStateUpdateTask.flushState() method in
GlobalStateUpdateTask.initialize() and GlobalStateUpdateTask.close()
methods. This will flush the state and create a checkpoint file thereby,
avoiding the need to completely restore the entire state.

Reviewers: Alieh Saeedi <asaeedi@confluent.io>, Matthias J. Sax <matthias@confluent.io>
2025-03-02 12:16:48 -08:00
A. Sophie Blee-Goldman f20f299492
KAFKA-18839: Drop EAGER rebalancing support in Kafka Streams (#18988)
In 3.1 we deprecated the eager rebalancing protocol and marked it for
removal in a later release. We aim to officially drop support and remove
the protocol from Streams in 4.0.

The effect of this PR is that it will no longer be possible to perform a
live upgrade Kafka Streams directly to 4.0 from version 2.3 or below.
Users will have to go through a bridge release between 2.4 - 3.9
instead.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-02-25 19:05:03 -08:00
Sebastien Viale 3ce5f23295
KAFKA-18023: Enforcing Explicit Naming for Kafka Streams Internal Topics (#18233)
Pull request to implement KIP-1111, aims to add a configuration that
prevents a Kafka Streams application from starting if any of its
internal topics have auto-generated names, thereby enforcing explicit
naming for all internal topics and enhancing the stability of the
application’s topology.

- Repartition Topics:

All repartition topics are created in the
KStreamImpl.createRepartitionedSource(...) static method. This method
either receives a name explicitly provided by the user or null and then
builds the final repartition topic name.

- Changelog Topics and State Store Names:

There are several scenarios where these are created:
  In the MaterializedInternal constructor.
  During KStream/KStream joins.
  During KStream/KTable joins with grace periods.
  With key-value buffers are used in suppressions.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>, Sophie Blee-Goldman <sophie@responsive.dev>
2025-02-24 11:41:42 +01:00
Sushant Mahajan 3fc103b48b
KAFKA-18629: ShareGroupDeleteState admin client impl. (#18928)
* In this PR, we add various infra classes needed to support the
`deleteShareGroups` functionality via the `kafka-share-groups.sh`
script, as well as the implementation of `kafka-share-groups.sh --delete`.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-02-22 16:21:10 +00:00
Matthias J. Sax acea35ddf3
MINOR: cleanup SinkNode generics (#18975)
Reviewers: Andrew Schofield <aschofield@confluent.io>, Bill Bejeck <bill@confluent.io>
2025-02-20 17:47:39 -08:00
Matthias J. Sax 9f23b25f6e
MINOR: fix Kafka Streams "smoke test" pass criteria (#18835)
Reviewers: Bill Bejeck <bill@confluent.io>, Bruno Cadonna <bruno@confluent.io>
2025-02-19 14:33:31 -08:00
Matthias J. Sax 538a60e1b3
MINOR: disallow rawtypes and fail build (#18877)
Cleanup code to avoid rawtype, and add suppressions where necessary.
Change the build to fail on rawtype warning.

Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Andrew Schofield <aschofield@confluent.io>
2025-02-19 13:11:49 -08:00
Matthias J. Sax 900d81b345
MINOR: cleanup top level class JavaDocs for main interfaces of Kafka Streams DSL (4/N) (#18884)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-18 16:22:18 -08:00
Matthias J. Sax 490ba8a8a3
MINOR: cleanup top level class JavaDocs for main interfaces of Kafka Streams DSL (3/N) (#18883)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-18 16:21:52 -08:00
Matthias J. Sax d6146644b3
MINOR: verify that internal StreamsConfig members are not public (#18840)
Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>
2025-02-18 16:18:29 -08:00
Matthias J. Sax 87f797811b
HOTFIX: StoreChangelogReader should require stable consumer group (#18901)
Fixing regression bug, introduced by beac86f049

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Bruno Cadonna <bruno@confluent.io>
2025-02-17 12:53:13 -08:00
Matthias J. Sax 36fd33a9d9 HOTFIX: fix broken :streams:javadocs target 2025-02-14 15:18:11 -08:00
Matthias J. Sax bcc58b4cfe
MINOR: cleanup top level class JavaDocs for main interfaces of Kafka Streams DSL (2/N) (#18882)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-14 13:47:23 -08:00
Matthias J. Sax 835d8f3097
MINOR: cleanup top level class JavaDocs for main interfaces of Kafka Streams DSL (1/N) (#18881)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-14 13:46:27 -08:00
Jimmy Wang 6a6b80215d
KAFKA-16717 [1/2]: Add AdminClient.alterShareGroupOffsets (#18819)
KAFKA-16720 aims to add the support for the AlterShareGroupOffsets AdminClient. Key Changes in the PR:

1. Added handing of alterShareGroupOffsets() in KafkaAdminClient and introduce AlterShareGroupOffsetRequest/AlterShareGroupOffsetResponse/AlterShareGroupOffsetsOptions classes.
2. Corresponding test in KafkaAdminClientTest.
3. Added ALTER_SHARE_GROUP_OFFSETS API (will finish it in next PR and the share coordinator pieces)

Reviewers: poorv Mittal <apoorvmittal10@gmail.com>, Andrew Schofield <aschofield@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
2025-02-15 02:35:46 +08:00
Bill Bejeck 3aae6f5402
MINOR: Adjust javadoc to reflect the correct status of standby task TopicPartition (#18892)
KIP-744 introduced the StreamsMetadata class as part of the implementation. In the KIP, the javadoc for the standbyTopicPartitions states that the method returns the set of source TopicPartition that it represents as a standby. The current javadoc states that it represents the changelog TopicPartition(s). While the partitions of the source and changelog topics will match, the javadoc needs to be updated to reflect the correct behavior.

Note that the deprecated o.a.k.streams.state.StreamsMetadata#standbyTopicPartitions method also describes the set of TopicPartition being source TopicPartition.

Reviewers: Matthias Sax<mjsax@apache.org>
2025-02-13 14:06:01 -05:00
Matthias J. Sax 9fbf14d544
MINOR: fix warn log message in Kafka Streams (#18878)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Bill Bejeck <bill@confluent.io>
2025-02-13 09:30:07 -08:00
Matthias J. Sax 6a050c6351
MINOR: cleanup KStream JavaDocs (14/N) - stream-globalTable-left-join (#18867)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-12 14:51:48 -08:00
Matthias J. Sax f67edf13a7
MINOR: cleanup KStream JavaDocs (13/N) - stream-stream-outer-join (#18865)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-12 13:02:01 -08:00
Matthias J. Sax ce8b08cf22
MINOR: cleanup KStream JavaDocs (12/N) - process[Values] (#18839)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-11 11:09:22 -08:00
Matthias J. Sax a6ec758488
MINOR: cleanup KStream JavaDocs (11/N) - stream-stream-left-join (#18836)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-11 10:16:28 -08:00
Kuan-Po Tseng e53af1a489
MINOR: fix KStream#to incorrect javadoc (#18838)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-02-10 22:10:36 +08:00
Matthias J. Sax 8b22f10083
MINOR: cleanup KStream JavaDocs (10/N) - stream-table-left-join (#18813)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-07 17:58:16 -08:00
Matthias J. Sax 33bba9ef4a
MINOR: cleanup KStream JavaDocs (9/N) - flatMap[Values] (#18805)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-07 14:41:03 -08:00
Matthias J. Sax 326ee368ba
MINOR: cleanup KStream JavaDocs (5/N) - stream-globalTable-inner-join (#18747)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-07 13:44:50 -08:00
Lucas Brutschy 8d294cf709 MINOR: Fix streams smoke test flush records (#18830)
In the streams smoke test, flush records that are appended to the input topics, to advance the stream time so that all suppressed windows are flushed at the end of the test. The records are created with record time equal to current time + 2 days. caf0b67 changed the broker defaults so that records more than one hour in the future are rejected by the broker. This breaks the flush messages. By moving all record time stamps 2 days into the past, the existing logic should work correctly with the new default broker configuration.

A similar thing happens in the relational smoke test, where data is emitted 4 days into the future. To avoid running into retention / compaction, the window retention time is increased for both tests.

Reviewers: Bruno Cadonna <bruno@confluent.io>, Bill Bejeck <bill@confluent.io>
2025-02-07 13:21:55 -08:00
Gyeongwon, Do 557c17bfbc
MINOR: Refactor method name for consistency (#18779)
Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-02-07 20:07:34 +00:00
Matthias J. Sax 780640f383
MINOR: cleanup KStream JavaDocs (8/N) - stream-stream-inner-join (#18761)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-06 10:58:29 -08:00
Matthias J. Sax bdab927a7d
MINOR: cleanup KStream JavaDocs (7/N) - repartition/to/toTable (#18760)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-06 10:57:54 -08:00
Steven Schlansker 852f14065b
KAFKA-18689: Improve metric calculation to avoid NoSuchElementException (#18771)
Reviewers: Nick Telford <nick.telford@gmail.com>, Matthias J. Sax <matthias@confluent.io>
2025-02-05 21:39:30 -08:00
Matthias J. Sax 9774635bfd
MINOR: update Kafka Streams `Topology` JavaDocs (#18778)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-02-05 20:24:14 -08:00
Joao Pedro Fonseca Dantas 8be2a8ed4e
MINOR: Add javadocs to AbstractMergedSortedCacheStoreIterator (#18772)
While reviewing PR #18287, I wrote some javadocs to help me understand the AbstractMergedSortedCacheStoreIterator. Maybe we could add them to help the next developers getting into it.

Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>
2025-02-05 17:20:53 -08:00
Lucas Brutschy 102de21355
KAFKA-17379: Fix inexpected state transition from ERROR to PENDING_SHUTDOWN (#18765)
The exception stack trace shown in the the ticket can happen when we are
concurrently closing the producer because of an error and doing a
regular close. This is not a bug in the test, but a real race condition
that can happen.

The sequence is this:

Thread1: Enter PENDING_ERROR
Thread2: Check if state is already ERROR
Thread1: Transition to ERROR
Thread2: Check if state is already PENDING_ERROR
Thread2: Transition to PENDING_SHUTDOWN

One idea to fix this would be to synchronize the sequence performed by
Thread1 using the state lock. However, this would require more changes,
since we cannot use the normal state transition method `setState` while
owning the lock, as it calls user-defined callbacks, which may create
deadlocks. Do avoid adding more synchronization, we can also fix it by
first attempting to transition to PENDING_SHUTDOWN, and _then_ checking
whether another thread is already attempting to shut down (states
PENDING_SHUTDOWN, PENDING_ERROR, ERROR, NOT_RUNNING). Since we never
transition from a shutdown state back to a non-shutdown state.

Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-02-05 17:09:14 +01:00
Matthias J. Sax a1d5dc0f9e HOTFIX: compilation error
Two merged PRs overlapped in a non-conflicting way, breaking compilation:
 - https://github.com/apache/kafka/pull/18722
 - https://github.com/apache/kafka/pull/18755
2025-02-04 20:32:52 -08:00
Matthias J. Sax 5988ee551e
MINOR: cleanup KStream JavaDocs (6/N) - map[Values] (#18755)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-04 19:57:59 -08:00
Matthias J. Sax 8e3a001bf5
MINOR: disable "processing threads" in SmokeTestDriverIntegrationTest (#18773)
Reviewers: Bruno Cadonna <bruno@confluent.io>
2025-02-04 09:59:14 -08:00
Matthias J. Sax 7719b5f70d
KAFKA-18644: improve generic type names for internal FK-join classes (#18700)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-03 22:20:47 -08:00
Matthias J. Sax 65961516fd
MINOR: cleanup KStream JavaDocs (4/N) - stream-table-inner-join (#18721)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>, Bill Bejeck <bill@confluent.io>
2025-02-03 17:48:49 -08:00
Matthias J. Sax b8cafbfe2d
MINOR: Session windows should accept zero as session gap (#18734)
Reviewers: Almog Gavra <almog@responsive.dev>, Anna Sophie Blee-Goldman <ableegoldman@apache.org>
2025-02-03 17:45:27 -08:00
Matthias J. Sax ce6f078192
MINOR: fix NPE in KS `Topology` for new `AutoOffsetReset` (#18780)
Introduced via KIP-1106.

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-02-03 17:24:47 -08:00
Matthias J. Sax 281a3c6a3a
MINOR: cleanup KStream JavaDocs (3/N) - groupBy[Key] (#18705)
Reviewers: Alieh Saeedi <asaeedi@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
2025-01-30 19:52:14 -08:00
Matthias J. Sax 0d1e7e04b2
KAFKA-18644: improve generic type names for KStreamImpl and KTableImpl (#18722)
Reviewers: Bill Bejeck <bill@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
2025-01-30 19:50:37 -08:00
Joao Pedro Fonseca Dantas 9980e12ce1
MINOR: remove close from contextual processors javadoc
Reviewers: Matthias J. Sax <matthias@confluent.io>
2025-01-30 11:02:07 -08:00
Matthias J. Sax ea07ff7694
MINOR: cleanup KStream JavaDocs (2/N) - print/foreach/peek/split/merge (#18704)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-01-30 09:32:57 -08:00
Matthias J. Sax a916a1db82
MINOR: cleanup KStream JavaDocs (1/N) - filter[Not]/selectKey (#18703)
Reviewers: Alieh Saeedi <asaeedi@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
2025-01-30 09:31:47 -08:00
Matthias J. Sax 1123a76110
KAFKA-13722: remove internal usage of old ProcessorContext (#18698)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-01-29 11:13:57 -08:00
Bill Bejeck 20b073bbee
KAFKA-18498: Update lock ownership from main thread (#18732)
Once a StreamThread receives its assignment, it will close the startup tasks. But during the closing process, the StandbyTask.closeClean() method will eventually call theStatemanagerUtil.closeStateManager method which needs to lock the state directory, but locking requires the calling thread be the current owner. Since the main thread grabs the lock on startup but moves on without releasing it, we need to update ownership explicitly here in order for the stream thread to close the startup task and begin processing.

Reviewers: Matthias Sax <mjsax@apache.org>, Nick Telford
2025-01-29 14:09:44 -05:00
Matthias J. Sax dc396f47e8
KAFKA-17162: join() started thread in DefaultTaskManagerTest (#18570)
Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
2025-01-27 16:48:07 -08:00
Matthias J. Sax ee4f8f8c42
KAFKA-18541: fix flaky KafkaStreamsTelemetryIntegrationTest (#18569)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-27 09:43:25 -08:00
Matthias J. Sax f13a22af0b
KAFKA-13722: remove usage of old ProcessorContext (#18292)
We want to deprecate an remove the old ProcessorContext. Thus, we need
to refactor Kafka Streams runtime code, to not make calls into the old
ProcessorContext but only into new code path.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-24 10:31:31 -08:00
Matthias J. Sax ad79b4afa7
MINOR: cleanup ProcessorContextImplTest (#18682)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-23 17:27:14 -08:00
Matthias J. Sax f2f9e84bca
KAFKA-17402: DefaultStateUpdated should transite task atomically (#18607)
Reviewers: Bruno Cadonna <bruno@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
2025-01-21 12:33:48 -08:00
Matthias J. Sax faff2de6a5
KAFKA-17561: add processId tag to thread-state metric (#18581)
Part of KIP-1091.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-21 08:09:43 -08:00
Sanskar Jhajharia bcbc72e29b
[KAFKA-16720] AdminClient Support for ListShareGroupOffsets (1/n) (#18571)
Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Andrew Schofield <aschofield@confluent.io>
2025-01-20 07:47:14 +00:00
Matthias J. Sax 07c860b730
MINOR: change warning suppression in RocksDBTimeOrderedKeyValueBufferTest (#18580)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Mickael Maison <mickael.maison@gmail.com>
2025-01-16 12:59:01 -08:00
Jason Taylor 23c459286b
KAFKA-16368: Update defaults for LOG_MESSAGE_TIMESTAMP_AFTER_MAX_MS_DEFAULT and NUM_RECOVERY_THREADS_PER_DATA_DIR_CONFIG (#18106)
Reviewers: Divij Vaidya <diviv@amazon.com>
2025-01-16 15:30:00 +01:00
A. Sophie Blee-Goldman c7d3999d4f
KAFKA-18026: KIP-1112, clean up graph node grace period resolution (#18342)
Minor followup to #18195 that I split out into a separate PR since that one was getting a bit long. Should be rebased & reviewed after that one is merged.

Introduces a new class for windowed graph nodes with a grace period defined to improve (slightly) the type safety

Reviewers: Guozhang Wang <guozhang.wang.us@gmail.com>, Almog Gavra <almog@responsive.dev>
2025-01-15 18:01:19 -08:00
Matthias J. Sax 0bc770d7b6
MINOR: avoid WARN logs in KafkaStreams test (#18517)
Avoiding 'WARN Method #getTimestampedKeyValueStore() should be
used to access a TimestampedKeyValueStore.' running
KTableKTableForeignKeyJoinIntegrationTest.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-15 14:08:55 -08:00
Matthias J. Sax 3f3bc90509
MINOR: Kafka Streams doc updates for 4.0 release (#18488)
Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-15 11:58:53 -08:00
Matthias J. Sax 30f94b5320
KAFKA-18479: RocksDBTimeOrderedKeyValueBuffer not initialized correctly (#18490)
RocksDBTimeOrderedKeyValueBuffer is not initialize with serdes provides
via Joined, but always uses serdes from StreamsConfig.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-15 10:04:13 -08:00
Alieh Saeedi 512e0c9628
MINOR: remove old comment in streams StateDirectory (#18546)
Reviewers: Bruno Cadonna <cadonna@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
2025-01-16 01:07:55 +08:00
Matthias J. Sax 1672a4bc27
KAFKA-18476: KafkaStreams should swallow TransactionAbortedException (#18487)
TransactionAbortedException is a follow up error to a previous error,
and such a previous error would already be handled when
`producer.abortTransaction()` is called. Thus, a
TransactionAbortedException can just be silently swallowed.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-01-14 18:03:14 -08:00
A. Sophie Blee-Goldman faef80a2e2
KAFKA-18026: KIP-1112, clean up StatefulProcessorNode (#18195)
Final cleanup of StatefulProcessorNode after converting all stateful operators to adding state stores via implementing the #stores method.
2025-01-14 17:42:58 -08:00
Matthias J. Sax 0e831d0840
KAFKA-8116: Update Kafka Streams archetype for Java 11 (#18471)
Reviewers: Ismael Juma <ismael@juma.me.uk>, Bill Bejeck <bill@confluent.io>
2025-01-10 15:45:39 -08:00
Almog Gavra 2a0c31e768
MINOR: improve StreamThread periodic processing log (#18430)
The current log is really helpful, this PR adds a bit more information to that log to help debug some issues. In particular, it is interesting to be able to debug situations that have long intervals between polls. It also includes a reference to how long it has been since it last logged so you don't have to find the previous time it was logged to compute quick per-second ratios.

Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>
2025-01-09 11:01:43 -08:00
Ao Li ebe7dd2b15
KAFKA-18418: Use CDL to block the thread termination to avoid flaky tests (#18418)
This PR fixed a race-condition in KafkaStreamsTest, by replacing a non-deterministic
sleep with a CountDownLatch to fully control how long a thread blocks.

Reviewers:  David Arthur <mumrah@gmail.com>, Matthias J. Sax <matthias@confluent.io>
2025-01-09 10:19:40 -08:00