Skip to content

Commit 2d94927

Browse files
committed
Merge remote-tracking branch 'apache-github/trunk' into kip-896-remove-old-protocol-versions
* apache-github/trunk: (25 commits) KAFKA-18270: FindCoordinator v0 incorrectly tagged as deprecated (apache#18262) KAFKA-18284: Add group coordinator records for Streams rebalance protocol (apache#18228) MINOR: Fix flaky state updater test (apache#18253) MINOR: improve StreamsResetter logging (apache#18237) KAFKA-18227: Ensure v2 partitions are not added to last transaction during upgrade (apache#18176) Add IT for share consumer with duration base offet auto reset (apache#18251) KAFKA-18283: Add StreamsGroupDescribe RPC definitions (apache#18230) KAFKA-18241: add docs check to CI (apache#18183) KAFKA-18223 Improve flaky test report (apache#18212) MINOR Remove triage label in nightly job (apache#18147) KAFKA-18294 Remove deprecated SourceTask#commitRecord (apache#18260) KAFKA-18264 Remove NotLeaderForPartitionException (apache#18211) KAFKA-13722: Refactor SerdeGetter (apache#18242) KAFKA-18094 Remove deprecated TopicListing(String, Boolean) (apache#18248) KAFKA-18282: Add StreamsGroupHeartbeat RPC definitions (apache#18227) KAFKA-18026: KIP-1112 migrate KTableSuppressProcessorSupplier (apache#18150) KAFKA-18026: transition KTable#filter impl to use processor wrapper (apache#18205) KAFKA-18293 Remove `org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler` and `org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerValidatorCallbackHandler` (apache#18244) MINOR: add assertion about groupEpoch and targetAssignmentEpoch to testConsumerGroups (apache#18203) KAFKA-17960; PlaintextAdminIntegrationTest.testConsumerGroups fails with CONSUMER group protocol (apache#18234) ...
2 parents dd86056 + 22d1ba8 commit 2d94927

File tree

92 files changed

+2155
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2155
-516
lines changed

.github/scripts/develocity_reports.py

Lines changed: 280 additions & 160 deletions
Large diffs are not rendered by default.

.github/workflows/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ Unlike trunk, the PR builds _will_ utilize the Gradle cache.
6767
### PR Triage
6868

6969
In order to get the attention of committers, we have a triage workflow for Pull Requests
70-
opened by non-committers. This workflow consists of three files:
70+
opened by non-committers. This workflow consists of two files:
7171

72-
* [pr-update.yml](pr-update.yml) When a PR is created add the `triage` label if the PR
72+
* [pr-update.yml](pr-update.yml) When a PR is created, add the `triage` label if the PR
7373
was opened by a non-committer.
74-
* [pr-reviewed-trigger.yml](pr-reviewed-trigger.yml) Runs when any PR is reviewed.
75-
Used as a trigger for the next workflow
76-
* [pr-reviewed.yml](pr-reviewed.yml) Remove the `triage` label after a PR has been reviewed
74+
* [pr-reviewed.yml](pr-reviewed.yml) Cron job to remove the `triage` label from PRs which have been reviewed
7775

7876
_The pr-update.yml workflow includes pull_request_target!_
7977

@@ -100,7 +98,7 @@ There are two files related to this workflow:
10098

10199
* [pr-labeled.yml](pr-labeled.yml) approves a pending approval for PRs that have
102100
been labeled with `ci-approved`
103-
* [ci-requested.yml](ci-requested.yml) approves future CI requests automatically
101+
* [ci-requested.yml](ci-requested.yml) approves future workflow requests automatically
104102
if the PR has the `ci-approved` label
105103

106104
_The pr-labeled.yml workflow includes pull_request_target!_

.github/workflows/build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
# --scan: Publish the build scan. This will only work on PRs from apache/kafka and trunk
118118
# --no-scan: For public fork PRs, we won't attempt to publish the scan
119119
run: |
120-
./gradlew --build-cache --info $SCAN_ARG check -x test
120+
./gradlew --build-cache --info $SCAN_ARG check siteDocTar -x test
121121
- name: Archive check reports
122122
if: always()
123123
uses: actions/upload-artifact@v4
@@ -137,6 +137,16 @@ jobs:
137137
run: python .github/scripts/rat.py
138138
env:
139139
GITHUB_WORKSPACE: ${{ github.workspace }}
140+
- name: Check generated documentation
141+
# Check if there are any empty files under ./site-docs/generated, If any empty files are found, print an error
142+
# message and list the empty files
143+
run: |
144+
tar zxvf core/build/distributions/kafka_2.13-$(./gradlew properties | grep version: | awk '{print $NF}' | head -n 1)-site-docs.tgz
145+
if find ./site-docs/generated -type f -exec grep -L "." {} \; | grep -q "."; then
146+
echo "One or more documentation files are empty!" >&2
147+
find ./site-docs/generated -type f -exec grep -L "." {} \; >&2
148+
exit 1
149+
fi
140150
141151
test:
142152
needs: [validate, load-catalog]

.github/workflows/generate-reports.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ on:
2020
schedule:
2121
- cron: '0 6 * * *' # Run daily at 6am UTC
2222

23-
2423
jobs:
2524
flaky-test-report:
2625
name: Flaky Test Report
@@ -38,6 +37,6 @@ jobs:
3837
uses: ./.github/actions/setup-python
3938
- name: Run Report
4039
env:
41-
GE_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }}
40+
DEVELOCITY_ACCESS_TOKEN: ${{ secrets.DV_API_ACCESS }}
4241
run: |
43-
python ./.github/scripts/develocity_reports.py >> $GITHUB_STEP_SUMMARY
42+
python ./.github/scripts/develocity_reports.py >> $GITHUB_STEP_SUMMARY

