Skip to content

Commit

Permalink
[fix] CI asan check
Browse files Browse the repository at this point in the history
  • Loading branch information
VCgege committed Dec 16, 2024
1 parent 5ce5c10 commit c2da951
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 48 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: CI

on:
push:
branches: [ xredis_2_ror ]
branches: [ xredis_2_ror,xredis_2_ror_v1 ]
pull_request:
branches: [ xredis_2_ror ]
branches: [ xredis_2_ror,xredis_2_ror_v1 ]

jobs:
unit:
strategy:
matrix:
platform: [ubuntu-22.04]
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand All @@ -19,14 +19,16 @@ jobs:
- name: get rocksdb sha
id: rocksdb-sha
run: |
echo "::set-output name=sha::$(cd deps/rocksdb && git rev-parse HEAD)"
ROCKSDB_SHA=$(cd deps/rocksdb && git rev-parse HEAD)
echo "ROCKSDB_SHA is $ROCKSDB_SHA"
echo "ROCKSDB_SHA=$ROCKSDB_SHA" >> $GITHUB_ENV
shell: bash
- name: cache rocksdb
id: cache-rocksdb
uses: actions/cache@v3
with:
path: deps/rocksdb
key: ${{ runner.os }}-rocksdb-${{ steps.rocksdb-sha.outputs.sha }}
key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_SHA }}
- name: unit-test
run: |
sudo apt-get update
Expand All @@ -35,7 +37,7 @@ jobs:
mem:
strategy:
matrix:
platform: [ubuntu-22.04]
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand All @@ -44,14 +46,16 @@ jobs:
- name: get rocksdb sha
id: rocksdb-sha
run: |
echo "::set-output name=sha::$(cd deps/rocksdb && git rev-parse HEAD)"
ROCKSDB_SHA=$(cd deps/rocksdb && git rev-parse HEAD)
echo "ROCKSDB_SHA is $ROCKSDB_SHA"
echo "ROCKSDB_SHA=$ROCKSDB_SHA" >> $GITHUB_ENV
shell: bash
- name: cache rocksdb
id: cache-rocksdb
uses: actions/cache@v3
with:
path: deps/rocksdb
key: ${{ runner.os }}-rocksdb-${{ steps.rocksdb-sha.outputs.sha }}
key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_SHA }}
- name: make
run: |
sudo apt-get update
Expand All @@ -62,7 +66,7 @@ jobs:
swap:
strategy:
matrix:
platform: [ubuntu-22.04]
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand All @@ -71,14 +75,16 @@ jobs:
- name: get rocksdb sha
id: rocksdb-sha
run: |
echo "::set-output name=sha::$(cd deps/rocksdb && git rev-parse HEAD)"
ROCKSDB_SHA=$(cd deps/rocksdb && git rev-parse HEAD)
echo "ROCKSDB_SHA is $ROCKSDB_SHA"
echo "ROCKSDB_SHA=$ROCKSDB_SHA" >> $GITHUB_ENV
shell: bash
- name: cache rocksdb
id: cache-rocksdb
uses: actions/cache@v3
with:
path: deps/rocksdb
key: ${{ runner.os }}-rocksdb-${{ steps.rocksdb-sha.outputs.sha }}
key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_SHA }}
- name: make
run: |
sudo apt-get update
Expand All @@ -89,7 +95,7 @@ jobs:
swap-asan:
strategy:
matrix:
platform: [ubuntu-22.04]
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand All @@ -98,20 +104,22 @@ jobs:
- name: get rocksdb sha
id: rocksdb-sha
run: |
echo "::set-output name=sha::$(cd deps/rocksdb && git rev-parse HEAD)"
ROCKSDB_SHA=$(cd deps/rocksdb && git rev-parse HEAD)
echo "ROCKSDB_SHA is $ROCKSDB_SHA"
echo "ROCKSDB_SHA=$ROCKSDB_SHA" >> $GITHUB_ENV
shell: bash
- name: cache rocksdb
id: cache-rocksdb
uses: actions/cache@v3
with:
path: deps/rocksdb
key: ${{ runner.os }}-rocksdb-${{ steps.rocksdb-sha.outputs.sha }}
key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_SHA }}
- name: make
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
run: make test-asan-disk


