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

chore(db) connector:close and connector:setkeepalive cleanup #4218

Closed
wants to merge 16 commits into from

Conversation

bungle
Copy link
Member

@bungle bungle commented Jan 18, 2019

Summary

Make both Postgres and Cassandra database connectors behave similarly on connector:close and connetor:setkeepalive.

Also adds tests for the mentioned methods + :connect, including tests with ssl connection.

This is continuation of the work to make the fix to #4212 be catched with our test suite, if it ever happens again.

bungle and others added 15 commits January 17, 2019 15:55
Make our methods that return all targets at once to return up
to 1000 at once, instead of the default of 100.
Do not raise an error when the target is not found,
aligning it with other "select" methods.
Changes:

* Returning a negative ttl value from the L3 callback will now make the
  fetched data bypass the cache (it will still be returned by get()). This
  is useful when some fetched data indicates that it is not cacheable.
* When get() returns a value from L2 (shm) during its last millisecond
  of freshness, we do not erroneously cache the value in L1 (LRU)
  indefinitely anymore.
* When get() returns a previously resurrected value from L2 (shm), we
  now correctly set the hit_lvl return value to 4, instead of 2.

Full Changelog:

https://github.com/thibaultcha/lua-resty-mlcache/blob/master/CHANGELOG.md

From #4216
In the init phase, lua-cassandra fallbacks to LuaSocket (since cosockets
are not supported). When we ask Kong to connect to the C* peers over
TLS, we use LuaSec. LuaSec wraps the LuaSocket TCP object (which itself
wraps the kernel socket).

LuaSocket normally returns `1` when calling `sock:close()`, but when
wrapped by LuaSec, the latter dismisses that return value, and thus,
`sslsock:close()` does _not_ return anything.

We could work around this limitation by providing an additional fix to
the pgmoon and lua-cassandra LuaSocket metatable wrappers, but this
commit presents a faster fix for the sake of efficiency, in the spirit
of the 1.0.2 release.

Note also how we changed the return value of `db_conn:close()` to `true`
when no stored connection is found. While not following the initial
design of this API, this changes will help prevent misuses in
higher-level modules (such as the DAO).

Fix #4212
From #4214
There is no need to assert whether we closed the DB connection. If it
isn't the case, this won't prevent Kong from starting nor functioning
normally.
@bungle
Copy link
Member Author

bungle commented Jan 18, 2019

Do not merge yet. I will rebase this on master when #4215 is merged. Or merge this before #4215.

@bungle bungle force-pushed the chore/db-close-keepalive branch 3 times, most recently from 4921f62 to a06044e Compare January 18, 2019 19:50
Make both Postgres and Cassandra database connectors behave
similarly on `connector:close` and `connetor:setkeepalive`.

Also adds tests for the mentioned methods + :connect,
including tests with ssl connection.
@bungle bungle force-pushed the chore/db-close-keepalive branch from a06044e to c81d2c9 Compare January 18, 2019 20:05
thibaultcha pushed a commit that referenced this pull request Jan 18, 2019
Make both Postgres and Cassandra database connectors behave similarly on
`connector:close` and `connetor:setkeepalive`.

Also adds tests for the mentioned methods + :connect, including tests
with ssl connections.

From #4218

Signed-off-by: Thibault Charbonnier <[email protected]>
@thibaultcha
Copy link
Member

Manually merged, thanks!

@bungle bungle deleted the chore/db-close-keepalive branch January 21, 2019 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants