Skip to content

Conversation

@sundb
Copy link
Collaborator

@sundb sundb commented Aug 17, 2024

This is a missing of the PR #13383.
We will call functionsLibCtxClear() in bio, so we shouldn't touch curr_functions_lib_ctx in it.

Reproduce:

make distclean && make SANITIZER=thread && ./runtest --config io-threads 4 --config io-threads-do-reads yes --single unit/functions

Report:

WARNING: ThreadSanitizer: data race (pid=19476)
  Write of size 8 at 0x7f73cadcead0 by thread T3:
    #0 functionsLibCtxClear /home/sundb/data/redis_fork/src/functions.c:174 (redis-server+0x224aac)
    #1 functionsLibCtxFree /home/sundb/data/redis_fork/src/functions.c:191 (redis-server+0x224aac)
    #2 lazyFreeFunctionsCtx /home/sundb/data/redis_fork/src/lazyfree.c:77 (redis-server+0x224aac)
    #3 bioProcessBackgroundJobs /home/sundb/data/redis_fork/src/bio.c:335 (redis-server+0x1e7908)

  Previous write of size 8 at 0x7f73cadcead0 by main thread (mutexes: write M65, write M134, write M136, write M138):
    #0 libraryUnlink /home/sundb/data/redis_fork/src/functions.c:281 (redis-server+0x2c3f50)
    #1 functionsCreateWithLibraryCtx /home/sundb/data/redis_fork/src/functions.c:978 (redis-server+0x2ca98c)
    #2 functionLoadCommand /home/sundb/data/redis_fork/src/functions.c:1054 (redis-server+0x2cb5f2)
    #3 call /home/sundb/data/redis_fork/src/server.c:3575 (redis-server+0xba513)
    #4 processCommand /home/sundb/data/redis_fork/src/server.c:4206 (redis-server+0xbd5ef)
    #5 processCommandAndResetClient /home/sundb/data/redis_fork/src/networking.c:2505 (redis-server+0xf7133)
    #6 processInputBuffer /home/sundb/data/redis_fork/src/networking.c:2613 (redis-server+0xf7133)
    #7 readQueryFromClient /home/sundb/data/redis_fork/src/networking.c:2759 (redis-server+0xf7f2f)
    #8 callHandler /home/sundb/data/redis_fork/src/connhelpers.h:58 (redis-server+0x2b4a72)
    #9 connSocketEventHandler /home/sundb/data/redis_fork/src/socket.c:277 (redis-server+0x2b4a72)
    #10 aeProcessEvents /home/sundb/data/redis_fork/src/ae.c:417 (redis-server+0x9a805)
    #11 aeMain /home/sundb/data/redis_fork/src/ae.c:477 (redis-server+0x9a805)
    #12 main /home/sundb/data/redis_fork/src/server.c:7251 (redis-server+0x886c5)

@sundb sundb merged commit 6c64892 into redis:unstable Aug 19, 2024
@sundb sundb deleted the race_lib_ctx branch August 19, 2024 02:11
@YaacovHazan YaacovHazan mentioned this pull request Sep 11, 2024
YaacovHazan added a commit that referenced this pull request Sep 12, 2024
### New Features in binary distributions

- 7 new data structures: JSON, Time series, Bloom filter, Cuckoo filter,
Count-min sketch, Top-k, t-digest
- Redis scalable query engine (including vector search)

### Potentially breaking changes

- #12272 `GETRANGE` returns an empty bulk when the negative end index is
out of range
- #12395 Optimize `SCAN` command when matching data type

### Bug fixes

- #13510 Fix `RM_RdbLoad` to enable AOF after RDB loading is completed
- #13489 `ACL CAT` - return module commands
- #13476 Fix a race condition in the `cache_memory` of `functionsLibCtx`
- #13473 Fix incorrect lag due to trimming stream via `XTRIM` command
- #13338 Fix incorrect lag field in `XINFO` when tombstone is after the
`last_id` of the consume group
- #13470 On `HDEL` of last field - update the global hash field
expiration data structure
- #13465 Cluster: Pass extensions to node if extension processing is
handled by it
- #13443 Cluster: Ensure validity of myself when loading cluster config
- #13422 Cluster: Fix `CLUSTER SHARDS` command returns empty array

### Modules API

- #13509 New API calls: `RM_DefragAllocRaw`, `RM_DefragFreeRaw`, and
`RM_RegisterDefragCallbacks` - defrag API to allocate and free raw
memory

### Performance and resource utilization improvements

