Fix client tracking, also ensure tracking tests are enabled
Former-commit-id: 1938af27f50f9686dc98b4839fb439cc03b4a250
This commit is contained in:
parent
c15802af8b
commit
d7fa406a0e
@ -56,6 +56,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <mutex>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
@ -202,6 +202,9 @@ void trackingRememberKeys(client *c) {
|
|||||||
* to the client as value of the invalidation. This is used in BCAST mode
|
* to the client as value of the invalidation. This is used in BCAST mode
|
||||||
* in order to optimized the implementation to use less CPU time. */
|
* in order to optimized the implementation to use less CPU time. */
|
||||||
void sendTrackingMessage(client *c, const char *keyname, size_t keylen, int proto) {
|
void sendTrackingMessage(client *c, const char *keyname, size_t keylen, int proto) {
|
||||||
|
std::unique_lock<fastlock> ul(c->lock);
|
||||||
|
serverAssert(c->lock.fOwnLock());
|
||||||
|
|
||||||
int using_redirection = 0;
|
int using_redirection = 0;
|
||||||
if (c->client_tracking_redirection) {
|
if (c->client_tracking_redirection) {
|
||||||
client *redir = lookupClientByID(c->client_tracking_redirection);
|
client *redir = lookupClientByID(c->client_tracking_redirection);
|
||||||
@ -210,12 +213,14 @@ void sendTrackingMessage(client *c, const char *keyname, size_t keylen, int prot
|
|||||||
* are unable to send invalidation messages to the redirected
|
* are unable to send invalidation messages to the redirected
|
||||||
* connection, because the client no longer exist. */
|
* connection, because the client no longer exist. */
|
||||||
if (c->resp > 2) {
|
if (c->resp > 2) {
|
||||||
addReplyPushLen(c,3);
|
addReplyPushLenAsync(c,3);
|
||||||
addReplyBulkCBuffer(c,"tracking-redir-broken",21);
|
addReplyBulkCBufferAsync(c,"tracking-redir-broken",21);
|
||||||
addReplyLongLong(c,c->client_tracking_redirection);
|
addReplyLongLongAsync(c,c->client_tracking_redirection);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ul.unlock();
|
||||||
|
ul = std::unique_lock<fastlock>(redir->lock);
|
||||||
c = redir;
|
c = redir;
|
||||||
using_redirection = 1;
|
using_redirection = 1;
|
||||||
}
|
}
|
||||||
@ -225,8 +230,8 @@ void sendTrackingMessage(client *c, const char *keyname, size_t keylen, int prot
|
|||||||
* in Pub/Sub mode, we can support the feature with RESP 2 as well,
|
* in Pub/Sub mode, we can support the feature with RESP 2 as well,
|
||||||
* by sending Pub/Sub messages in the __redis__:invalidate channel. */
|
* by sending Pub/Sub messages in the __redis__:invalidate channel. */
|
||||||
if (c->resp > 2) {
|
if (c->resp > 2) {
|
||||||
addReplyPushLen(c,2);
|
addReplyPushLenAsync(c,2);
|
||||||
addReplyBulkCBuffer(c,"invalidate",10);
|
addReplyBulkCBufferAsync(c,"invalidate",10);
|
||||||
} else if (using_redirection && c->flags & CLIENT_PUBSUB) {
|
} else if (using_redirection && c->flags & CLIENT_PUBSUB) {
|
||||||
/* We use a static object to speedup things, however we assume
|
/* We use a static object to speedup things, however we assume
|
||||||
* that addReplyPubsubMessage() will not take a reference. */
|
* that addReplyPubsubMessage() will not take a reference. */
|
||||||
@ -241,10 +246,10 @@ void sendTrackingMessage(client *c, const char *keyname, size_t keylen, int prot
|
|||||||
|
|
||||||
/* Send the "value" part, which is the array of keys. */
|
/* Send the "value" part, which is the array of keys. */
|
||||||
if (proto) {
|
if (proto) {
|
||||||
addReplyProto(c,keyname,keylen);
|
addReplyProtoAsync(c,keyname,keylen);
|
||||||
} else {
|
} else {
|
||||||
addReplyArrayLen(c,1);
|
addReplyArrayLenAsync(c,1);
|
||||||
addReplyBulkCBuffer(c,keyname,keylen);
|
addReplyBulkCBufferAsync(c,keyname,keylen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ set ::all_tests {
|
|||||||
unit/wait
|
unit/wait
|
||||||
unit/pendingquerybuf
|
unit/pendingquerybuf
|
||||||
unit/tls
|
unit/tls
|
||||||
|
unit/tracking
|
||||||
}
|
}
|
||||||
# Index to the next test to run in the ::all_tests list.
|
# Index to the next test to run in the ::all_tests list.
|
||||||
set ::next_test 0
|
set ::next_test 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user