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

Alex Petrov commented on CASSANDRA-18317:
-----------------------------------------

I agree that adding {{synchronized}} fixes the issue, but I think the core of 
the problem is that {{Schema#load}} is not atomic in 4.0 and we should probably 
disallow it and switch to {{cas}} or an interface similar to what is available 
in trunk with transformations (see 
https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java#L565).
 This way, all users of schema loading will not be able to overwrite anything 
written by someone else. An alternative to CAS can be an interface that allows 
your transformation code to run inside of synchronised block of schema load. 
Ive put rough prototypes of both ideas just to explore them 
[here|https://github.com/ifesdjeen/cassandra/tree/alter-example]. I am weakly 
leaning to the second variant, as it is closer to trunk. But in general, I 
think that load in its current form should go away in 4.0 as well, and if we 
fix it by wrapping cql writer schema loading in a synchronised block, we are 
only fixing it for the cql writer, while leaving a possibility for other users 
of schema loading to overwrite keyspaces other users wrote.

Thank you for spotting this issue.

> Properly synchronize CQLSSTableWriter#build on the Schema.instance
> ------------------------------------------------------------------
>
>                 Key: CASSANDRA-18317
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18317
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tool/bulk load
>            Reporter: Francisco Guerrero
>            Assignee: Francisco Guerrero
>            Priority: Normal
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The {{CQLSSTableWriter#build}} method should properly synchronize on the 
> {{Schema.instance}} class to prevent concurrent Schema operations fail, [when 
> the offline tool also updates schema].
> For example, a table creation operation, which modifies the keyspaces tables 
> metadata, might end up missing the update when a concurrent call to the 
> {{CQLSSTableWriter#build}} method is accessing the {{Schema}} instance.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to