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

When Cassandra is temporarily down make sure the connection is resumed #11

Closed
subnetmarco opened this issue Feb 11, 2015 · 4 comments · Fixed by #146 or #187
Closed

When Cassandra is temporarily down make sure the connection is resumed #11

subnetmarco opened this issue Feb 11, 2015 · 4 comments · Fixed by #146 or #187
Assignees
Labels
Milestone

Comments

@subnetmarco
Copy link
Member

It may happen because of network issues, and we need to make sure it doesn't crash the application but it logs the error and resumes the connection as soon as it's available again.

Make sure that when testing this nginx runs with daemon on;.

@thibaultcha thibaultcha added this to the v0.2 (public beta release) milestone Feb 19, 2015
@thibaultcha
Copy link
Member

#28 now uses the cosocket API. So we might loose some queries but the connection will be resumed as soon as cassandra is reachable again. Now we need to know if this doesn't throw any unexpected errors that could disturb the execution of plugins not using the DB.

@subnetmarco
Copy link
Member Author

Right now this doesn't happen. Connection to Cassandra is never resumed and nginx logs the following error:

2015/02/24 00:35:42 [error] 19605#0: *1 [lua] access.lua:28: execute(): Cassandra returned error (Unprepared): "Prepared query with ID 29083996e2fe585226bc6e89ae37c690 not found (either the query was not prepared on this host (maybe the host has been restarted?) or you have prepared too many queries and it has been evicted from the internal cache)", client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8000"

@thibaultcha
Copy link
Member

if the cluster shuts down and restarts, prepared queries are dropped and need to be re-prepared.

@thibaultcha thibaultcha removed the TODO label Mar 25, 2015
@thibaultcha thibaultcha modified the milestones: 0.1.0-beta, 1.0.0 Mar 27, 2015
@thibaultcha
Copy link
Member

BTW, re-reading the issue: it won't cause any issue if cassandra is unreachable because of network issues beyond dropping the queries.

It will only be a more critical issue if cassandra was restarted for some reason, because the statements aren't prepared anymore, resulting in errors and no query will succeed.

@thibaultcha thibaultcha reopened this Apr 22, 2015
@subnetmarco subnetmarco modified the milestones: 0.2.1, 0.2.0 Apr 24, 2015
thibaultcha added a commit that referenced this issue Apr 30, 2015
If Cassandra returns an unprepared error, the DAO will re-prepare it
and try the query again. This fixes #11, and handles the case where
Cassandra would go down, and then up again while Kong is still running.

Other changes:

