Skip to content

Commit 12164ab

Browse files
committed
CCBC-1664: register read event watcher for KV socket if duplex is enabled
When the cluster is 7.6.5+ and support Faster Failover, libcouchbase would automatically disable config polling mechanism and eventually remove all event watchers for KV sockets, if there is no KV traffic (e.g. the application only doing Query or Search requests). If the cluster will be reconfigured during this time, the libcouchbase will not pick up new topology and continue using previous set of the endpoints. Change-Id: I4f0460bd6697c7b7987992a53cadde5b1e1d9a44 Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/228199 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Dimitris Christodoulou <dimitris.christodoulou@couchbase.com>
1 parent dd6756e commit 12164ab

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/mcserver/mcserver.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ static void on_read(lcbio_CTX *ctx, unsigned)
746746

747747
while (server->try_read(ctx, ior) == Server::PKT_READ_COMPLETE)
748748
;
749+
if (server->supports_duplex()) {
750+
lcbio_ctx_rwant(ctx, 24);
751+
}
749752
lcbio_ctx_schedule(ctx);
750753
lcb_maybe_breakout(server->instance);
751754
}
@@ -1127,6 +1130,7 @@ void Server::handle_connected(lcbio_SOCKET *sock, lcb_STATUS err, lcbio_OSERR sy
11271130
} else if (settings->conntype == LCB_TYPE_BUCKET && settings->bucket) {
11281131
try_to_select_bucket = true;
11291132
}
1133+
duplex = sessinfo->has_feature(PROTOCOL_BINARY_FEATURE_DUPLEX);
11301134
clustermap_change_notification =
11311135
sessinfo->has_feature(PROTOCOL_BINARY_FEATURE_CLUSTERMAP_CHANGE_NOTIFICATION_BRIEF);
11321136
config_with_known_version =

src/mcserver/mcserver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ class Server : public mc_PIPELINE
141141
return clustermap_change_notification;
142142
}
143143

144+
bool supports_duplex() const
145+
{
146+
return duplex;
147+
}
148+
144149
/**
145150
* If true, the library will always send version of current configuration, which allows KV engine skip payload in
146151
* response, if it does not have newer version.
@@ -258,6 +263,9 @@ class Server : public mc_PIPELINE
258263
/** Whether GetClusterConfigWithKnownVersion is supported */
259264
short config_with_known_version{0};
260265

266+
/** Whether the connection supports unsolicited packets from the server */
267+
short duplex{0};
268+
261269
lcbio_CTX *connctx;
262270
lcb::io::ConnectionRequest *connreq{};
263271

0 commit comments

Comments
 (0)