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

Aleksey Yeschenko commented on CASSANDRA-9425:
----------------------------------------------

The first commit is finishing the work I haven't completed for schema in 3.0, 
making the remaining metadata objects effectively immutable. So that's mostly 
{{CFMetaData}}, {{ViewDefinition}}, and {{UDFunction}}.

{{CFMetaData}} is now split into {{TableMetadata}} - an immutable, severely 
cleaned up, table descriptor class, and {{TableMetadataRef}} - a wrapper used 
in long-lived instances like {{ColumnFamilyStore}}, {{AtomicBTreePartition}}, 
and {{SSTable}}, where looking up {{Schema.instance}} is too much, yet updating 
them every time on a table change is a hassle, and potentially error-prone 
(though {{ColumnFamilyStore}} could arguably just have a {{TableMetadata}} 
field in place of {{TableMetadataRef}}.

It's a huge diff, but a lot of it in tests, and most of it is renames in method 
signatures and fields.

Multiple schema-related classes have been moved to 
{{org.apache.cassandra.schema}} package, where they ultimately belong, to allow 
for tighter visibility on some of the more dangerous schema altering methods. 
Some of them have also been renamed to more accurately reflect their purpose or 
be more consistent (which IMO is ok, if they are being moved to new files 
anyway).

The review should focus on {{org.apache.cassandra.schema}} package, most 
everything else can be skimmed.

The commit fixes multiple issues (for 4.0 only), including but not limited to 
CASSANDRA-12950, CASSANDRA-12951, CASSANDRA-12953, CASSANDRA-12954. It doesn't 
fix CASSANDRA-12949 but disables the method as unsafe.

Among other things, Schema merge logic has been vastly simplified (and moved 
from {{SchemaKeyspace}} to {{Schema}}).

CI runs:
||branch||testall||dtest||
|[9425-1|https://github.com/iamaleksey/cassandra/tree/9425-1]|[testall|http://cassci.datastax.com/view/Dev/view/iamaleksey/job/iamaleksey-9425-1-testall]|[dtest|http://cassci.datastax.com/view/Dev/view/iamaleksey/job/iamaleksey-9425-1-dtest]|

> Make node-local schema fully immutable
> --------------------------------------
>
>                 Key: CASSANDRA-9425
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9425
>             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
(v6.3.4#6332)

Reply via email to