You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2024/03/23 03:01:19 UTC
[PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
FrankYang0529 opened a new pull request, #15586:
URL: https://github.com/apache/kafka/pull/15586
When an exception is thrown in kafka-delete-records, it propagates through `main` to the JVM, producing the following message:
```
bin/kafka-delete-records.sh --bootstrap-server localhost:9092 --offset-json-file /tmp/does-not-exist
Exception in thread "main" java.io.IOException: Unable to read file /tmp/does-not-exist
at org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:787)
at org.apache.kafka.tools.DeleteRecordsCommand.execute(DeleteRecordsCommand.java:105)
at org.apache.kafka.tools.DeleteRecordsCommand.main(DeleteRecordsCommand.java:64)
Caused by: java.nio.file.NoSuchFileException: /tmp/does-not-exist
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
at java.base/java.nio.file.Files.newByteChannel(Files.java:432)
at java.base/java.nio.file.Files.readAllBytes(Files.java:3288)
at org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:784)
... 2 more
```
This is in contrast to the error handling used in other tools, such as the kafka-log-dirs:
```
bin/kafka-log-dirs.sh --bootstrap-server localhost:9092 --describe --command-config /tmp/does-not-exist
/tmp/does-not-exist
java.nio.file.NoSuchFileException: /tmp/does-not-exist
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
at java.base/java.nio.file.Files.newByteChannel(Files.java:432)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:422)
at java.base/java.nio.file.Files.newInputStream(Files.java:160)
at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:686)
at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:673)
at org.apache.kafka.tools.LogDirsCommand.createAdminClient(LogDirsCommand.java:149)
at org.apache.kafka.tools.LogDirsCommand.execute(LogDirsCommand.java:68)
at org.apache.kafka.tools.LogDirsCommand.mainNoExit(LogDirsCommand.java:54)
at org.apache.kafka.tools.LogDirsCommand.main(LogDirsCommand.java:49)
```
After the fix, the error from kafka-delete-records will be like:
```
Unable to read file /tmp/does-not-exist
java.io.IOException: Unable to read file /tmp/does-not-exist
at org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:787)
at org.apache.kafka.tools.DeleteRecordsCommand.execute(DeleteRecordsCommand.java:117)
at org.apache.kafka.tools.DeleteRecordsCommand.mainNoExit(DeleteRecordsCommand.java:70)
at org.apache.kafka.tools.DeleteRecordsCommand.main(DeleteRecordsCommand.java:65)
Caused by: java.nio.file.NoSuchFileException: /tmp/does-not-exist
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
at java.base/java.nio.file.Files.newByteChannel(Files.java:432)
at java.base/java.nio.file.Files.readAllBytes(Files.java:3288)
at org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:784)
... 3 more
```
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #15586:
URL: https://github.com/apache/kafka/pull/15586#issuecomment-2018334375
> Failed with the same error again. Please help fix the errors. Thanks.
Sorry, I will double check test result before creating a PR next time. I have updated the case. Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #15586:
URL: https://github.com/apache/kafka/pull/15586#issuecomment-2019187474
Failed tests are unrelated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon merged PR #15586:
URL: https://github.com/apache/kafka/pull/15586
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #15586:
URL: https://github.com/apache/kafka/pull/15586#issuecomment-2017024206
@FrankYang0529 , have you confirmed all DeleteRecordsCommand-tests passed in your local env? In the 1st run, all 4 CI jobs failed with exit code 1. I've re-run it. But it'd be good if you could verify them first in local env.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16409: DeleteRecordsCommand should use standard exception handling [kafka]
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #15586:
URL: https://github.com/apache/kafka/pull/15586#issuecomment-2017555528
Failed with the same error again. Please help fix the errors. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org