242 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
3829c2c768 Merge pull request #5738 from bmerry/fix-swapdb-int-overflow
Make dbSwapDatabases take args as long
2019-07-12 12:36:33 +02:00
Oran Agra
29754ebe22 diskless replication on slave side (don't store rdb to file), plus some other related fixes
The implementation of the diskless replication was currently diskless only on the master side.
The slave side was still storing the received rdb file to the disk before loading it back in and parsing it.

This commit adds two modes to load rdb directly from socket:
1) when-empty
2) using "swapdb"
the third mode of using diskless slave by flushdb is risky and currently not included.

other changes:
--------------
distinguish between aof configuration and state so that we can re-enable aof only when sync eventually
succeeds (and not when exiting from readSyncBulkPayload after a failed attempt)
also a CONFIG GET and INFO during rdb loading would have lied

When loading rdb from the network, don't kill the server on short read (that can be a network error)

Fix rdb check when performed on preamble AOF

tests:
run replication tests for diskless slave too
make replication test a bit more aggressive
Add test for diskless load swapdb
2019-07-08 15:37:48 +03:00
Salvatore Sanfilippo
9c1932beeb Merge pull request #6116 from AngusP/scan-types
SCAN: New Feature `SCAN cursor [TYPE type]` modifier suggested in issue #6107
2019-07-08 12:53:34 +02:00
Angus Pearson
00c9b4f15d Change typeNameCanonicalize -> getObjectTypeName, and other style changes 2019-07-08 11:04:37 +01:00
antirez
4b5027845e Client side caching: implement trackingInvalidateKey(). 2019-07-03 19:16:20 +02:00
Angus Pearson
5ca48db2e2 Add char* typeNameCanonicalize(robj*) to remove duplicate code between SCAN and TYPE commands,
and to keep OBJ_* enum to string canonicalization in one place.
2019-06-10 17:41:44 +01:00
Angus Pearson
4bbaf621a1 Implement SCAN cursor [TYPE type] modifier suggested in issue #6107.
Add tests to check basic functionality of this optional keyword, and also tested with
a module (redisgraph). Checked quickly with valgrind, no issues.

Copies name the type name canonicalisation code from `typeCommand`, perhaps this would
be better factored out to prevent the two diverging and both needing to be edited to
add new `OBJ_*` types, but this is a little fiddly with C strings.