.github/workflows/pr-reviewed-trigger.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/pr-reviewed.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,48 @@
1616
name: Remove Triage Label
1717

1818
on:
19-
workflow_run:
20-
workflows: [Pull Request Reviewed]
21-
types:
22-
- completed
19+
workflow_dispatch: # Let us run manually
20+
21+
schedule:
22+
- cron: '0 3 * * *' # Run at 3:00 UTC nightly -- just before the "stale.yml" workflow
2323

2424
jobs:
25-
# This job runs with elevated permissions and the ability to modify pull requests. The steps taken here
26-
# should be limited to updating labels and adding comments to PRs. This approach is taken from
27-
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/.
2825
remove-triage:
29-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
3026
runs-on: ubuntu-latest
3127
steps:
3228
- name: Env
3329
run: printenv
3430
env:
3531
GITHUB_CONTEXT: ${{ toJson(github) }}
36-
- uses: actions/download-artifact@v4
37-
with:
38-
github-token: ${{ github.token }}
39-
run-id: ${{ github.event.workflow_run.id }}
40-
name: pr-number.txt
4132
- name: Remove label
4233
uses: actions/github-script@v7
4334
continue-on-error: true
4435
with:
4536
github-token: ${{ secrets.GITHUB_TOKEN }}
4637
script: |
47-
var fs = require('fs');
48-
var pr_number = Number(fs.readFileSync('./pr-number.txt'));
49-
await github.rest.issues.removeLabel({
50-
owner: context.repo.owner,
51-
repo: context.repo.repo,
52-
issue_number: pr_number,
53-
name: 'triage'
38+
github.paginate("GET /search/issues{?q}", {
39+
q: "repo:apache/kafka label:triage is:pull-request"
40+
})
41+
.then((pulls) => {
42+
pulls.forEach(pull => {
43+
github.request("GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews", {
44+
owner: "apache",
45+
repo: "kafka",
46+
pull_number: pull.number,
47+
headers: {
48+
"X-GitHub-Api-Version": "2022-11-28"
49+
}
50+
}).then((resp) => {
51+
console.log("Found " + resp.data.length + " reviews for PR " + pull.number);
52+
if (resp.data.length > 0) {
53+
console.log("Removing 'triage' label from PR " + pull.number + " : " + pull.title);
54+
github.rest.issues.removeLabel({
55+
owner: "apache",
56+
repo: "kafka",
57+
issue_number: pull.number,
58+
name: "triage"
59+
});
60+
}
61+
});
62+
});
5463
});

clients/src/main/java/org/apache/kafka/clients/admin/TopicListing.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ public class TopicListing {
2727
private final Uuid topicId;
2828
private final boolean internal;
2929

30-
/**
31-
* Create an instance with the specified parameters.
32-
*
33-
* @param name The topic name
34-
* @param internal Whether the topic is internal to Kafka
35-
* @deprecated Since 3.0 use {@link #TopicListing(String, Uuid, boolean)} instead
36-
*/
37-
@Deprecated
38-
public TopicListing(String name, boolean internal) {
39-
this.name = name;
40-
this.internal = internal;
41-
this.topicId = Uuid.ZERO_UUID;
42-
}
43-
4430
/**
4531
* Create an instance with the specified parameters.
4632
*

clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ public void initTransactions() {
665665
sender.wakeup();
666666
result.await(maxBlockTimeMs, TimeUnit.MILLISECONDS);
667667
producerMetrics.recordInit(time.nanoseconds() - now);
668+
transactionManager.maybeUpdateTransactionV2Enabled(true);
668669
}
669670

670671
/**

clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private boolean isTransitionValid(State source, State target) {
211211
case UNINITIALIZED:
212212
return source == READY || source == ABORTABLE_ERROR;
213213
case INITIALIZING:
214-
return source == UNINITIALIZED || source == ABORTING_TRANSACTION;
214+
return source == UNINITIALIZED || source == COMMITTING_TRANSACTION || source == ABORTING_TRANSACTION;
215215
case READY:
216216
return source == INITIALIZING || source == COMMITTING_TRANSACTION || source == ABORTING_TRANSACTION;
217217
case IN_TRANSACTION:
@@ -312,7 +312,6 @@ public synchronized void beginTransaction() {
312312
throwIfPendingState("beginTransaction");
313313
maybeFailWithError();
314314
transitionTo(State.IN_TRANSACTION);
315-
maybeUpdateTransactionV2Enabled();
316315
}
317316

318317
public synchronized TransactionalRequestResult beginCommit() {
@@ -348,10 +347,17 @@ private TransactionalRequestResult beginCompletingTransaction(TransactionResult
348347
isTransactionV2Enabled
349348
);
350349

350+
// Maybe update the transaction version here before we enqueue the EndTxn request so there are no races with
351+
// completion of the EndTxn request. Since this method may update clientSideEpochBumpRequired, we want to update
352+
// before the check below, but we also want to call it after the EndTxnRequest.Builder so we complete the transaction
353+
// with the same version as it started.
354+
maybeUpdateTransactionV2Enabled(false);
355+
351356
EndTxnHandler handler = new EndTxnHandler(builder);
352357
enqueueRequest(handler);
353358

354359
// If an epoch bump is required for recovery, initialize the transaction after completing the EndTxn request.
360+
// If we are upgrading to TV2 transactions on the next transaction, also bump the epoch.
355361
if (clientSideEpochBumpRequired) {
356362
return initializeTransactions(this.producerIdAndEpoch);
357363
}
@@ -437,15 +443,25 @@ public boolean isTransactional() {
437443
return transactionalId != null;
438444
}
439445

440-
// Check all the finalized features from apiVersions to whether the transaction V2 is enabled.
441-
public synchronized void maybeUpdateTransactionV2Enabled() {
446+
/**
447+
* Check all the finalized features from apiVersions to verify whether the transaction V2 is enabled.
448+
* Sets clientSideEpochBumpRequired if upgrading to V2 since we need to bump the epoch.
449+
* This is because V2 no longer adds partitions explicitly and there are some edge cases on upgrade
450+
* that can be avoided by fencing the old V1 transaction epoch. For example, we won't consider
451+
* partitions from the previous transaction as already added to the new V2 transaction if the epoch is fenced.
452+
*/
453+
454+
public synchronized void maybeUpdateTransactionV2Enabled(boolean onInitiatialization) {
442455
if (latestFinalizedFeaturesEpoch >= apiVersions.getMaxFinalizedFeaturesEpoch()) {
443456
return;
444457
}
445458
ApiVersions.FinalizedFeaturesInfo info = apiVersions.getFinalizedFeaturesInfo();
446459
latestFinalizedFeaturesEpoch = info.finalizedFeaturesEpoch;
447460
Short transactionVersion = info.finalizedFeatures.get("transaction.version");
461+
boolean wasTransactionV2Enabled = isTransactionV2Enabled;
448462
isTransactionV2Enabled = transactionVersion != null && transactionVersion >= 2;
463+
if (!onInitiatialization && !wasTransactionV2Enabled && isTransactionV2Enabled)
464+
clientSideEpochBumpRequired = true;
449465
}
450466

451467
public boolean isTransactionV2Enabled() {
@@ -1652,6 +1668,8 @@ public void handleResponse(AbstractResponse response) {
16521668
// When Transaction Version 2 is enabled, the end txn request 5+ is used,
16531669
// it mandates bumping the epoch after every transaction.
16541670
// If the epoch overflows, a new producerId is returned with epoch set to 0.
1671+
// Note, we still may see EndTxn TV1 (< 5) responses when the producer has upgraded to TV2 due to the upgrade
1672+
// occurring at the end of beginCompletingTransaction. The next transaction started should be TV2.
16551673
if (endTxnResponse.data().producerId() != -1) {
16561674
ProducerIdAndEpoch producerIdAndEpoch = new ProducerIdAndEpoch(
16571675
endTxnResponse.data().producerId(),

clients/src/main/java/org/apache/kafka/common/errors/NotLeaderForPartitionException.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)