Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db) Support for Cassandra 3.x - lua-cassandra 1.x #1709

Merged
merged 7 commits into from
Oct 18, 2016

Conversation

thibaultcha
Copy link
Member

@thibaultcha thibaultcha commented Oct 4, 2016

Summary

Implement support for Cassandra 3.x by upgrading lua-cassandra support to
1.x. This is waiting on a lua-cassandra 1.1.0 release before being merged.
In the meantime, manually install the master branch of
lua-cassandra.

Full changelog

  • Support for lua-cassandra 1.x
  • Support for Cassandra 3.x (2.x is still supported)
  • Configurable Load Balancing policy for the C* cluster. We now support
    Datacenter-aware round robin with the cassandra_lb_policy and
    cassandra_local_datacenter properties in kong.conf
  • Rework the rate-limiting and response-ratelimiting plugins "cluster"
    policies (those are using the DAO). We now pass the DAO as an argument instead
    of extending the plugin's DAO.
  • Get rid of classic.lua pattern to create DB modules. We now use
    kong.dao.db.init
  • Prevent using a C* cluster made of nodes with different major release
    versions
  • Implement a mock ngx.shared.DICT API for use in resty-cli because
    lua-cassandra 1.x depends on an shm. Waiting on
    feat: implement --shdict to create shared dict openresty/resty-cli#12 to get rid of it.
  • Better Lua idioms for DAOs and the Factory (Factory.new() instead of
    Factory())
  • slightly rework the codestyle of the C* and Postgres DB modules
  • increase the C* timeout in CLI and tests
  • use a constant reconnection policy with a very low setting in the CLI and tests

Issues resolved

Fix #831 #1294

Missing

  • Bump lua-cassandra to 1.1.x (actually will do before releasing 0.10)
  • DAO tests output WARN logs to stdout due to lua-resty-cli

@thibaultcha thibaultcha added this to the 0.10 milestone Oct 4, 2016
@thibaultcha
Copy link
Member Author

Tests: waiting on lua-cassandra 1.1

@thibaultcha thibaultcha force-pushed the feat/cassandra-3.x_lua-cassandra-1.0 branch 8 times, most recently from 6ab7286 to 4ffc18e Compare October 9, 2016 11:59
@thibaultcha thibaultcha force-pushed the feat/cassandra-3.x_lua-cassandra-1.0 branch from 4ffc18e to 4c9bff5 Compare October 17, 2016 22:22
This makes the DAO functional with lua-cassandra 1.0.0. Only Cassandra
2.x is still supported (more updates required for 3.x).

We also retrieve the cluster release_version to avoid nodes with
different major versions, and thus prevent migration errors (due to
different queries being performed for different major versions)

* move DB implementations to `kong.dao.db`
* updated rockspec tests to properly evaluate `init` modules (typical
Lua idiom)
* Get rid of classic.lua and use our own DB implementation helper
module, it's pretty cool
* instanciating a DAO Factory now returns `factory, err`
* instanciating a Cassandra DB in the CLI triggers a cluster refresh
(testing the connection and retrieving cluster info at the same time)
* as long as openresty/resty-cli#12 is not
included in an OpenResty release, this implements a mocked
`ngx.shared.DICT` object in `kong.globalpatches`.
- new architecture for db modules, this gets rid of `classic.lua` and
uses a custom base DB module `kong.dao.db.init`
- support for Cassandra 3.x system querying - we detect which major
Cassandra version is in use before executing queries
- switch `cassandra.unset` for `cassandra.null` which has the same
meaning for protocol v3 but the one we intend for protocol v4 (set an
existing column to NULL)
- distinguish `init()` and `init_worker()` methods for dbs (Postgres
needs init_worker, Cassandra needs init context (must run before
migrations to detect major version)
- we do not support clusters made of nodes with different major versions
(not sure if this is possible, so we should prevent it)
- add exptime support in shm mock in `globalpatches`
- cleanup some bad patterns like return values
- trying to limit col width to 80 chars
- caching some global lookups
- cleanup some bad patterns like single return values or such
- caching global lookups
Allows the use of `DCAwareRoundRobin` load balancing policy for
Cassandra, allowing to distribute C* queries accross a multi-dc cluster
while always trying to hit the local DC first.
- make db instance accessible from Factory for `init_worker()` call
- update to new CLI flag
- use the new no_keyspace option from coordinator_options
- correcly instanciate Factory in new quiet_spec tests
- replace left over `unset`
- fix rate-limiting and response-ratelimiting tests (renamed dao_spec to
policies_spec)
@thibaultcha thibaultcha force-pushed the feat/cassandra-3.x_lua-cassandra-1.0 branch 4 times, most recently from 02ffca6 to d192ea7 Compare October 18, 2016 00:07
@thibaultcha thibaultcha force-pushed the feat/cassandra-3.x_lua-cassandra-1.0 branch from d192ea7 to 3dc9a0e Compare October 18, 2016 01:57
@thibaultcha thibaultcha added pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release) and removed pr/status/needs review labels Oct 18, 2016
@thibaultcha thibaultcha merged commit 7ae1754 into next Oct 18, 2016
@thibaultcha thibaultcha deleted the feat/cassandra-3.x_lua-cassandra-1.0 branch October 18, 2016 22:26
This was referenced Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant