Skip to content

Commit 486a6bb

Browse files
Merge remote-tracking branch 'internal/main'
2 parents 79b0c84 + 70503f6 commit 486a6bb

13 files changed

Lines changed: 120 additions & 68 deletions

build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ machamp:
2121
parent: make-build
2222
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
2323
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
24-
command: ./runtest --clients 4 --verbose
24+
command: ./runtest --clients 4 --verbose --tls
2525
cluster-test:
2626
type: cmd
2727
parent: make-build
2828
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
2929
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
30-
command: ./runtest-cluster
30+
command: ./runtest-cluster --tls
3131
sentinel-test:
3232
type: cmd
3333
parent: make-build

src/SnapshotPayloadParseState.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,33 @@ void SnapshotPayloadParseState::flushQueuedKeys() {
136136
int idb = current_database;
137137
serverAssert(vecqueuedKeys.size() == vecqueuedVals.size());
138138
auto sizePrev = vecqueuedKeys.size();
139-
(*insertsInFlight)++;
140-
std::weak_ptr<std::atomic<int>> insertsInFlightTmp = insertsInFlight; // C++ GRRRRRRRRRRRRRRRR, we don't want to capute "this" because that's dangerous
141139
if (current_database < cserver.dbnum) {
142-
g_pserver->asyncworkqueue->AddWorkFunction([idb, vecqueuedKeys = std::move(this->vecqueuedKeys), vecqueuedKeysCb = std::move(this->vecqueuedKeysCb), vecqueuedVals = std::move(this->vecqueuedVals), vecqueuedValsCb = std::move(this->vecqueuedValsCb), insertsInFlightTmp, pallocator = m_spallocator.release()]() mutable {
143-
g_pserver->db[idb]->bulkDirectStorageInsert(vecqueuedKeys.data(), vecqueuedKeysCb.data(), vecqueuedVals.data(), vecqueuedValsCb.data(), vecqueuedKeys.size());
144-
(*(insertsInFlightTmp.lock()))--;
145-
delete pallocator;
146-
});
140+
if (g_pserver->m_pstorageFactory) {
141+
(*insertsInFlight)++;
142+
std::weak_ptr<std::atomic<int>> insertsInFlightTmp = insertsInFlight; // C++ GRRRRRRRRRRRRRRRR, we don't want to capute "this" because that's dangerous
143+
g_pserver->asyncworkqueue->AddWorkFunction([idb, vecqueuedKeys = std::move(this->vecqueuedKeys), vecqueuedKeysCb = std::move(this->vecqueuedKeysCb), vecqueuedVals = std::move(this->vecqueuedVals), vecqueuedValsCb = std::move(this->vecqueuedValsCb), insertsInFlightTmp, pallocator = m_spallocator.release()]() mutable {
144+
g_pserver->db[idb]->bulkDirectStorageInsert(vecqueuedKeys.data(), vecqueuedKeysCb.data(), vecqueuedVals.data(), vecqueuedValsCb.data(), vecqueuedKeys.size());
145+
(*(insertsInFlightTmp.lock()))--;
146+
delete pallocator;
147+
});
148+
} else {
149+
for (size_t ival = 0; ival < vecqueuedKeys.size(); ++ival) {
150+
size_t offset = 0;
151+
auto spexpire = deserializeExpire(vecqueuedVals[ival], vecqueuedValsCb[ival], &offset);
152+
auto o = deserializeStoredObject(vecqueuedVals[ival] + offset, vecqueuedValsCb[ival] - offset);
153+
sds sdsKey = sdsnewlen(vecqueuedKeys[ival], -static_cast<ssize_t>(vecqueuedKeysCb[ival]));
154+
if (dbMerge(g_pserver->db[idb], sdsKey, o, false)) {
155+
if (spexpire != nullptr)
156+
g_pserver->db[idb]->setExpire(sdsKey, std::move(*spexpire));
157+
} else {
158+
sdsfree(sdsKey);
159+
}
160+
}
161+
vecqueuedKeys.clear();
162+
vecqueuedKeysCb.clear();
163+
vecqueuedVals.clear();
164+
vecqueuedValsCb.clear();
165+
}
147166
} else {
148167
// else drop the data
149168
vecqueuedKeys.clear();

src/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,7 @@ standardConfig configs[] = {
29832983
createIntConfig("overload-protect-percent", NULL, MODIFIABLE_CONFIG, 0, 200, g_pserver->overload_protect_threshold, 0, INTEGER_CONFIG, NULL, NULL),
29842984
createIntConfig("force-eviction-percent", NULL, MODIFIABLE_CONFIG, 0, 100, g_pserver->force_eviction_percent, 0, INTEGER_CONFIG, NULL, NULL),
29852985
createBoolConfig("enable-async-rehash", NULL, MODIFIABLE_CONFIG, g_pserver->enable_async_rehash, 1, NULL, NULL),
2986+
createBoolConfig("enable-keydb-fastsync", NULL, MODIFIABLE_CONFIG, g_pserver->fEnableFastSync, 0, NULL, NULL),
29862987

29872988
#ifdef USE_OPENSSL
29882989
createIntConfig("tls-port", NULL, MODIFIABLE_CONFIG, 0, 65535, g_pserver->tls_port, 0, INTEGER_CONFIG, NULL, updateTLSPort), /* TCP port. */

src/db.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ int expireIfNeeded(redisDb *db, robj *key, robj *o);
5656
void slotToKeyUpdateKeyCore(const char *key, size_t keylen, int add);
5757

5858
std::unique_ptr<expireEntry> deserializeExpire(const char *str, size_t cch, size_t *poffset);
59-
sds serializeStoredObjectAndExpire(robj_roptr o);
6059

6160
dictType dictChangeDescType {
6261
dictSdsHash, /* hash function */

src/networking.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ client *createClient(connection *conn, int iel) {
163163
c->multibulklen = 0;
164164
c->bulklen = -1;
165165
c->sentlen = 0;
166-
c->sentlenAsync = 0;
167166
c->flags = 0;
168167
c->fPendingAsyncWrite = FALSE;
169168
c->fPendingAsyncWriteHandler = FALSE;

src/redis-cli.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,10 @@ static int clusterManagerExecTransaction(clusterManagerNode *node,
25242524

25252525
static int clusterManagerNodeConnect(clusterManagerNode *node) {
25262526
if (node->context) redisFree(node->context);
2527-
node->context = redisConnect(node->ip, node->port);
2527+
struct timeval tv;
2528+
tv.tv_sec = config.cluster_manager_command.timeout / 1000;
2529+
tv.tv_usec = (config.cluster_manager_command.timeout % 1000) * 1000;
2530+
node->context = redisConnectWithTimeout(node->ip, node->port, tv);
25282531
if (!node->context->err && config.tls) {
25292532
const char *err = NULL;
25302533
if (cliSecureConnection(node->context, config.sslconfig, &err) == REDIS_ERR && err) {
@@ -5626,7 +5629,10 @@ static int clusterManagerCommandImport(int argc, char **argv) {
56265629
char *reply_err = NULL;
56275630
redisReply *src_reply = NULL;
56285631
// Connect to the source node.
5629-
redisContext *src_ctx = redisConnect(src_ip, src_port);
5632+
struct timeval tv;
5633+
tv.tv_sec = config.cluster_manager_command.timeout / 1000;
5634+
tv.tv_usec = (config.cluster_manager_command.timeout % 1000) * 1000;
5635+
redisContext *src_ctx = redisConnectWithTimeout(src_ip, src_port, tv);
56305636
if (src_ctx->err) {
56315637
success = 0;
56325638
fprintf(stderr,"Could not connect to KeyDB at %s:%d: %s.\n", src_ip,

0 commit comments

Comments
 (0)