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

Sam Tunnicliffe commented on CASSANDRA-9310:
--------------------------------------------

Actually, I'm still uneasy about introducing changes to protocol messages in 
2.0, even though it's clear that the message doesn't match the original intent. 

AFAICT, the java driver isn't affected by this in the same way as the python 
driver. This seems to be because while the python driver assumes that a ks 
level event only indicates changes to the ks meta data (replication settings 
and such) and so only reloads that, the java driver also refreshes all table 
and column metadata for the affected ks. 

FTR, what the python driver is doing currently is correct (from my reading 
anyway) so although it's a shame to have to work around it there I think we 
really should be handling this at the driver level as it's too late in the day 
to be making changes like this in 2.0

Aside from that, cleaning up {{DropeIndexStatement}} a little in 2.1 would be 
good but there's a problem in the 2.1 patch. In 2.1 
{{DropIndexStatement#columnfamily()}} is already defined, so applying the patch 
as-is causes a compilation error. I would keep your new version of the method 
and drop the existing one.


> Table change response returns as keyspace change response
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-9310
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9310
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: C* 1.2.19 and 2.0.14 | python-driver master (upcoming v. 
> 2.6)
>            Reporter: Kishan Karunaratne
>            Assignee: Carl Yeksigian
>             Fix For: 2.1.x, 2.0.x
>
>         Attachments: 9310-1.2.txt, 9310-2.0.txt, 9310-2.1.txt
>
>
> When an index is dropped, its existence is still persisted across the 
> keyspace metadata. This happens because the response to drop the index from 
> the metadata is never received, as a keyspace change response is 
> (incorrectly) received by the driver instead of a table change response. 
> Related to PYTHON-241: https://datastax-oss.atlassian.net/browse/PYTHON-241
> Test:
> {noformat}
> self.session.execute("CREATE TABLE %s (k int PRIMARY KEY, a int)" % 
> self.table_name)
> ks_meta = self.cluster.metadata.keyspaces[self.keyspace_name]
> table_meta = ks_meta.tables[self.table_name]
> self.assertNotIn('a_idx', ks_meta.indexes)
> self.assertNotIn('b_idx', ks_meta.indexes)
> self.assertNotIn('a_idx', table_meta.indexes)
> self.assertNotIn('b_idx', table_meta.indexes)
> self.session.execute("CREATE INDEX a_idx ON %s (a)" % self.table_name)
> self.session.execute("ALTER TABLE %s ADD b int" % self.table_name)
> self.session.execute("CREATE INDEX b_idx ON %s (b)" % self.table_name)
> ks_meta = self.cluster.metadata.keyspaces[self.keyspace_name]
> table_meta = ks_meta.tables[self.table_name]
> self.assertIsInstance(ks_meta.indexes['a_idx'], IndexMetadata)
> self.assertIsInstance(ks_meta.indexes['b_idx'], IndexMetadata)
> self.assertIsInstance(table_meta.indexes['a_idx'], IndexMetadata)
> self.assertIsInstance(table_meta.indexes['b_idx'], IndexMetadata)
> # both indexes updated when index dropped
> self.session.execute("DROP INDEX a_idx")
> ks_meta = self.cluster.metadata.keyspaces[self.keyspace_name]
> table_meta = ks_meta.tables[self.table_name]
> self.assertNotIn('a_idx', ks_meta.indexes)
> {noformat}
> Output:
> {noformat}
> AssertionError: 'a_idx' unexpectedly found in {u'b_idx': 
> <cassandra.metadata.IndexMetadata object at 0x7f2dd87d4590>, u'a_idx': 
> <cassandra.metadata.IndexMetadata object at 0x7f2dd87d4a10>}
> {noformat}
> Debug log:
> {noformat}
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'CREATED', 
> 'table': u''}, trace_id=None)>
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: , Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Fetched keyspace info for 
> index_map_tests, rebuilding metadata
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched keyspace info for 
> index_map_tests, rebuilding metadata
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'CREATED', 
> 'table': u'test_index_updates'}, trace_id=None)>
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: test_index_updates, Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'UPDATED', 
> 'table': u'test_index_updates'}, trace_id=None)>
> cassandra.cluster: DEBUG: Ignoring schedule_unique for already-scheduled 
> task: (<bound method ControlConnection.refresh_schema of 
> <cassandra.cluster.ControlConnection object at 0x7f9c6864fc90>>, 
> (u'index_map_tests', u'test_index_updates', None))
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: test_index_updates, Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'UPDATED', 
> 'table': u'test_index_updates'}, trace_id=None)>
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: test_index_updates, Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: test_index_updates, Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'UPDATED', 
> 'table': u'test_index_updates'}, trace_id=None)>
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.cluster: DEBUG: [control connection] Fetched table info for 
> index_map_tests.test_index_updates, rebuilding metadata
> cassandra.connection: DEBUG: Message pushed from server: 
> <EventMessage(stream_id=-1, event_type=u'SCHEMA_CHANGE', 
> event_args={'keyspace': u'index_map_tests', 'change_type': u'UPDATED', 
> 'table': u'test_index_updates'}, trace_id=None)>
> cassandra.cluster: DEBUG: Refreshing schema in response to schema change. 
> Keyspace: index_map_tests; Table: , Type: None
> cassandra.cluster: DEBUG: [control connection] Waiting for schema agreement
> cassandra.cluster: DEBUG: [control connection] Schemas mismatched, trying 
> again
> cassandra.cluster: DEBUG: [control connection] Schemas match
> cassandra.cluster: DEBUG: [control connection] Fetched keyspace info for 
> index_map_tests, rebuilding metadata
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to