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

timeout <= 0 not working for deleteTopics function #1128

Closed
aditya81070 opened this issue Jun 17, 2021 · 3 comments · Fixed by #1427
Closed

timeout <= 0 not working for deleteTopics function #1128

aditya81070 opened this issue Jun 17, 2021 · 3 comments · Fixed by #1427

Comments

@aditya81070
Copy link

Describe the bug
In the deleteTopics docs, the description for timeout field is missing. It only says it is a number. There is no clear description of whether it is the max time taken in deleting all topics or the timeout of sending a deletion request (connecting to broker and all).

To find out, how this timeout is working under the hood, I jumped into the code and found that admin.deleteTopics is calling broker.deleteTopics under the hood and it has this doc (jsdocs comments). According to this doc, if timeout <= 0 then it will trigger the topic deletion and will return but when I provide timeout value as 0 or 1, it throws REQUEST_TIMED_OUT error.

Are these comments up to date? If no, is there any way I can trigger topic deletion asynchronously?

The asynchronous part is important for some applications. In my case, I am writing a scheduler that will clean up stale topics daily (a lambda function) but I don't want to pay for lambda execution time until all topics are deleted. I just want to send an async deletion request and if something goes wrong, I will pick those topics in the next run.

To Reproduce
Please provide either a link to a:

  1. [failing test in a KafkaJS fork]
    Sorry, I am not running KafkaJS locally.
  2. [repository with an example project reproducing the issue]
    Not possible

If none of the above is possible to provide, please write down the exact steps to reproduce the behavior:

  1. Create a Kafka client.
  2. Create an admin using const admin = client.admin() and connect to the admin using await admin.connect().
  3. Call await admin.deleteTopics({topics: ['an-existing-topic'], timeout: 0 or -1}).

Expected behavior
The delete request should be sent successfully and I should get an ok response from deleteTopics call.

Observed behavior
The request failed with the REQUEST_TIMED_OUT exception when passing timeout as <= 0 value.

Environment:

  • OS: MacOS 11.4
  • KafkaJS version: 1.14.0
  • Kafka version: 2.7.0
  • NodeJS: node:12.13.1
@tulios
Copy link
Owner

tulios commented Jun 17, 2021

Hi @aditya81070 , the comments are correct. I think this is a bug, the protocol layer for deleteTopics is probably not taking this scenario in consideration.

@aditya81070
Copy link
Author

@tulios Thanks for quick response. Are there any plans to fix this one in upcoming release?
If it is a easy fix , I can raise a PR. I went deep down in the code to the some Encoder thing but couldn't understand fully. Some guidance on this will be helpful.

@Nevon
Copy link
Collaborator

Nevon commented Jul 26, 2022

I wasn't able to find any mention of timeout values <= 0 making topic deletion async. There's no KIP mentioning it and nothing in the Java client docs or anywhere else, so I think this is incorrect. I'm removing that comment in #1427 and updating the docs to include the default value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants