Add DEBUG_ASSERTIONS option to custom assert (#12667)
This PR introduces a new macro, serverAssertWithInfoDebug, to do complex assertions only for debugging. The main intention is to allow running complex operations during tests without impacting runtime performance. This assertion is enabled when setting DEBUG_ASSERTIONS. The DEBUG_ASSERTIONS flag is set for the daily and CI variants of `test-sanitizer-address`.
This commit is contained in:
parent
9ca8490315
commit
88e83e517b
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make
|
||||
# build with TLS module just for compilation coverage
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-Werror' BUILD_TLS=module
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-Werror -DDEBUG_ASSERTIONS' BUILD_TLS=module
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx -y
|
||||
- name: test
|
||||
|
2
.github/workflows/daily.yml
vendored
2
.github/workflows/daily.yml
vendored
@ -587,7 +587,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-DREDIS_TEST -Werror'
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-DREDIS_TEST -Werror -DDEBUG_ASSERTIONS'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
1
src/db.c
1
src/db.c
@ -304,6 +304,7 @@ int getKeySlot(sds key) {
|
||||
* the key slot would fallback to calculateKeySlot.
|
||||
*/
|
||||
if (server.current_client && server.current_client->slot >= 0 && server.current_client->flags & CLIENT_EXECUTING_COMMAND) {
|
||||
debugServerAssertWithInfo(server.current_client, NULL, calculateKeySlot(key)==server.current_client->slot);
|
||||
return server.current_client->slot;
|
||||
}
|
||||
return calculateKeySlot(key);
|
||||
|
@ -673,6 +673,14 @@ typedef enum {
|
||||
#define serverAssert(_e) (likely(_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redis_unreachable()))
|
||||
#define serverPanic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redis_unreachable()
|
||||
|
||||
/* The following macros provide assertions that are only executed during test builds and should be used to add
|
||||
* assertions that are too computationally expensive or dangerous to run during normal operations. */
|
||||
#ifdef DEBUG_ASSERTIONS
|
||||
#define debugServerAssertWithInfo(...) serverAssertWithInfo(__VA_ARGS__)
|
||||
#else
|
||||
#define debugServerAssertWithInfo(...)
|
||||
#endif
|
||||
|
||||
/* latency histogram per command init settings */
|
||||
#define LATENCY_HISTOGRAM_MIN_VALUE 1L /* >= 1 nanosec */
|
||||
#define LATENCY_HISTOGRAM_MAX_VALUE 1000000000L /* <= 1 secs */
|
||||
|
Loading…
x
Reference in New Issue
Block a user