Skip to content

Commit

Permalink
fix(cassandra) add a 'port' option for clusters
Browse files Browse the repository at this point in the history
Clusters with nodes not running on the default `9042` port couldn't be
properly reached by Kong. This bumps the driver (including the fix), and
adds a `port` options to the configuration. Thanks @allisthere2love for
the investigation.

This issue was never encountered before and my guess is because such
clusters added their contact_points including the port (`x.x.x.x:9043`),
and the driver could connect to it, but not to the other nodes, since it
was trying `9042` on those. So it simply considered the other nodes as
DOWN, and thus still works (if one doesn't check the logs and those lags
are not displaying warnings, it seems like nothing is going wrong).
However @allisthere2love had nodes from another C* cluster listening on
`9042`, leading to inconsistencies and thus, actual errors that allowed
us to track it down.

As per other datastax drivers, all nodes of a cluster must listen on the
same port.

Fix #1139
See thibaultcha/lua-cassandra#47
  • Loading branch information
thibaultcha committed Apr 11, 2016
1 parent abb9dc5 commit 0a9a003
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kong-0.7.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = {
"yaml ~> 1.1.2-1",
"lapis ~> 1.3.1-1",
"stringy ~> 0.4-1",
"lua-cassandra ~> 0.5.0",
"lua-cassandra ~> 0.5.1",
"multipart ~> 0.2-1",
"lua-path ~> 0.2.3-1",
"lua-cjson ~> 2.1.0-1",
Expand Down
2 changes: 2 additions & 0 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
# contact_points:
# - "127.0.0.1:9042"

# port: 9042

######
## Name of the keyspace used by Kong. Will be created if it does not exist.
# keyspace: kong
Expand Down
3 changes: 3 additions & 0 deletions kong/dao/cassandra/factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ function CassandraFactory:get_session_options()
prepared_shm = "cassandra_prepared",
contact_points = self.properties.contact_points,
keyspace = self.properties.keyspace,
protocol_options = {
default_port = self.properties.port
},
query_options = {
prepare = true
},
Expand Down
1 change: 1 addition & 0 deletions kong/tools/config_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ return {
type = "table",
content = {
["contact_points"] = {type = "array", default = {"127.0.0.1:9042"}},
["port"] = {type = "number", default = 9042},
["keyspace"] = {type = "string", default = "kong"},
["timeout"] = {type = "number", default = 5000},
["replication_strategy"] = {type = "string", default = "SimpleStrategy", enum = {"SimpleStrategy", "NetworkTopologyStrategy"}},
Expand Down

0 comments on commit 0a9a003

Please sign in to comment.