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

test abort #309

Open
wants to merge 5 commits into
base: xredis_2_ror
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install libsnappy-dev zlib1g-dev libstdc++6
make SANTIZER=address -j8
make SANITIZER=address -j8
- name: make test
run: make test-disk

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ifneq (,$(findstring FreeBSD,$(uname_S)))
STD+=-Wno-c11-extensions
endif
endif
WARN=-Wall -W -Wno-missing-field-initializers
WARN=-Wall -W -Wno-missing-field-initializers -Wno-pedantic
OPT=$(OPTIMIZATION)

# Detect if the compiler supports C11 _Atomic
Expand Down
9 changes: 5 additions & 4 deletions src/ctrip_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,11 @@ typedef struct objectMetaType {

typedef struct objectMeta {
uint64_t version;
unsigned swap_type:4;
union {
long long len:60;
unsigned long long ptr:60;
long long len;
unsigned long long ptr;
};
int swap_type;
} objectMeta;

extern objectMetaType lenObjectMetaType;
Expand All @@ -541,12 +541,13 @@ void freeObjectMeta(objectMeta *object_meta);
sds objectMetaEncode(struct objectMeta *object_meta, int meta_enc_mode);
int objectMetaDecode(struct objectMeta *object_meta, const char *extend, size_t extlen);
int keyIsHot(objectMeta *object_meta, robj *value);
int keyIsPureHot(redisDb *db, robj *key);
sds dumpObjectMeta(objectMeta *object_meta);
int objectMetaEqual(struct objectMeta *oma, struct objectMeta *omb);
int objectMetaRebuildFeed(struct objectMeta *rebuild_meta, uint64_t version, const char *subkey, size_t sublen, robj *subval);

static inline void *objectMetaGetPtr(objectMeta *object_meta) {
return (void*)(long)object_meta->ptr;
return (void*)(unsigned long long)object_meta->ptr;
}
static inline void objectMetaSetPtr(objectMeta *object_meta, void *ptr) {
object_meta->ptr = (unsigned long long)ptr;
Expand Down
2 changes: 2 additions & 0 deletions src/ctrip_swap_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ NULL
if (submitUtilTask(ROCKSDB_COMPACT_RANGE_TASK, task, rocksdbCompactRangeTaskDone, task, &error)) {
addReply(c,shared.ok);
} else {
compactTaskFree(task);
addReplyErrorSds(c,error);
}
} else if (!strcasecmp(c->argv[1]->ptr,"flush") && c->argc >= 2) {
Expand Down Expand Up @@ -365,6 +366,7 @@ NULL
if (rdbSaveBackground(server.rdb_filename,rsiptr,sfrctx,1) == C_OK) {
addReplyStatus(c,"Background saving started(rordb mode)");
} else {
swapForkRocksdbCtxRelease(sfrctx);
addReplyErrorObject(c,shared.err);
}
} else if (!strcasecmp(c->argv[2]->ptr,"reload")) {
Expand Down
6 changes: 2 additions & 4 deletions src/ctrip_swap_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int tryLoadKey(redisDb *db, robj *key, int oom_sensitive) {
client *load_client = server.load_clients[db->id];

/* skip pure hot key */
if (lookupKey(db, key, LOOKUP_NOTOUCH) != NULL && lookupMeta(db, key) == NULL) {
if (keyIsPureHot(db, key)) {
return 0;
}

Expand Down Expand Up @@ -166,9 +166,7 @@ int readSwapChildErr(swapRdbSaveErrType *err_type, int *db_id, sds *key) {
if (server.swap_child_err_nread == buf_len) {
/* read swapRdbSaveErr done, make room for key reading */
server.swap_child_err_nread = 0;
key_buffer = sdsempty();
key_buffer = sdsMakeRoomForExact(key_buffer, buffer.klen);
sdssetlen(key_buffer, buffer.klen);
key_buffer = sdsnewlen(SDS_NOINIT, buffer.klen);
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/ctrip_swap_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ int keyIsHot(objectMeta *object_meta, robj *value) {
return swapObjectMetaIsHot(&som);
}

int keyIsPureHot(redisDb *db, robj *key) {
if (lookupKey(db, key, LOOKUP_NOTOUCH) == NULL) {
return 0;
} else {
objectMeta *om = lookupMeta(db, key);
if (om == NULL) {
return 1;
} else if (om->swap_type == SWAP_TYPE_BITMAP && bitmapObjectMetaIsMarker(om)) {
return 1;
} else {
return 0;
}
}
}

struct listMeta;
sds listMetaDump(sds result, struct listMeta *lm);

Expand Down
2 changes: 1 addition & 1 deletion src/ctrip_swap_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static inline void keyLoadFixFeed(struct keyLoadFixData *fix, decodedData *d) {
fix->feed_ok++;
}
if (subval != NULL)
freeStringObject(subval);
decrRefCount(subval);
}

#define FIX_NONE 0
Expand Down
2 changes: 1 addition & 1 deletion src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/* ===================== Creation and parsing of objects ==================== */

robj *createObject(int type, void *ptr) {
robj *o = zmalloc(sizeof(*o));
robj *o = zmalloc(sizeof(robj));
o->type = type;
o->encoding = OBJ_ENCODING_RAW;
o->ptr = ptr;
Expand Down
13 changes: 9 additions & 4 deletions src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,11 @@ int rdbSave(char *filename, rdbSaveInfo *rsi,int rordb) {
int rdbSaveBackground(char *filename, rdbSaveInfo *rsi, struct swapForkRocksdbCtx *sfrctx, int rordb) {
pid_t childpid;

if (hasActiveChildProcess()) return C_ERR;
if (hasActiveChildProcess()) {
swapForkRocksdbCtxRelease(sfrctx);
return C_ERR;
}


server.dirty_before_bgsave = server.dirty;
server.lastbgsave_try = time(NULL);
Expand All @@ -1515,9 +1519,8 @@ int rdbSaveBackground(char *filename, rdbSaveInfo *rsi, struct swapForkRocksdbCt

if (server.swap_mode != SWAP_MODE_MEMORY) {
if (swapForkRocksdbAfterChild(sfrctx)) {
exit(1);
} else {
swapForkRocksdbCtxRelease(sfrctx);
exit(1);
}
}

Expand All @@ -1527,23 +1530,25 @@ int rdbSaveBackground(char *filename, rdbSaveInfo *rsi, struct swapForkRocksdbCt
sendChildInfo(CHILD_INFO_TYPE_SWAP_RDB_SIZE, 0, server.swap_rdb_size, "RDB");
sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB");
}
swapForkRocksdbCtxRelease(sfrctx);
exitFromChild((retval == C_OK) ? 0 : 1);
} else {
/* Parent */
if (server.swap_mode != SWAP_MODE_MEMORY) {
swapForkRocksdbAfterParent(sfrctx,childpid);
swapForkRocksdbCtxRelease(sfrctx);
}

if (childpid == -1) {
server.lastbgsave_status = C_ERR;
serverLog(LL_WARNING,"Can't save in background: fork: %s",
strerror(errno));
swapForkRocksdbCtxRelease(sfrctx);
return C_ERR;
}
serverLog(LL_NOTICE,"Background saving started by pid %ld",(long) childpid);
server.rdb_save_time_start = time(NULL);
server.rdb_child_type = RDB_CHILD_TYPE_DISK;
swapForkRocksdbCtxRelease(sfrctx);
return C_OK;
}
return C_OK; /* unreached */
Expand Down
5 changes: 4 additions & 1 deletion tests/swap/integration/persist.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subk
assert_equal {1} [r bitcount mybitmap0]
r config set swap-evict-step-max-subkeys $bak_evict_step
}
r flushdb
}

start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subkeys-enabled yes}} {
Expand Down Expand Up @@ -406,7 +407,7 @@ start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subk

r config set swap-bitmap-subkey-size $bak_bitmap_subkey_size
}

r flushdb
}

start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subkeys-enabled yes}} {
Expand Down Expand Up @@ -434,6 +435,7 @@ start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subk
wait_key_cold r mybitmap0
r bitcount mybitmap0
}
r flushdb
}

start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subkeys-enabled yes}} {
Expand All @@ -452,5 +454,6 @@ start_server {tags {persist} overrides {swap-persist-enabled yes swap-dirty-subk
after 1500
assert_equal [llength [r swap rio-scan meta {}]] 0
}
r flushdb
}

1 change: 1 addition & 0 deletions tests/swap/integration/rordb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ start_server {tags {"rordb replication"} overrides {}} {
assert_equal [$slave bitcount mybitmap2] {5}

assert_equal [object_meta_pure_cold_subkeys_num $slave mybitmap3] 6

}

$master config set swap-evict-step-max-subkeys $old_swap_max_subkeys
Expand Down
1 change: 0 additions & 1 deletion tests/swap/integration/type_error.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,4 @@ start_server {tags {"repl"}} {

}
}

}
2 changes: 0 additions & 2 deletions tests/swap/unit/ttl_compact.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ start_server {tags {"ttl compact 4"}
# stop sst-age-limit refresh
r config set swap-sst-age-limit-refresh-period 3600

r flushdb

set sst_age_limit [get_info_property r Swap swap_ttl_compact sst_age_limit]
assert_equal $sst_age_limit 0
}
Expand Down
Loading