Repository navigation
SPOP optional count argument. (issue #1793) - #1803
advance512 wants to merge 964 commits into
Conversation
We can save a little work by aborting when we enter the function if we're disconnected.
32 bit builds don't have a big enough long to capture the same range as a 64 bit build. If we use "long long" we get proper size limits everywhere. Also updates size of unsigned comparison to fit new size of `end`. Fixes redis#1981
Previously, GETRANGE of a key containing nothing ("")
would allocate a large (size_t)-1 return value causing
crashes on 32bit builds when it tried to allocate the
4 GB return string.
Increase size of range request in getrange
There are instances such as EC2 where the bind address is private (behind a NAT) and cannot be accessible from WAN. https://groups.google.com/d/msg/redis-db/PVVvjO4nMd0/P3oWC036v3cJ
The original implementation was modified in order to allow to selectively announce a different IP or port, and to rewrite the two options in the config file after a rewrite.
Because of the new ability to start with a truncated AOF, we need to correctly release all the memory on EOF error. Otherwise there is a small leak, that is not really a problem, but causes a false positive in the tests that detect memory leaks.
When aof-load-truncated option was introduced, with a default of "yes", the past behavior of the server to abort with trunncated AOF changed, so we need to explicitly configure the tests to abort with truncated AOF by setting the option to no.
*SCAN will cause redis server to hang for seconds after millions of keys was deleted by SCAN/DEL pairs
Limit the *SCAN command `dictScan` iterations
As discussed in issue redis#1945.
The code to check the number of voters was never updated to follow the new Sentinel specification, so the number of voters was computed using only the set of Sentinels that provided a vote. This means that there is a changing majority on partitions, even if usually the issue is not triggered because of the configured quorum check (what was broken was the other implicit check that requires anyway half of the known sentinels to agree in order to start a failover).
This is a general fix (check that dirty delta is positive) but actually should have as the only effect fixing the SAVE propagation to AOF and slaves.
Recently we introduced the ability to load truncated AOFs, but unfortuantely the support was broken since the server, after loading the truncated AOF, continues appending to the file that is corrupted at the end. The problem is fixed only in the next AOF rewrite. This commit fixes the issue by truncating the AOF to the last valid opcode, and aborting if it is not possible to truncate the file correctly.
It is not clear if files open in append only mode will automatically fix their offset after a truncate(2) operation. This commit makes sure that we reposition the AOF file descriptor offset at the end of the file after a truncated AOF is loaded and trimmed to the last valid command.
Now there are tests to write more data after loading a truncated AOF, testing that the loaded data is correct, appending more, and testing again.
This fixes a potential bug that was never observed in practice since what happens is that the asynchronous connect returns ok (to fail later, calling the handler) every time, so a ping is queued, and sent_ping happens to always be populated. Howver technically connect(2) with a non blocking socket may return an error synchronously, so before this fix the code was not correct.
Instead of manually checking for strchr(n,':') everywhere, we can use our new centralized IP formatting functions.
A few code style changes + consistent format: not nice for humans but better for parsers.
Specialized single-use function. Not the best match for sds.c btw. Also genClientPeerId() is no longer static: we need symbols.
remove_warning in db.c
It fixes a bad bug that crashes the server in certain conditions as shown in issue redis#2210.
The old list did not made much sense... and the flag is currently not used at all, so no side effects.
Otherwise there are security risks, especially when providing Redis as a service, the user may "sniff" for admin commands renamed to an unguessable string via rename-command in redis.conf.
7ad7d25 to
7c64e52
Compare
|
Okay. I rebased it, and updated the documentation here: Just one quick assumption that I need to verify. (Left over notes from June. Might even have verified it back then, but here goes anyways.) There is no need to release the strings created by dupStringObject and createStringObjectFromLongLong, since _dictClear does so. Correct? |
Maybe? It could just be a GItHub problem, but this PR has a lot of out of place commits here (maybe because GitHub is forcing it on the 3.0 branch)? The new commit can probably be cherry picked out okay though.
Correct! Sets are just key-only dicts, and the dict definition is at https://github.com/antirez/redis/blob/unstable/src/redis.c#L525-L533 — it doesn't have a key duplication function, so it retains the key you pass in, and it also has a built-in key free function to destroy items automatically on delete. Your feature looks good and even has tests and documentation! Some minor notes on required Redis coding style:
|
3355f64 to
d571e97
Compare
|
Thanks for the code review @mattsta, I appreciate it. I rebased the commit again, this time on antirez/redis/unstable, instead of advance512/redis/unstable (duh). So, less clutter. The original Pull Request was to antirez:3.0 and not antirez:unstable, which is why we see all the extra commits on top. Unfortunately, Github doesn't allow changing the target branch of a pull request. So, I created a new Pull Request instead: #2215 |
1f061dd to
57e907b
Compare
spopCommand() now runs spopWithCountCommand() in case the <count> param is found. Added intsetRandomMembers() to Intset: Copies N random members from the set into inputted 'values' array. Uses either the Knuth or Floyd sample algos depending on ratio count/size. Added setTypeRandomElements() to SET type: Returns a number of random elements from a non empty set. This is a version of setTypeRandomElement() that is modified in order to return multiple entries, using dictGetRandomKeys() and intsetRandomMembers(). Added tests for SPOP with <count>: unit/type/set, unit/scripting, integration/aof -- Cleaned up code a bit to match with required Redis coding style
57e907b to
2880288
Compare
|
Hello, thanks! Closing this in favor of #2215. |
More details of implementation in issue https://github.com/antirez/redis/issues/1793.
Commit message:
Added parameter to SPOP: