-
Notifications
You must be signed in to change notification settings - Fork 310
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
Provide configuration option to declare CQL scripts that create a "named" Keyspace on startup [DATACASS-723] #890
Comments
John Blum commented This problem was first detected in Spring Boot for Apache Geode (SBDG), testing the Inline Caching capabilities provided by SBDG to back an Apache Geode cache with a persistent data store like Apache Cassandra to perform read/write-through or write-behind data access operations. This test class driving the configuration and test cases lives here. The configuration of Apache Cassandra using Spring Data for Apache Cassandra lives here. When trying to use either a |
John Blum commented I see 2 possible solutions (there maybe others as well):
Of course, the If a bean definition were created for the "system" |
Mark Paluch commented Keyspace creation and initialization were intentionally split with the driver upgrade. Previously, factory beans carried a lot of functionality that blurred the lines of responsibility. We have a clear separation now between keyspace creation and keyspace initialization. In general, keyspace creation on startup through configuration classes is discouraged as all data frameworks require the database (which corresponds with the keyspace) already created.
Regarding the
|
John Blum commented Mark Paluch- Just acknowledging that I saw your reply comments, but need more time to respond to your questions. Will followup more shortly |
John Blum opened DATACASS-723 and commented
The
o.s.d.c.core.cql.session.init.SessionFactoryInitializer
is not sufficient to replace theo.s.d.c.config.AbstractSessionConfiguration
class's now deprecatedgetStartupScripts()
andgetShutdownScripts()
methods.As as application developer using Spring Data for Apache Cassandra, if I want to specify a Cassandra Keyspace used by my application, then in my application configuration, I might do, or start with the following, which is very useful...
However, without also specifying the now deprecated methods, for example...
Where
schema.cql
is defined as...Then the application will throw an Exception on startup stating that the named/specified Keyspace (i.e.
MyAppKeyspace
does not exist!The
SessionFactoryInitializer
(or even theKeyspacePopulator
registered on theSessionFactoryFactoryBean
provided via extension of theAbstractCassandraConfiguration}) is, or are far too late in the initialization process to "initialize" the "application" (-defined) Keyspace using the Cassandra {{Session
provided by the SD CassandraSessionFactory
, which is created by theCqlSessionFactoryBean
definition and is based off the "name", application-defined Keyspace anyway.Essentially the problem can be reproduced by:
First declaring the application
Keyspace
name.The
Keyspace
name is then configured (i.e. set) on the {{CqlSessionFactoryBean} bean definition declared in theAbstractSessionConfiguration
class, which theAbstractCassandraConfiguration
base class, extended by application code to simplify configuration, extends.Keyspace
is directly after a SD Cassandra framework (internal)Session
is opened to the Cassandra "system"Keyspace
and subsequently initialized that would then further allow additionalKeyspaces
to be defined, created and initialized, via CQL scripts applied on startup.However, the very next thing to happen is that now the application "named"
Keyspace
is created, which leads to theIllegalStateException
shown above.If we tried to follow the logic of using a
SessionFactoryInitializer
to perform the schema actions above, we'd see that A) theSession
connected to the application "named"Keyspace
would then be supplied by theCqlSessionFactoryBean
bean definition from theAbstractSessionConfiguration
class (which again, the user's application would indirectly extend) to theSessionFactoryFactoryBean
bean definition declared in theAbstractCassandraConfiguration
class (the class our application configuration class extends).It is the
SessionFactoryFactoryBean
that supplies theSessionFactory
that ultimately is post processed by the declaredSessionFactoryInitializers
in the Spring context.Yet, as stated above, this is too late in the initialization process.
See comments below for possible solutions.
Affects: 3.0 M2 (Neumann)
The text was updated successfully, but these errors were encountered: