cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Yeschenko (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-9425) Make node-local schema fully immutable
Date Thu, 26 Jan 2017 17:42:24 GMT


Aleksey Yeschenko commented on CASSANDRA-9425:

bq. feels like it could be misused easily so I'd suggest making things
a bit more explicit.


bq. for indexes, where we kind of hack around them not having their own ID.

Addressed by moving 2i {{TableMetadata}} s handling to {{Tables}} and {{Schema}}.

bq. Also, the Schema ctor should probably be private.


bq. Some of Schema.createKeyspace() is actually redundant: Keyspace ctor already initialize
all tables and views, so it ends up being duplicated. It's largely harmless though we do end
up reloading each ColumnFamilyStore for no reason.


bq. Schema.load and Schema.unload should probably be synchronized for their modification of


bq. validateTable seems to replace Validation.validateColumnFamily but the latter is still
there and used in a few instances. Would be nice to clean up. Validation.validateKeyspaceNotSystem
could probably be migrated too for consistency.


bq. In TableMetadata, validateCompatibility() should probably check more stuffs (we can't
alter non-PK column types as we want, nor change the partition key size for instance).


The only unaddressed issues at this point are loading of schema and system keyspaces in {{Schema}}
static block and a proper refactoring of {{load()}}. With both of these present in current
trunk code, I'd prefer to commit what is here as is, and move those into a separate ticket
(I would also like to separate out {{Keyspace}} instance handling and metadata handling into
two separate classes instead of overloading {{Schema}}, to address the issue properly and
not just put some lipstick on this pig).

> Make node-local schema fully immutable
> --------------------------------------
>                 Key: CASSANDRA-9425
>                 URL:
>             Project: Cassandra
>          Issue Type: Sub-task
>            Reporter: Aleksey Yeschenko
>            Assignee: Aleksey Yeschenko
>             Fix For: 4.0
> The way we handle schema changes currently is inherently racy.
> All of our {{SchemaAlteringStatement}} s perform validation on a schema state that's
won't necessarily be there when the statement gets executed and mutates schema.
> We should make all the *Metadata classes ({{KeyspaceMetadata, TableMetadata}}, {{ColumnMetadata}},
immutable, and local schema persistently snapshottable, with a single top-level {{AtomicReference}}
to the current snapshot. Have DDL statements perform validation and transformation on the
same state.
> In pseudo-code, think
> {code}
> public interface DDLStatement
> {
>     /**
>      * Validates that the DDL statement can be applied to the provided schema snapshot.
>      *
>      * @param schema snapshot of schema before executing CREATE KEYSPACE
>      */
>     void validate(SchemaSnapshot schema);
>     /**
>      * Applies the DDL statement to the provided schema snapshot.
>      * Implies that validate() has already been called on the provided snapshot.
>      *
>      * @param schema snapshot of schema before executing the statement
>      * @return snapshot of schema as it would be after executing the statement
>      */
>     SchemaSnapshot transform(SchemaSnapshot schema);
> }
> {code}

This message was sent by Atlassian JIRA

View raw message