- #13503 Avoid overhead of comparison function pointer calls in listpack
`lpFind`
- #13505 Optimize `STRING` datatype write commands
- #13499 Optimize `SMEMBERS` command
- #13494 Optimize `GEO*` commands reply
- #13490 Optimize `HELLO` command
- #13488 Optimize client query buffer
- #12395 Optimize `SCAN` command when matching data type
- #13529 Optimize `LREM`, `LPOS`, `LINSERT`, and `LINDEX` commands
- #13516 Optimize `LRANGE` and other commands that perform several
writes to client buffers per call
- #13431 Avoid `used_memory` contention when updating from multiple
threads

### Other general improvements

- #13495 Reply `-LOADING` on replica while flushing the db

### CLI tools

- #13411 redis-cli: Fix wrong `dbnum` showed after the client
reconnected

### Notes

- No backward compatibility for replication or persistence.
- Additional distributions, upgrade paths, features, and improvements
will be introduced in upcoming pre-releases.
- With the GA release of 8.0 we will deprecate Redis Stack.
YaacovHazan pushed a commit that referenced this pull request Nov 4, 2024
…3476)

This is a missing of the PR #13383.
We will call `functionsLibCtxClear()` in bio, so we shouldn't touch
`curr_functions_lib_ctx` in it.
This was referenced Nov 4, 2024
YaacovHazan pushed a commit that referenced this pull request Jan 6, 2025
…3476)

This is a missing of the PR #13383.
We will call `functionsLibCtxClear()` in bio, so we shouldn't touch
`curr_functions_lib_ctx` in it.
@YaacovHazan YaacovHazan moved this from Todo to Done in Redis 7.4 Backport Apr 21, 2025
@sundb sundb added this to Redis 8.0 Aug 15, 2025
@sundb sundb removed this from Redis 8.2 Aug 15, 2025
@sundb sundb moved this from Todo to Done in Redis 8.0 Aug 15, 2025
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
…dis#13476)

This is a missing of the PR redis#13383.
We will call `functionsLibCtxClear()` in bio, so we shouldn't touch
`curr_functions_lib_ctx` in it.
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
### New Features in binary distributions

- 7 new data structures: JSON, Time series, Bloom filter, Cuckoo filter,
Count-min sketch, Top-k, t-digest
- Redis scalable query engine (including vector search)

### Potentially breaking changes

- redis#12272 `GETRANGE` returns an empty bulk when the negative end index is
out of range
- redis#12395 Optimize `SCAN` command when matching data type

### Bug fixes

- redis#13510 Fix `RM_RdbLoad` to enable AOF after RDB loading is completed
- redis#13489 `ACL CAT` - return module commands
- redis#13476 Fix a race condition in the `cache_memory` of `functionsLibCtx`
- redis#13473 Fix incorrect lag due to trimming stream via `XTRIM` command
- redis#13338 Fix incorrect lag field in `XINFO` when tombstone is after the
`last_id` of the consume group
- redis#13470 On `HDEL` of last field - update the global hash field
expiration data structure
- redis#13465 Cluster: Pass extensions to node if extension processing is
handled by it
- redis#13443 Cluster: Ensure validity of myself when loading cluster config
- redis#13422 Cluster: Fix `CLUSTER SHARDS` command returns empty array

### Modules API

- redis#13509 New API calls: `RM_DefragAllocRaw`, `RM_DefragFreeRaw`, and
`RM_RegisterDefragCallbacks` - defrag API to allocate and free raw
memory

### Performance and resource utilization improvements

- redis#13503 Avoid overhead of comparison function pointer calls in listpack
`lpFind`
- redis#13505 Optimize `STRING` datatype write commands
- redis#13499 Optimize `SMEMBERS` command
- redis#13494 Optimize `GEO*` commands reply
- redis#13490 Optimize `HELLO` command
- redis#13488 Optimize client query buffer
- redis#12395 Optimize `SCAN` command when matching data type
- redis#13529 Optimize `LREM`, `LPOS`, `LINSERT`, and `LINDEX` commands
- redis#13516 Optimize `LRANGE` and other commands that perform several
writes to client buffers per call
- redis#13431 Avoid `used_memory` contention when updating from multiple
threads

### Other general improvements

- redis#13495 Reply `-LOADING` on replica while flushing the db

### CLI tools

- redis#13411 redis-cli: Fix wrong `dbnum` showed after the client
reconnected

### Notes

- No backward compatibility for replication or persistence.
- Additional distributions, upgrade paths, features, and improvements
will be introduced in upcoming pre-releases.
- With the GA release of 8.0 we will deprecate Redis Stack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants