Title: Using Redis sentinel, some commands 'send' hangs · Issue #92 · cpp-redis/cpp_redis · GitHub
Open Graph Title: Using Redis sentinel, some commands 'send' hangs · Issue #92 · cpp-redis/cpp_redis
X Title: Using Redis sentinel, some commands 'send' hangs · Issue #92 · cpp-redis/cpp_redis
Description: Describe the bug When using Redis sentinel - 1 master, 2 duplicates, 3 sentinels - I can always connect to the (curent) writeable master. However, if I 'stop' that service, the next command hangs. This may not be a bug, maybe it's proper...
Open Graph Description: Describe the bug When using Redis sentinel - 1 master, 2 duplicates, 3 sentinels - I can always connect to the (curent) writeable master. However, if I 'stop' that service, the next command hangs. ...
X Description: Describe the bug When using Redis sentinel - 1 master, 2 duplicates, 3 sentinels - I can always connect to the (curent) writeable master. However, if I 'stop' that service, the next command...
Opengraph URL: https://github.com/cpp-redis/cpp_redis/issues/92
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using Redis sentinel, some commands 'send' hangs","articleBody":"**Describe the bug**\r\nWhen using Redis sentinel - 1 master, 2 duplicates, 3 sentinels - I can always connect to the (curent) writeable master.\r\n\r\nHowever, if I 'stop' that service, the next command hangs.\r\n\r\nThis may not be a bug, maybe it's proper use of Sentinel, but if this is the case the examples and/or docs should probably be updated. I can do a PR if that's the case.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Implement Redis Sentinel\r\n2. Connect to the current master\r\n3. Issue an 'lpop' command:\r\n```\r\n\tredisClient-\u003elpop(GetQueue().toStdString(), [\u0026webReply,\u0026bError](cpp_redis::reply\u0026 charRequest) {\r\n .... stuff ... \r\n\t\t});\r\n\tredisClient-\u003esync_commit(std::chrono::milliseconds(5000)); \r\n```\r\n\r\n4. It works fine.\r\n5. stop the current master. The slaves will fail over and promote a new master.\r\n6. The next 'lpop' command hangs down inside this routine:\r\n```\r\nclient::send(const std::vector\u003cstd::string\u003e \u0026redis_cmd, const reply_callback_t \u0026callback) {\r\n\tstd::lock_guard\u003cstd::mutex\u003e lock_callback(m_callbacks_mutex);\r\n\t__CPP_REDIS_LOG(info, \"cpp_redis::client attempts to store new command in the send buffer\");\r\n\tunprotected_send(redis_cmd, callback);\r\n\t__CPP_REDIS_LOG(info, \"cpp_redis::client stored new command in the send buffer\");\r\n\r\n```\r\n\r\n\r\n**Expected behavior**\r\nI would think issuing any serial commands to a connection that can't take it should result in a tacopie or cpp_redis error being thrown. \r\n\r\n**Possible workaround**\r\nMy routine that does the connect DOES immediately exits out:\r\n```\r\n\tLOG_INFO \u003c\u003c \"Connecting to HA Redis servers with \" \u003c\u003c iSentinels \u003c\u003c \"sentinels\";\r\n\tbool bDisconnect = false;\r\n\tredisClient-\u003econnect(\"ourcluster\", [\u0026bDisconnect](const std::string\u0026 host, std::size_t port, cpp_redis::connect_state status) {\r\n\t\tif (status == cpp_redis::connect_state::dropped) {\r\n\t\t\tLOG_INFO \u003c\u003c \"Client disconnected from \" \u003c\u003c host.c_str() \u003c\u003c \":\" \u003c\u003c port;\r\n```\r\n\r\nThe 'dropped' fires right off, so I could assign a bool value, and then in the outer loop, before every command check to see if we're disconnected - but that seems like a lot of potential boilerplate code.\r\n\r\nI guess I could also just try to reconnect inside the 'connect' callback? Is that the right way to do it? The code example didn't show this\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: [Windows 10]\r\n - Browser [n/a]\r\n - Version [Current]\r\n\r\n","author":{"url":"https://github.com/jgwinner","@type":"Person","name":"jgwinner"},"datePublished":"2022-05-02T04:43:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/92/cpp_redis/issues/92"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1308ce52-2707-96d6-8cc6-db720cc792bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A994:3BFB17:2D46F6C:3A94748:69749EC8 |
| html-safe-nonce | ae908d0c528b665a9414d21d41487d3ee200d27a9879acf583edbb241b0e2812 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTk0OjNCRkIxNzoyRDQ2RjZDOjNBOTQ3NDg6Njk3NDlFQzgiLCJ2aXNpdG9yX2lkIjoiNzI3NTI1NTM4NjYxNTM1NzEyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 772058d598baa97ef319a1d5837b3dc29ec90d9dd129ee09002597cd9d07ce5d |
| hovercard-subject-tag | issue:1222476163 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cpp-redis/cpp_redis/92/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c36af04fcda51e6f456baad71f80091cc40569d1d8fedd157101edd0ef4948fd/cpp-redis/cpp_redis/issues/92 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c36af04fcda51e6f456baad71f80091cc40569d1d8fedd157101edd0ef4948fd/cpp-redis/cpp_redis/issues/92 |
| og:image:alt | Describe the bug When using Redis sentinel - 1 master, 2 duplicates, 3 sentinels - I can always connect to the (curent) writeable master. However, if I 'stop' that service, the next command hangs. ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jgwinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/cpp-redis/cpp_redis git https://github.com/cpp-redis/cpp_redis.git |
| octolytics-dimension-user_id | 45303665 |
| octolytics-dimension-user_login | cpp-redis |
| octolytics-dimension-repository_id | 158901124 |
| octolytics-dimension-repository_nwo | cpp-redis/cpp_redis |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 38889153 |
| octolytics-dimension-repository_parent_nwo | Cylix/cpp_redis |
| octolytics-dimension-repository_network_root_id | 38889153 |
| octolytics-dimension-repository_network_root_nwo | Cylix/cpp_redis |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width