4 changes: 2 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
- name: test
run: |
sudo apt-get install tcl8.6 tclx -y
./runtest --swap-mode disk --accurate --verbose --dump-logs
./runtest --swap-mode disk --tags -nosanitizer --accurate --verbose --dump-logs
- name: unittest
run: ./src/redis-server test all

Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
- name: test
run: |
sudo apt-get install tcl8.6 tclx -y
./runtest --swap-mode disk --accurate --verbose --dump-logs
./runtest --swap-mode disk --tags -nosanitizer --accurate --verbose --dump-logs
- name: unittest
run: ./src/redis-server test all

Expand Down
11 changes: 8 additions & 3 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,24 @@ jemalloc: .make-prerequisites

# -Wno-unused-but-set-variable: meaning do not report warning when meeting unused but set variable
# -Wno-error: meaning do not report error when meeting warnings
# In ubuntu 24.04, do not compile rocksdb with sanitizer, which will cause sanitizer internal crash.
CFLAGS += -Wno-unused-but-set-variable -Wno-error
ROCKSDB_CFLAGS = $(CFLAGS)
ROCKSDB_BUILD_FLAGS=ROCKSDB_DISABLE_BZIP=1 ROCKSDB_DISABLE_LZ4=1 ROCKSDB_DISABLE_ZSTD=1 ROCKSDB_DISABLE_MALLOC_USABLE_SIZE=1 ROCKSDB_DISABLE_MEMKIND=1 PORTABLE=1 ROCKSDB_USE_IO_URING=0

rocksdb: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd rocksdb && ROCKSDB_DISABLE_BZIP=1 ROCKSDB_DISABLE_LZ4=1 ROCKSDB_DISABLE_ZSTD=1 ROCKSDB_DISABLE_MALLOC_USABLE_SIZE=1 ROCKSDB_DISABLE_MEMKIND=1 PORTABLE=1 ROCKSDB_USE_IO_URING=0 $(MAKE) CFLAGS="$(ROCKSDB_CFLAGS)" static_lib
cd rocksdb && $(ROCKSDB_BUILD_FLAGS) $(MAKE) CFLAGS="$(ROCKSDB_CFLAGS)" static_lib

.PHONY: rocksdb


XREDIS_GTID_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS) -I../../src -DUSE_JEMALLOC -I../jemalloc/include -DGTID_MALLOC_INCLUDE=\<gtid_zmalloc.h\>
XREDIS_GTID_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS)
XREDIS_GTID_LDFLAGS= $(LDFLAGS)

ifndef SANITIZER
XREDIS_GTID_CFLAGS+=-I../../src -DUSE_JEMALLOC -I../jemalloc/include -DGTID_MALLOC_INCLUDE=\<gtid_zmalloc.h\>
endif

xredis-gtid: jemalloc .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd xredis-gtid && $(MAKE) CFLAGS="$(XREDIS_GTID_CFLAGS)" LDFLAGS="$(XREDIS_GTID_LDFLAGS)"
Expand Down
2 changes: 1 addition & 1 deletion deps/xredis-gtid
7 changes: 6 additions & 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 Expand Up @@ -85,6 +85,8 @@ ifeq ($(USE_JEMALLOC),no)
MALLOC=libc
endif

export LSAN_OPTIONS=suppressions=suppr.txt

ifdef SANITIZER
ifeq ($(SANITIZER),address)
MALLOC=libc
Expand Down Expand Up @@ -423,6 +425,9 @@ test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) $(REDIS_CLI_NAME) $(REDIS_BEN
test-disk: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME)
@(cd ..; ./runtest --swap-mode disk)

test-asan-disk: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME)
@(cd ..; ./runtest --swap-mode disk --tags -nosanitizer)

test-modules: $(REDIS_SERVER_NAME)
@(cd ..; ./runtest-moduleapi)

