Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-17593; [7/N] Introduce CoordinatorExecutor #17823

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

dajac
Copy link
Contributor

@dajac dajac commented Nov 15, 2024

This patch introduces the CoordinatorExecutor construct into the CoordinatorRuntime. It allows scheduling asynchronous tasks from within a CoordinatorShard while respecting the runtime semantic. It will be used to asynchronously resolve regular expressions.

The GroupCoordinatorService uses a default ExecutorService with a single thread to back it at the moment. It seems that it should be sufficient. In the future, we could consider making the number of threads configurable.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@dajac dajac added the KIP-848 The Next Generation of the Consumer Rebalance Protocol label Nov 15, 2024
@github-actions github-actions bot added the KIP-932 Queues for Kafka label Nov 15, 2024
@dajac dajac removed the KIP-932 Queues for Kafka label Nov 15, 2024
@github-actions github-actions bot added the KIP-932 Queues for Kafka label Nov 15, 2024
@@ -642,6 +664,7 @@ public void testScheduleLoading() {
when(builder.withTimer(any())).thenReturn(builder);
when(builder.withCoordinatorMetrics(any())).thenReturn(builder);
when(builder.withTopicPartition(any())).thenReturn(builder);
when(builder.withExecutor(any())).thenReturn(builder);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, i'll refactor those tests in a separate PR. i'll also so some cleanups.

@AndrewJSchofield
Copy link
Collaborator

@smjn fyi. Potentially this is useful for the record deletion work that you're doing.

Copy link
Contributor

@lianetm lianetm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dajac , took a first pass to non-testing files.

Comment on lines +80 to +83
if (tasks.containsKey(key)) return false;

// We use the task as a lock for the key.
tasks.put(key, task);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about

Suggested change
if (tasks.containsKey(key)) return false;
// We use the task as a lock for the key.
tasks.put(key, task);
if (tasks.putIfAbsent(key, task) != null) return false;

// that the task was either replaced or cancelled. We stop.
if (tasks.get(key) != task) return;

// Executor the task.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Executor the task.
// Execute the task.

return operation.onComplete(result.result, result.exception);
}
).exceptionally(exception -> {
if (exception instanceof NotCoordinatorException || exception instanceof CoordinatorLoadInProgressException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we end up here due to a failure on scheduling the write op, without having removed the task? (ln 102). Wondering if we need to remove it here too to clean up.

}

/**
* Schedule an asynchronous tasks. Note that only one task for a given key can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Schedule an asynchronous tasks. Note that only one task for a given key can
* Schedule an asynchronous task. Note that only one task for a given key can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIP-848 The Next Generation of the Consumer Rebalance Protocol KIP-932 Queues for Kafka
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants