frankgh commented on code in PR #2519:
URL: https://github.com/apache/cassandra/pull/2519#discussion_r1276448027


##########
src/java/org/apache/cassandra/db/ColumnFamilyStore.java:
##########
@@ -558,7 +558,7 @@ public ColumnFamilyStore(Keyspace keyspace,
         repairManager = new CassandraTableRepairManager(this);
         sstableImporter = new SSTableImporter(this);
 
-        if (SchemaConstants.isSystemKeyspace(getKeyspaceName()))
+        if (DatabaseDescriptor.isClientOrToolInitialized() || 
SchemaConstants.isSystemKeyspace(getKeyspaceName()))

Review Comment:
   I encountered this message in the Cassandra Analytics library. I have added 
a unit test that showcases the problem that I mention in the jira. When running 
the unit test without this change, I see the following in the logs:
   
   ```
   WARN  [main] 2023-07-27 08:17:43,417 SystemKeyspace.java:1925 - Could not 
load stored top SIZES partitions for cql_test_keyspace.test1
   org.apache.cassandra.db.KeyspaceNotDefinedException: keyspace system does 
not exist
        at org.apache.cassandra.schema.Schema.validateTable(Schema.java:460)
        at 
org.apache.cassandra.cql3.statements.SelectStatement$RawStatement.prepare(SelectStatement.java:1131)
        at 
org.apache.cassandra.cql3.statements.SelectStatement$RawStatement.prepare(SelectStatement.java:1126)
        at 
org.apache.cassandra.cql3.statements.SelectStatement$RawStatement.prepare(SelectStatement.java:1098)
        at 
org.apache.cassandra.cql3.QueryProcessor.parseAndPrepare(QueryProcessor.java:435)
        at 
org.apache.cassandra.cql3.QueryProcessor.prepareInternal(QueryProcessor.java:413)
        at 
org.apache.cassandra.cql3.QueryProcessor.executeInternal(QueryProcessor.java:446)
        at 
org.apache.cassandra.db.SystemKeyspace.getTopPartitions(SystemKeyspace.java:1903)
        at 
org.apache.cassandra.metrics.TopPartitionTracker.<init>(TopPartitionTracker.java:85)
        at 
org.apache.cassandra.db.ColumnFamilyStore.<init>(ColumnFamilyStore.java:564)
        at 
org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:766)
        at 
org.apache.cassandra.db.ColumnFamilyStoreClientModeTest.testTopPartitionsAreNotInitialized(ColumnFamilyStoreClientModeTest.java:95)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
        at 
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
        at 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
   
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to