cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lyuben Todorov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-7597) System.exit() calls should be removed from DatabaseDescriptor
Date Thu, 24 Jul 2014 10:13:38 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-7597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14073058#comment-14073058
] 

Lyuben Todorov commented on CASSANDRA-7597:
-------------------------------------------

Its better to fail-fast when a bad config is detected as it's hard to interpret what the config
was supposed to be and attempt to fix it. My argument for -1 here is that logging exceptions
without erroring out preemptively will lead to further problems (further exception and a 
stacktrace that might be misleading) and eventually a crash. 

I'll give an example just to be clear. A missing {{commitlog_sync}} option from cassandra.yaml
would generate this error when trying to start the server:

{noformat}
ERROR 09:58:33 Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: Missing required directive CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:162)
~[main/:na]
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:128)
~[main/:na]
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:109) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543) [main/:na]
Missing required directive CommitLogSync
Fatal configuration error; unable to start. See log for stacktrace.
{noformat}

I think that error is much clearer than what would happen if we just log the exception and
allow cassandra to continue, the below is the final exception that is displayed:

{noformat}
ERROR 09:59:45 Exception encountered during startup
java.lang.NullPointerException: null
	at java.util.Arrays$ArrayList.<init>(Arrays.java:2842) ~[na:1.7.0_60]
	at java.util.Arrays.asList(Arrays.java:2828) ~[na:1.7.0_60]
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:192) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543) [main/:na]
java.lang.NullPointerException
	at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
	at java.util.Arrays.asList(Arrays.java:2828)
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:192)
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454)
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543)
Exception encountered during startup: null
{noformat}

Finally removing the {{System.exit(1|-1)}} and throwing exceptions instead generates a similar
stacktrace to what we do now, except its not as clean:

{noformat}
ERROR 10:07:59 Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: Missing required directive CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:164)
~[main/:na]
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:128)
~[main/:na]
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:109) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543) [main/:na]
ERROR 10:07:59 Exception encountered during startup
java.lang.ExceptionInInitializerError: null
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:109) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454) [main/:na]
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543) [main/:na]
Caused by: java.lang.RuntimeException: org.apache.cassandra.exceptions.ConfigurationException:
Missing required directive CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:136)
~[main/:na]
	... 3 common frames omitted
Caused by: org.apache.cassandra.exceptions.ConfigurationException: Missing required directive
CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:164)
~[main/:na]
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:128)
~[main/:na]
	... 3 common frames omitted
java.lang.ExceptionInInitializerError
	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:109)
	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:454)
	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:543)
Caused by: java.lang.RuntimeException: org.apache.cassandra.exceptions.ConfigurationException:
Missing required directive CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:136)
	... 3 more
Caused by: org.apache.cassandra.exceptions.ConfigurationException: Missing required directive
CommitLogSync
	at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:164)
	at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:128)
	... 3 more
Exception encountered during startup: null
{noformat}

> System.exit() calls should be removed from DatabaseDescriptor
> -------------------------------------------------------------
>
>                 Key: CASSANDRA-7597
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7597
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Cassandra 2.0.9 (earlier version should be affected as well)
>            Reporter: Pavel Sakun
>
> We're using SSTableSimpleUnsortedWriter API to generate SSTable to be loaded into cassandra.
In case of any issue with config DatabaseDescriptor calls System.exit() which is apparently
not the thing you expect while using API.
> Test case is simple:
> System.setProperty( "cassandra.config", "" );
> new YamlConfigurationLoader().loadConfig();
> Thread.sleep( 5000 );
> System.out.println("We're still alive"); // this will never be called



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message