Expand Down
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ standardConfig configs[] = {
createULongLongConfig("rocksdb.data.blob_file_size", "rocksdb.blob_file_size", MODIFIABLE_CONFIG, 0, ULLONG_MAX, server.rocksdb_data_blob_file_size, 256*1024*1024, MEMORY_CONFIG, NULL, updateRocksdbDataBlobFileSize),
createULongLongConfig("rocksdb.meta.blob_file_size", NULL, MODIFIABLE_CONFIG, 0, ULLONG_MAX, server.rocksdb_meta_blob_file_size, 256*1024*1024, MEMORY_CONFIG, NULL, updateRocksdbMetaBlobFileSize),
createULongLongConfig("swap-repl-rordb-max-write-bps", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.swap_repl_rordb_max_write_bps, 200*1024*1024, MEMORY_CONFIG, NULL, NULL),
createULongLongConfig("swap-ttl-compact-period", NULL, MODIFIABLE_CONFIG, 1, 3600*24, server.swap_ttl_compact_period, 60*8, INTEGER_CONFIG, NULL, NULL),
createULongLongConfig("swap-ttl-compact-period", NULL, MODIFIABLE_CONFIG, 1, 3600*24, server.swap_ttl_compact_period, 60, INTEGER_CONFIG, NULL, NULL),
createULongLongConfig("swap-sst-age-limit-refresh-period", NULL, MODIFIABLE_CONFIG, 1, 3600*24, server.swap_sst_age_limit_refresh_period, 60, INTEGER_CONFIG, NULL, NULL),
createULongLongConfig("swap-swap-info-slave-period", NULL, MODIFIABLE_CONFIG, 1, 3600*24, server.swap_swap_info_slave_period, 60, INTEGER_CONFIG, NULL, NULL),

Expand Down
3 changes: 2 additions & 1 deletion src/ctrip_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(objectMeta *object_meta, robj *value);
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
4 changes: 2 additions & 2 deletions src/ctrip_swap_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ void swapRequestExecuteUtil_CompactRange(swapRequest *req) {
long size_after = get_dir_size(dir);
serverLog(LL_WARNING, "[rocksdb compact range after] dir(%s) size(%ld)", dir, size_after);

if (server.swap_ttl_compact_ctx && task->compact_type == TYPE_TTL_COMPACT) {
atomicIncr(server.swap_ttl_compact_ctx->stat_compacted_data_size, size_after - size_before);
if (server.swap_ttl_compact_ctx && task->compact_type == TYPE_TTL_COMPACT && size_before > size_after) {
atomicIncr(server.swap_ttl_compact_ctx->stat_compacted_data_size, size_before - size_after);
}
serverRocksUnlock(rocks);
}
Expand Down
8 changes: 4 additions & 4 deletions src/ctrip_swap_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ 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) {
robj *value = lookupKey(db, key, LOOKUP_NOTOUCH);
objectMeta *object_meta = lookupMeta(db, key);
if (keyIsPureHot(object_meta, value)) {
return 0;
}

Expand Down Expand Up @@ -166,9 +168,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
14 changes: 14 additions & 0 deletions src/ctrip_swap_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ int keyIsHot(objectMeta *object_meta, robj *value) {
return swapObjectMetaIsHot(&som);
}

int keyIsPureHot(objectMeta *object_meta, robj *value) {
if (value == NULL) {
return 0;
} else {
if (object_meta == NULL) {
return 1;
} else if (object_meta->swap_type == SWAP_TYPE_BITMAP && bitmapObjectMetaIsMarker(object_meta)) {
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
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: 5 additions & 0 deletions src/suppr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
leak:hashTypeConvertZiplist
leak:^listMetaCreate$
leak:^bitmapMetaCreate$
leak:^bitmapMetaDecode$
leak:^bitmapMetaDup$
3 changes: 2 additions & 1 deletion tests/integration/logging.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ if {$system_supported} {
}

# Valgrind will complain that the process terminated by a signal, skip it.
# Sanitizer will cause unknown crash, which seems a problem of gcc or sanitizer, skip it.
if {!$::valgrind} {
set server_path [tmpdir server1.log]
start_server [list overrides [list dir $server_path]] {
start_server [list overrides [list dir $server_path] tags {"nosanitizer"}] {
test "Crash report generated on SIGABRT" {
set pid [s process_id]
exec kill -SIGABRT $pid
Expand Down
5 changes: 2 additions & 3 deletions tests/swap/integration/client_rate_limit_bug.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ proc format_command {args} {
}
set _ $cmd
}
start_server [list overrides [list save ""] ] {

start_server [list overrides [list save ""] tags {"nosanitizer"}] {
set master [srv 0 client]
$master config set swap-ratelimit-maxmemory-percentage 100
$master config set maxmemory-policy allkeys-lru
Expand All @@ -38,7 +37,7 @@ start_server [list overrides [list save ""] ] {
} else {
fail "Fail to full sync"
}

for {set j 0} {$j < 20} {incr j} {
set ele [lindex $load_handles $j]
stop_bg_complex_data $ele
Expand Down
Loading

0 comments on commit c2da951

Please sign in to comment.