You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/11/22 05:25:30 UTC
[GitHub] [bookkeeper] equanz opened a new pull request, #3663: Exit bookkeeper shell correctly even if fails to run for some reason
equanz opened a new pull request, #3663:
URL: https://github.com/apache/bookkeeper/pull/3663
### Motivation
When I run `bookkeeper shell listledgers` command and get exception like the below, the shell process doesn't exit forever. I expect shell processes will exit soon.
```
...
06:00:02.801 [main-EventThread] ERROR o.a.b.t.c.c.b.ListLedgersCommand - Unable to read the ledger: 15256124 information
06:00:02.805 [main-EventThread] ERROR o.a.b.p.BookkeeperInternalCallbacks - Error in multi callback : -25
06:00:02.807 [main] ERROR o.a.b.t.c.c.b.ListLedgersCommand - Received error return value while processing ledgers: -1
06:00:02.810 [main] ERROR o.a.b.t.c.c.b.ListLedgersCommand - Received Exception while processing ledgers
org.apache.bookkeeper.client.BKException$BKReadException: Error while reading ledger
at org.apache.bookkeeper.client.BKException.create(BKException.java:62)
at org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand.lambda$handler$3(ListLedgersCommand.java:176)
at org.apache.bookkeeper.meta.MetadataDrivers.lambda$runFunctionWithLedgerManagerFactory$2(MetadataDrivers.java:389)
at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithMetadataBookieDriver(MetadataDrivers.java:347)
at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithLedgerManagerFactory(MetadataDrivers.java:387)
at org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand.handler(ListLedgersCommand.java:127)
at org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand.apply(ListLedgersCommand.java:99)
at org.apache.bookkeeper.bookie.BookieShell$ListLedgersCmd.runCmd(BookieShell.java:704)
at org.apache.bookkeeper.bookie.BookieShell$MyCommand.runCmd(BookieShell.java:236)
at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:2235)
at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:2326)
...
```
I encountered the issue in the v4.12.0 client.
### Changes
* Close legacyLM and longLM if call HierarchicalLedgerManager#close
- legacyLM and longLM have [inner scheduler](https://github.com/apache/bookkeeper/blob/e4ef0ef7f4f989e46f854c92ac7684325f050a60/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java#L87). In this case, these schedulers are not shut down.
* Exit as ok when calling listledgers command and get NoSuchLedgerExistsOnMetadataServerException
* Call `System.exit` even if get some exception in bookkeeler shell
--
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: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] nicoloboschi closed pull request #3663: Exit bookkeeper shell correctly even if fails to run for some reason
Posted by GitBox <gi...@apache.org>.
nicoloboschi closed pull request #3663: Exit bookkeeper shell correctly even if fails to run for some reason
URL: https://github.com/apache/bookkeeper/pull/3663
--
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: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] nicoloboschi commented on a diff in pull request #3663: Exit bookkeeper shell correctly even if fails to run for some reason
Posted by GitBox <gi...@apache.org>.
nicoloboschi commented on code in PR #3663:
URL: https://github.com/apache/bookkeeper/pull/3663#discussion_r1032093192
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java:
##########
@@ -2397,50 +2397,56 @@ public int compare(File file1, File file2) {
}
}
- public static void main(String[] argv) throws Exception {
- BookieShell shell = new BookieShell();
-
- // handle some common options for multiple cmds
- Options opts = new Options();
- opts.addOption(CONF_OPT, true, "configuration file");
- opts.addOption(LEDGERID_FORMATTER_OPT, true, "format of ledgerId");
- opts.addOption(ENTRY_FORMATTER_OPT, true, "format of entries");
- BasicParser parser = new BasicParser();
- CommandLine cmdLine = parser.parse(opts, argv, true);
-
- // load configuration
- CompositeConfiguration conf = new CompositeConfiguration();
- if (cmdLine.hasOption(CONF_OPT)) {
- String val = cmdLine.getOptionValue(CONF_OPT);
- conf.addConfiguration(new PropertiesConfiguration(
- new File(val).toURI().toURL()));
- }
- shell.setConf(conf);
-
- // ledgerid format
- if (cmdLine.hasOption(LEDGERID_FORMATTER_OPT)) {
- String val = cmdLine.getOptionValue(LEDGERID_FORMATTER_OPT);
- shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(val, shell.bkConf);
- } else {
- shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(shell.bkConf);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using ledgerIdFormatter {}", shell.ledgerIdFormatter.getClass());
- }
+ public static void main(String[] argv) {
+ int res = -1;
+ try {
+ BookieShell shell = new BookieShell();
- // entry format
- if (cmdLine.hasOption(ENTRY_FORMATTER_OPT)) {
- String val = cmdLine.getOptionValue(ENTRY_FORMATTER_OPT);
- shell.entryFormatter = EntryFormatter.newEntryFormatter(val, shell.bkConf);
- } else {
- shell.entryFormatter = EntryFormatter.newEntryFormatter(shell.bkConf);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using entry formatter {}", shell.entryFormatter.getClass());
- }
+ // handle some common options for multiple cmds
+ Options opts = new Options();
+ opts.addOption(CONF_OPT, true, "configuration file");
+ opts.addOption(LEDGERID_FORMATTER_OPT, true, "format of ledgerId");
+ opts.addOption(ENTRY_FORMATTER_OPT, true, "format of entries");
+ BasicParser parser = new BasicParser();
+ CommandLine cmdLine = parser.parse(opts, argv, true);
+
+ // load configuration
+ CompositeConfiguration conf = new CompositeConfiguration();
+ if (cmdLine.hasOption(CONF_OPT)) {
+ String val = cmdLine.getOptionValue(CONF_OPT);
+ conf.addConfiguration(new PropertiesConfiguration(
+ new File(val).toURI().toURL()));
+ }
+ shell.setConf(conf);
- int res = shell.run(cmdLine.getArgs());
- System.exit(res);
+ // ledgerid format
+ if (cmdLine.hasOption(LEDGERID_FORMATTER_OPT)) {
+ String val = cmdLine.getOptionValue(LEDGERID_FORMATTER_OPT);
+ shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(val, shell.bkConf);
+ } else {
+ shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(shell.bkConf);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using ledgerIdFormatter {}", shell.ledgerIdFormatter.getClass());
+ }
+
+ // entry format
+ if (cmdLine.hasOption(ENTRY_FORMATTER_OPT)) {
+ String val = cmdLine.getOptionValue(ENTRY_FORMATTER_OPT);
+ shell.entryFormatter = EntryFormatter.newEntryFormatter(val, shell.bkConf);
+ } else {
+ shell.entryFormatter = EntryFormatter.newEntryFormatter(shell.bkConf);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using entry formatter {}", shell.entryFormatter.getClass());
+ }
+
+ res = shell.run(cmdLine.getArgs());
+ } catch (Exception e) {
Review Comment:
```suggestion
} catch (Throwable e) {
```
otherwise in case of unchecked exceptions the user won't get the stacktrace
--
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: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] nicoloboschi merged pull request #3663: Exit bookkeeper shell correctly even if fails to run for some reason
Posted by GitBox <gi...@apache.org>.
nicoloboschi merged PR #3663:
URL: https://github.com/apache/bookkeeper/pull/3663
--
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: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] equanz commented on a diff in pull request #3663: Exit bookkeeper shell correctly even if fails to run for some reason
Posted by GitBox <gi...@apache.org>.
equanz commented on code in PR #3663:
URL: https://github.com/apache/bookkeeper/pull/3663#discussion_r1032131218
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java:
##########
@@ -2397,50 +2397,56 @@ public int compare(File file1, File file2) {
}
}
- public static void main(String[] argv) throws Exception {
- BookieShell shell = new BookieShell();
-
- // handle some common options for multiple cmds
- Options opts = new Options();
- opts.addOption(CONF_OPT, true, "configuration file");
- opts.addOption(LEDGERID_FORMATTER_OPT, true, "format of ledgerId");
- opts.addOption(ENTRY_FORMATTER_OPT, true, "format of entries");
- BasicParser parser = new BasicParser();
- CommandLine cmdLine = parser.parse(opts, argv, true);
-
- // load configuration
- CompositeConfiguration conf = new CompositeConfiguration();
- if (cmdLine.hasOption(CONF_OPT)) {
- String val = cmdLine.getOptionValue(CONF_OPT);
- conf.addConfiguration(new PropertiesConfiguration(
- new File(val).toURI().toURL()));
- }
- shell.setConf(conf);
-
- // ledgerid format
- if (cmdLine.hasOption(LEDGERID_FORMATTER_OPT)) {
- String val = cmdLine.getOptionValue(LEDGERID_FORMATTER_OPT);
- shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(val, shell.bkConf);
- } else {
- shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(shell.bkConf);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using ledgerIdFormatter {}", shell.ledgerIdFormatter.getClass());
- }
+ public static void main(String[] argv) {
+ int res = -1;
+ try {
+ BookieShell shell = new BookieShell();
- // entry format
- if (cmdLine.hasOption(ENTRY_FORMATTER_OPT)) {
- String val = cmdLine.getOptionValue(ENTRY_FORMATTER_OPT);
- shell.entryFormatter = EntryFormatter.newEntryFormatter(val, shell.bkConf);
- } else {
- shell.entryFormatter = EntryFormatter.newEntryFormatter(shell.bkConf);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using entry formatter {}", shell.entryFormatter.getClass());
- }
+ // handle some common options for multiple cmds
+ Options opts = new Options();
+ opts.addOption(CONF_OPT, true, "configuration file");
+ opts.addOption(LEDGERID_FORMATTER_OPT, true, "format of ledgerId");
+ opts.addOption(ENTRY_FORMATTER_OPT, true, "format of entries");
+ BasicParser parser = new BasicParser();
+ CommandLine cmdLine = parser.parse(opts, argv, true);
+
+ // load configuration
+ CompositeConfiguration conf = new CompositeConfiguration();
+ if (cmdLine.hasOption(CONF_OPT)) {
+ String val = cmdLine.getOptionValue(CONF_OPT);
+ conf.addConfiguration(new PropertiesConfiguration(
+ new File(val).toURI().toURL()));
+ }
+ shell.setConf(conf);
- int res = shell.run(cmdLine.getArgs());
- System.exit(res);
+ // ledgerid format
+ if (cmdLine.hasOption(LEDGERID_FORMATTER_OPT)) {
+ String val = cmdLine.getOptionValue(LEDGERID_FORMATTER_OPT);
+ shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(val, shell.bkConf);
+ } else {
+ shell.ledgerIdFormatter = LedgerIdFormatter.newLedgerIdFormatter(shell.bkConf);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using ledgerIdFormatter {}", shell.ledgerIdFormatter.getClass());
+ }
+
+ // entry format
+ if (cmdLine.hasOption(ENTRY_FORMATTER_OPT)) {
+ String val = cmdLine.getOptionValue(ENTRY_FORMATTER_OPT);
+ shell.entryFormatter = EntryFormatter.newEntryFormatter(val, shell.bkConf);
+ } else {
+ shell.entryFormatter = EntryFormatter.newEntryFormatter(shell.bkConf);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using entry formatter {}", shell.entryFormatter.getClass());
+ }
+
+ res = shell.run(cmdLine.getArgs());
+ } catch (Exception e) {
Review Comment:
Addressed. PTAL
--
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: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org