You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "tengu-alt (via GitHub)" <gi...@apache.org> on 2024/08/08 09:41:07 UTC
[PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
tengu-alt opened a new pull request, #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "tengu-alt (via GitHub)" <gi...@apache.org>.
tengu-alt commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1713589130
##########
metadata.go:
##########
@@ -760,6 +879,37 @@ func getTableMetadata(session *Session, keyspaceName string) ([]TableMetadata, e
return tables, nil
}
+// query for only the table metadata in the specified keyspace from system_virtual_schema.tables
+func getVirtualTableMetadata(s *Session, keyspaceName string) ([]VirtualTableMetadata, error) {
+ const stmt = `
+ SELECT
+ table_name,
+ comment
+ FROM system_virtual_schema.tables
+ WHERE keyspace_name = ?`
Review Comment:
agree, fixed
##########
metadata.go:
##########
@@ -947,6 +1097,52 @@ func getColumnMetadata(session *Session, keyspaceName string) ([]ColumnMetadata,
return columns, nil
}
+// query for only the column metadata in the specified keyspace from system_virtual_schema.columns
+func getVirtualColumnMetadata(s *Session, keyspaceName string) ([]VirtualColumnMetadata, error) {
+ const stmt = `
+ SELECT
+ table_name,
+ column_name,
+ clustering_order,
+ kind,
+ type
+ FROM system_virtual_schema.columns
+ WHERE keyspace_name = ?`
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "tengu-alt (via GitHub)" <gi...@apache.org>.
tengu-alt commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1713628549
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
I agree with your point about invalidation, but virtual metadata is only requested on the user's purpose, not by some node event, also virtual tables can't be changed, if we talk about some `schemaAgreement` case. In my opinion, it is unnecessary to invalidate it on every `getSchema` request, and i think it is unnecessary to remove a control connection, it is good to keep the existing pattern of the metadata requests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "dkropachev (via GitHub)" <gi...@apache.org>.
dkropachev commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1712560334
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
Shouldn't you invalidate it at some point.
Say you upgrade cluster from one version to another, driver will still keep old schema.
Probably on `handleNodeUp` you could read `release_version` `select release_version from system.local where key = 'local'` and invalidate or update cache if it has changed.
Another problem if your cluster half on new version half on another.
Now you depends on where have your control connection landed, if it has landed on a node with new version, session will give you a new schema, while old nodes don't support it.
Way to solve it is to run queries not on control connection, but rather on the node with oldest version available, if you were do so, you can't pick all the nodes from the cluster, you have to adhere to `HostSelectionPolicy`, say if it is `dcAwareRR` you will need to filter out all nodes from other datacenters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "tengu-alt (via GitHub)" <gi...@apache.org>.
tengu-alt commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1713635813
##########
metadata.go:
##########
@@ -240,6 +262,13 @@ type schemaDescriber struct {
cache map[string]*KeyspaceMetadata
}
+// queries the cluster for schema information for a virtual keyspace
+type virtualSchemaDescriber struct {
+ session *Session
+ mu sync.Mutex
+ cache map[string]*VirtualKeyspaceMetadata
Review Comment:
I think it is preferable to use mutex, to keep the existing pattern, and avoid unnecessary code complexity.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "dkropachev (via GitHub)" <gi...@apache.org>.
dkropachev commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1712553534
##########
metadata.go:
##########
@@ -760,6 +879,37 @@ func getTableMetadata(session *Session, keyspaceName string) ([]TableMetadata, e
return tables, nil
}
+// query for only the table metadata in the specified keyspace from system_virtual_schema.tables
+func getVirtualTableMetadata(s *Session, keyspaceName string) ([]VirtualTableMetadata, error) {
+ const stmt = `
+ SELECT
+ table_name,
+ comment
+ FROM system_virtual_schema.tables
+ WHERE keyspace_name = ?`
Review Comment:
Can you please fix indent:
```suggestion
const stmt = `
SELECT
table_name,
comment
FROM system_virtual_schema.tables
WHERE keyspace_name = ?`
```
##########
metadata.go:
##########
@@ -947,6 +1097,52 @@ func getColumnMetadata(session *Session, keyspaceName string) ([]ColumnMetadata,
return columns, nil
}
+// query for only the column metadata in the specified keyspace from system_virtual_schema.columns
+func getVirtualColumnMetadata(s *Session, keyspaceName string) ([]VirtualColumnMetadata, error) {
+ const stmt = `
+ SELECT
+ table_name,
+ column_name,
+ clustering_order,
+ kind,
+ type
+ FROM system_virtual_schema.columns
+ WHERE keyspace_name = ?`
Review Comment:
Same ident problem:
```suggestion
const stmt = `
SELECT
table_name,
column_name,
clustering_order,
kind,
type
FROM system_virtual_schema.columns
WHERE keyspace_name = ?`
```
##########
metadata.go:
##########
@@ -240,6 +262,13 @@ type schemaDescriber struct {
cache map[string]*KeyspaceMetadata
}
+// queries the cluster for schema information for a virtual keyspace
+type virtualSchemaDescriber struct {
+ session *Session
+ mu sync.Mutex
+ cache map[string]*VirtualKeyspaceMetadata
Review Comment:
I would recommend, in this particular case, use `sync.Map` instead of Mutex + map.
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
Shouldn't you invalidate it at some point.
Say you upgrade cluster from one version to another, driver will still keep old schema.
Probably on `handleNodeUp` you could read `release_version` `select release_version from system.local where key = 'local'` and invalidate cache if it has changed.
Another problem if your cluster half on new version half on another.
Now you depends on where have your control connection landed, if it has landed on a node with new version, session will give you a new schema, while old nodes don't support it.
Way to solve it is to run queries not on control connection, but rather on the node with oldest version available, if you were do so, while you are picking nodes, you also have to adhere to `HostSelectionPolicy`, say if it is `dcAwareRR` you will need to filter out all nodes from other datacenters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "tengu-alt (via GitHub)" <gi...@apache.org>.
tengu-alt commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1714855768
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
I totally agree with you, but in my opinion, it is good to keep an existing pattern of processing the metadata (virtual or not)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "dkropachev (via GitHub)" <gi...@apache.org>.
dkropachev commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1713644935
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
If you clear cache a the betting of `getSchema` it means that there is going to be no cache, why just not drop it.
If you drop the cache then there is no point in having `virtualSchemaDescriber`, you can just move code to `Session`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "tengu-alt (via GitHub)" <gi...@apache.org>.
tengu-alt commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1713628549
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
I agree with your point about invalidation. I will clear the cache at the beginning of the `getSchema` method.
Virtual metadata is only requested on the user's purpose, not by some node event, also virtual tables can't be changed, if we talk about some `schemaAgreement` case. In my opinion, it is unnecessary to remove a control connection, and it is good to keep the existing pattern of the metadata requests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] Virtual keyspace metadata support was immplemented [cassandra-gocql-driver]
Posted by "dkropachev (via GitHub)" <gi...@apache.org>.
dkropachev commented on code in PR #1794:
URL: https://github.com/apache/cassandra-gocql-driver/pull/1794#discussion_r1712560334
##########
metadata.go:
##########
@@ -269,6 +307,23 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}
+// returns the cached VirtualKeyspaceMetadata held by the describer for the named
+// keyspace.
+func (s *virtualSchemaDescriber) getSchema(keyspaceName string) (*VirtualKeyspaceMetadata, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ metadata, found := s.cache[keyspaceName]
Review Comment:
Shouldn't you invalidate it at some point.
Say you upgrade cluster from one version to another, driver will still keep old schema.
Probably on `handleNodeUp` you could read `release_version` `select release_version from system.local where key = 'local'` and invalidate or update cache if it has changed.
Another problem if your cluster half on new version half on another.
Now you depends on where have your control connection landed, if it has landed on a node with new version, session will give you a new schema, while old nodes don't support it.
Way to solve it is to run queries not on control connection, but rather on the node with oldest version available, if you were do so, while you are picking nodes, you also have to adhere to `HostSelectionPolicy`, say if it is `dcAwareRR` you will need to filter out all nodes from other datacenters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org