The [redis-doc](https://github.com/antirez/redis-doc/blob/master/commands.json) repo
will need to be updated with this new arg if accepted.

A quirk to be aware of here is that the GEO commands are backed by zsets not their own
type, so they're not distinguishable from other zsets.

Additionally, for sparse types this has the same behaviour as `MATCH` in that it may
return many empty results before giving something, even for large `COUNT`s.
2019-05-22 16:39:04 +01:00
Dvir Volk
1a24f23a50 Renamed event name from "miss" to "keymiss" 2019-03-21 20:33:11 +02:00
Dvir Volk
50befc42ad added special flag for keyspace miss notifications 2019-03-21 11:47:14 +02:00
Dvir Volk
278c7a6b6d Added keyspace miss notifications support 2019-03-19 13:11:37 +02:00
antirez
94a9e27bb8 Use dictGetFairRandomKey() for RANDOMKEY as well. 2019-02-19 17:29:51 +01:00
antirez
da54f1fd3f Refactoring: always kill AOF/RDB child via helper functions. 2019-01-21 11:28:44 +01:00
Salvatore Sanfilippo
081ef93364 Merge branch 'unstable' into fixChildInfoPipeFdLeak 2019-01-21 11:20:56 +01:00
Salvatore Sanfilippo
3faf82d14b Merge pull request #5797 from trevor211/fixUpdateDictResizePolicy
Fix update dict resize policy
2019-01-21 11:14:48 +01:00
WuYunlong
1e1a5ceb65 Fix child info pipe fd leak when child process gets killed. 2019-01-21 17:48:45 +08:00
WuYunlong
f02ae4788b Update dict resize policy when rdb child process gets killed. 2019-01-21 17:33:18 +08:00
antirez
c8304b099d RESP3: most null replies converted. 2019-01-09 17:00:29 +01:00
antirez
293659ae04 RESP3: Use new deferred len API in dict.c. 2019-01-09 17:00:29 +01:00
Bruce Merry
26b109ae23 Make dbSwapDatabases take args as long
This prevents an integer overflow bug. Closes #5737.
2018-12-31 11:51:03 +02:00
lsytj0413
2538516df1 fix a typo: craeted -> created 2018-12-06 11:08:59 +08:00
Salvatore Sanfilippo
6f79cc62e6 Merge pull request #5469 from soloestoy/stat-key-miss-if-expired
if we read a expired key, misses++
2018-10-24 12:31:28 +02:00
antirez
5f8d96699d Simplify part of the #5470 patch. 2018-10-24 12:26:27 +02:00
Salvatore Sanfilippo
0f4e72fb8d Merge pull request #5470 from soloestoy/keys-no-trigger-expire
do not delete expired keys in KEYS command
2018-10-24 12:23:59 +02:00
hujie
2cf0ab76fd fix typo 2018-10-20 12:18:56 +08:00
zhaozhao.zz
2906ba5b5c if we read a expired key, misses++ 2018-10-19 18:16:29 +08:00
zhaozhao.zz
357909d7dd do not delete expired keys in KEYS command 2018-10-19 18:00:57 +08:00
zhaozhao.zz
b880a352d6 refactor dbOverwrite to make lazyfree work 2018-07-31 12:07:57 +08:00
antirez
8acaa863c8 Remove useless conditional from emptyDb().
Related to #4852.
2018-07-25 16:34:57 +02:00
antirez
b2aaf15b7b Make emptyDb() change introduced in #4852 simpler to read. 2018-07-25 16:32:52 +02:00
zhaozhao.zz
391a1cda58 optimize flushdb, avoid useless loops 2018-07-25 18:13:34 +08:00
Jack Drogon
bae1d36e5d Fix typo 2018-07-03 18:19:46 +02:00
zhaozhao.zz
07f01cc4cd fix some compile warnings 2018-06-28 17:22:59 +08:00
shenlongxing
dbd1e254bd fix typo 2018-06-21 22:08:09 +08:00
antirez
7f72840c36 Streams: fix xreadGetKeys() for correctness.
The old version could not handle the fact that "STREAMS" is a valid key
name for streams. Now we really try to parse the command like the
command implementation would do.

Related to #5028 and 4857.
2018-06-18 14:06:06 +02:00
Salvatore Sanfilippo
780c3bef6a Merge pull request #4857 from youjiali1995/fix-command-getkeys
Fix core dump when using some commands with wrong arguments.
2018-06-18 13:54:38 +02:00
antirez
102106fc61 Streams: fix xreadGetKeys() buffer overflow.
The loop allocated a buffer for the right number of keys positions, then
overflowed it going past the limit.

Related to #4857 and cause of the memory violation seen in #5028.
2018-06-18 13:51:19 +02:00
antirez
ea5d760ed5 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-06-14 18:11:04 +02:00
antirez
063dd636ab Fix infinite loop in dbRandomKey().
Thanks to @kevinmcgehee for signaling the issue and reasoning about the
consequences and potential fixes.

Issue #5015.
2018-06-14 18:08:21 +02:00
zhaozhao.zz
6786bcba94 fix exists command on slave 2018-06-14 01:30:07 +08:00
antirez
778b846ca9 In scanDatabaseForReadyLists() now we need to handle ZSETs as well.
Since the introduction of ZPOP makes this needed. Thanks to @oranagra
for reporting.
2018-06-12 17:28:40 +02:00
赵磊
3ab3bb1421 Fix core dump when using 'command getkeys' with wrong arguments. 2018-06-04 15:14:50 +08:00
Itamar Haber
52c9565dda Implements [B]Z[REV]POP and the respective unit tests
An implementation of the
[Ze POP Redis Module](https://github.com/itamarhaber/zpop) as core
Redis commands.

Fixes #1861.
2018-04-30 02:10:42 +03:00
Salvatore Sanfilippo
a8b560804f Merge pull request #4679 from youjiali1995/fix-lru
Some commands will udpate lfu-counter many times in one call.
2018-03-22 16:26:01 +01:00
antirez
7ba754281f expireIfNeeded() needed a top comment documenting the behavior. 2018-02-27 16:44:43 +01:00
antirez
f7f696f4ae expireIfNeeded() comment: claim -> pretend. 2018-02-27 16:37:37 +01:00
赵磊
8b09c535c4 Remove updateLFU() in dbOverwrite(). 2018-02-11 21:02:07 +08:00
antirez
b686b085ed Fix getKeysUsingCommandTable() in the case of nagative arity.
This fixes a crash with Redis Cluster when OBJECT is mis-used, because
getKeysUsingCommandTable() will call serverPanic() detecting we are
accessing an invalid argument in the case "OBJECT foo" is called.

This bug was introduced when OBJECT HELP was introduced, because the key
argument is set fixed at index 2 in the command table, however now
OBJECT may be called with an insufficient number of arguments to extract
the key.

The "Right Thing" would be to have a specific function to extract keys
from the OBJECT command, however this is kinda of an overkill, so I
preferred to make getKeysUsingCommandTable() more robust and just return
no keys when it's not possible to honor the command table, because new
commands are often added and also there are a number with an HELP
subcommand violating the normal form, and crashing for this trivial
reason or having many command-specific key extraction functions is not
great.
2018-01-12 11:26:29 +01:00
antirez
54b3dc4992 Streams: fix TYPE for stream type. 2017-12-01 10:24:24 +01:00
antirez
799eaab940 Streams: fix XREAD ready-key signaling.
With lists we need to signal only on key creation, but streams can
provide data to clients listening at every new item added.
To make this slightly more efficient we now track different classes of
blocked clients to avoid signaling keys when there is nobody listening.
A typical case is when the stream is used as a time series DB and
accessed only by range with XRANGE.
2017-12-01 10:24:24 +01:00
antirez
dd857e945e Streams: XREAD get-key method fixed. 2017-12-01 10:24:24 +01:00