- docs: base_dao and the factory have been given a better documentation.
- refactor:
  - `kong_query` is now the prefered term for _queries elements.
  - `params` becomes `args_keys` and `values` `args` for consistance with the driver.
  - The `_execute` method was renamed to `_execute_kong_query` and broken into smaller chunks.
  - Batch statements now need to use the raw `_execute` method (the new one, not the one renamed to `_execute_kong_query`.
  - Cassandra errors now also have the error code.
thibaultcha added a commit that referenced this issue Apr 30, 2015
If Cassandra returns an unprepared error, the DAO will re-prepare it
and try the query again. This fixes #11, and handles the case where
Cassandra would go down, and then up again while Kong is still running.

Other changes:

- docs: base_dao and the factory have been given a better documentation.
- refactor:
  - `kong_query` is now the prefered term for _queries elements.
  - `params` becomes `args_keys` and `values` `args` for consistance with the driver.
  - The `_execute` method was renamed to `_execute_kong_query` and broken into smaller chunks.
  - Batch statements now need to use the raw `_execute` method (the new one, not the one renamed to `_execute_kong_query`.
  - Cassandra errors now also have the error code.
thibaultcha added a commit that referenced this issue Apr 30, 2015
If Cassandra returns an unprepared error, the DAO will re-prepare it
and try the query again. This fixes #11, and handles the case where
Cassandra would go down, and then up again while Kong is still running.

Other changes:

- docs: base_dao and the factory have been given a better documentation.
- refactor:
  - `kong_query` is now the prefered term for _queries elements.
  - `params` becomes `args_keys` and `values` `args` for consistance with the driver.
  - The `_execute` method was renamed to `_execute_kong_query` and broken into smaller chunks.
  - Batch statements now need to use the raw `_execute` method (the new one, not the one renamed to `_execute_kong_query`.
  - Cassandra errors now also have the error code.
thibaultcha added a commit that referenced this issue Apr 30, 2015
[feature] support unprepared statement errors. fix #11
ctranxuan pushed a commit to streamdataio/kong that referenced this issue Aug 25, 2015
If Cassandra returns an unprepared error, the DAO will re-prepare it
and try the query again. This fixes Kong#11, and handles the case where
Cassandra would go down, and then up again while Kong is still running.

Other changes:

- docs: base_dao and the factory have been given a better documentation.
- refactor:
  - `kong_query` is now the prefered term for _queries elements.
  - `params` becomes `args_keys` and `values` `args` for consistance with the driver.
  - The `_execute` method was renamed to `_execute_kong_query` and broken into smaller chunks.
  - Batch statements now need to use the raw `_execute` method (the new one, not the one renamed to `_execute_kong_query`.
  - Cassandra errors now also have the error code.
ctranxuan pushed a commit to streamdataio/kong that referenced this issue Aug 25, 2015
[feature] support unprepared statement errors. fix Kong#11
gszr pushed a commit that referenced this issue Jun 17, 2021
)

It is no longer needed as service mesh support is removed from Kong
gszr pushed a commit that referenced this issue Aug 18, 2021
* fix(session) do not try to use body if it cannot be read on logout
* chore(session) 2.1.1
gszr pushed a commit that referenced this issue Oct 28, 2021
… schema (#11)

It is no longer needed as service mesh support is removed from Kong
hutchic pushed a commit that referenced this issue Jun 10, 2022
### Summary

Before this commit:

```
patching file LuaJIT-2.1-20190507/src/lj_tab.c
patching file LuaJIT-2.1-20190507/src/lj_asm_arm.h
patching file LuaJIT-2.1-20190507/src/lj_api.c
patching file LuaJIT-2.1-20190507/src/lj_arch.h
patching file LuaJIT-2.1-20190507/src/lj_cconv.c
patching file LuaJIT-2.1-20190507/src/lj_obj.h
patching file LuaJIT-2.1-20190507/src/lj_state.c
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/ngx/balancer.lua
patching file lua-resty-websocket-0.07/lib/resty/websocket/client.lua
patching file nginx-1.15.8/src/http/ngx_http_upstream.c
Hunk #2 succeeded at 1691 (offset -3 lines).
Hunk #4 succeeded at 1768 (offset -7 lines).
patching file nginx-1.15.8/src/http/ngx_http_special_response.c
patching file nginx-1.15.8/src/stream/ngx_stream_proxy_module.c
Hunk #2 succeeded at 802 (offset 20 lines).
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
Hunk #5 succeeded at 1556 (offset 48 lines).
Hunk #6 succeeded at 1626 (offset 48 lines).
Hunk #7 succeeded at 1726 (offset 48 lines).
Hunk #8 succeeded at 1749 (offset 48 lines).
Hunk #9 succeeded at 1760 (offset 48 lines).
Hunk #10 succeeded at 1775 (offset 48 lines).
Hunk #11 succeeded at 1816 (offset 48 lines).
Hunk #12 succeeded at 1827 (offset 48 lines).
Hunk #13 succeeded at 1849 (offset 48 lines).
Hunk #14 succeeded at 1868 (offset 48 lines).
Hunk #15 succeeded at 1878 (offset 48 lines).
Hunk #16 succeeded at 2008 (offset 48 lines).
Hunk #17 succeeded at 6101 (offset 62 lines).
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.h
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
Hunk #1 succeeded at 1647 (offset 48 lines).
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
Hunk #3 succeeded at 1579 (offset 48 lines).
Hunk #4 succeeded at 1644 (offset 48 lines).
Hunk #5 succeeded at 1668 (offset 48 lines).
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
Hunk #1 succeeded at 1756 (offset 48 lines).
patching file ngx_lua-0.10.15/src/ngx_http_lua_balancer.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_common.h
patching file ngx_lua-0.10.15/src/ngx_http_lua_module.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_string.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_control.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_variable.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_common.h
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_util.c
patching file ngx_stream_lua-0.0.7/src/api/ngx_stream_lua_api.h
```

vs. (after this commit)

```
patching file LuaJIT-2.1-20190507/src/lj_tab.c
patching file LuaJIT-2.1-20190507/src/lj_asm_arm.h
patching file LuaJIT-2.1-20190507/src/lj_api.c
patching file LuaJIT-2.1-20190507/src/lj_arch.h
patching file LuaJIT-2.1-20190507/src/lj_cconv.c
patching file LuaJIT-2.1-20190507/src/lj_obj.h
patching file LuaJIT-2.1-20190507/src/lj_state.c
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/resty/core.lua
patching file lua-resty-core-0.1.17/lib/resty/core/socket_tcp.lua
patching file lua-resty-core-0.1.17/lib/ngx/balancer.lua
patching file lua-resty-websocket-0.07/lib/resty/websocket/client.lua
patching file nginx-1.15.8/src/http/ngx_http_upstream.c
patching file nginx-1.15.8/src/http/ngx_http_special_response.c
patching file nginx-1.15.8/src/stream/ngx_stream_proxy_module.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.h
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_socket_tcp.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_balancer.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_common.h
patching file ngx_lua-0.10.15/src/ngx_http_lua_module.c
patching file ngx_lua-0.10.15/src/ngx_http_lua_string.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_control.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_variable.c
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_common.h
patching file ngx_stream_lua-0.0.7/src/ngx_stream_lua_util.c
patching file ngx_stream_lua-0.0.7/src/api/ngx_stream_lua_api.h
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants