427 Commits

Author SHA1 Message Date
meir@redislabs.com
51e178454d Fix RM_ScanKey module api not to return int encoded strings
The scan key module API provides the scan callback with the current
field name and value (if it exists). Those arguments are RedisModuleString*
which means it supposes to point to robj which is encoded as a string.
Using createStringObjectFromLongLong function might return robj that
points to an integer and so break a module that tries for example to
use RedisModule_StringPtrLen on the given field/value.

The PR introduces a fix that uses the createObject function and sdsfromlonglong function.
Using those function promise that the field and value pass to the to the
scan callback will be Strings.

The PR also changes the Scan test module to use RedisModule_StringPtrLen
to catch the issue. without this, the issue is hidden because
RedisModule_ReplyWithString knows to handle integer encoding of the
given robj (RedisModuleString).

The PR also introduces a new test to verify the issue is solved.

(cherry picked from commit a89bf734a933e45b9dd3ae85ef4c3b62bd6891d8)
2020-07-20 21:08:26 +03:00
antirez
6791ff0525 Tracking: NOLOOP internals implementation. 2020-04-24 10:14:48 +02:00
Oran Agra
a38ff404bd modules don't signalModifiedKey in setKey() since that's done (optionally) in RM_CloseKey 2020-04-07 16:52:04 +02:00
Oran Agra
061616c1b1 fix possible warning on incomplete struct init 2020-04-07 16:52:04 +02:00
antirez
6fe66e0969 Simplify comment in moduleTryServeClientBlockedOnKey(). 2020-04-07 16:52:04 +02:00
Guy Benoish
193fc241ca Fix memory corruption in moduleHandleBlockedClients
By using a "circular BRPOPLPUSH"-like scenario it was
possible the get the same client on db->blocking_keys
twice (See comment in moduleTryServeClientBlockedOnKey)

The fix was actually already implememnted in
moduleTryServeClientBlockedOnKey but it had a bug:
the funxction should return 0 or 1 (not OK or ERR)

Other changes:
1. Added two commands to blockonkeys.c test module (To
   reproduce the case described above)
2. Simplify blockonkeys.c in order to make testing easier
3. cast raxSize() to avoid warning with format spec
2020-04-07 16:52:03 +02:00
antirez
616b1cb7ac Fix module commands propagation double MULTI bug.
37a10cef introduced automatic wrapping of MULTI/EXEC for the
alsoPropagate API. However this collides with the built-in mechanism
already present in module.c. To avoid complex changes near Redis 6 GA
this commit introduces the ability to exclude call() MUTLI/EXEC wrapping
for also propagate in order to continue to use the old code paths in
module.c.
2020-03-31 16:57:20 +02:00
antirez
08fdef4bf6 Fix RM_Call() stale comment due to cut&paste. 2020-03-31 16:57:20 +02:00
antirez
50f8f9504b Modules: updated function doc after #7003. 2020-03-25 15:55:24 +01:00
Guy Benoish
f2f3dc5e73 Allow RM_GetContextFlags to work with ctx==NULL 2020-03-25 15:55:24 +01:00
chendianqiang
5d4c4df3ef use correct list for moduleUnregisterUsedAPI 2020-03-25 15:54:34 +01:00
antirez
edc0ed1415 Modules: reformat RM_Scan() top comment a bit. 2020-03-05 12:51:14 +01:00
antirez
c5319612b4 Modules: more details in RM_Scan API top comment. 2020-03-05 12:51:14 +01:00
Oran Agra
fff6b26ae3 RM_Scan disable dict rehashing
The callback approach we took is very efficient, the module can do any
filtering of keys without building any list and cloning strings, it can
also read data from the key's value. but if the user tries to re-open
the key, or any other key, this can cause dict re-hashing (dictFind does
that), and that's very bad to do from inside dictScan.

this commit protects the dict from doing any rehashing during scan, but
also warns the user not to attempt any writes or command calls from
within the callback, for fear of unexpected side effects and crashes.
2020-03-05 12:51:14 +01:00
Guy Benoish
650484604c Add RM_CreateStringFromDouble 2020-03-05 12:51:14 +01:00
Oran Agra
afe0b16c02 module api docs for aux_save and aux_load 2020-03-05 12:51:14 +01:00
meir@redislabs.com
2966132c52 Changed log level for module fork api from 'notice' to 'verbos'. 2020-02-27 18:02:30 +01:00
Ariel
15ea13245a fix ThreadSafeContext lock/unlock function names 2020-02-27 18:02:30 +01:00
Guy Benoish
2ecab0b63a Modules: Do not auto-unblock clients if not blocked on keys 2020-02-27 18:02:30 +01:00
Oran Agra
3b4f147775 add no-slowlog option to RM_CreateCommand 2020-02-27 17:59:57 +01:00
Guy Benoish
dcbe8bfad1 Exclude "keymiss" notification from NOTIFY_ALL
Because "keymiss" is "special" compared to the rest of
the notifications (Trying not to break existing apps
using the 'A' format for notifications)

Also updated redis.conf and module.c docs
2020-02-12 14:17:54 +01:00
Oran Agra
36caf2e42b update RM_SignalModifiedKey doc comment 2020-02-12 14:17:40 +01:00
Oran Agra
8e7282eb3e Fix client flags to be int64 in module.c
currently there's no bug since the flags these functions handle are
always lower than 32bit, but still better fix the type to prevent future
bugs.
2020-02-12 14:17:40 +01:00
Oran Agra
a678390e52 moduleRDBLoadError, add key name, and use panic rather than exit
using panic rather than exit means you get s stack trace of the code
path that experianced the error, and possibly other info.
2020-02-12 14:17:40 +01:00
Oran Agra
ec0c61da05 fix uninitialized info_cb var in module.c 2020-02-04 10:23:48 +01:00
Guy Benoish
6fe55c2f29 ld2string should fail if string contains \0 in the middle
This bug affected RM_StringToLongDouble and HINCRBYFLOAT.
I added tests for both cases.

Main changes:
1. Fixed string2ld to fail if string contains \0 in the middle
2. Use string2ld in getLongDoubleFromObject - No point of
   having duplicated code here

The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble
because the long double string was saved with length+1 (An innocent
mistake, but it's actually a bug - The length passed to
RM_SaveLongDouble should not include the last \0).
2020-02-04 10:23:48 +01:00
antirez
bbce3ba974 Add more info in the unblockClientFromModule() function. 2020-02-04 10:23:48 +01:00
Guy Benoish
40295fb3fe Modules: Fix blocked-client-related memory leak
If a blocked module client times-out (or disconnects, unblocked
by CLIENT command, etc.) we need to call moduleUnblockClient
in order to free memory allocated by the module sub-system
and blocked-client private data

Other changes:
Made blockedonkeys.tcl tests a bit more aggressive in order
to smoke-out potential memory leaks
2020-02-04 10:23:48 +01:00
Yossi Gottlieb
b752e83db5 Add REDISMODULE_CTX_FLAGS_MULTI_DIRTY. 2020-01-10 13:16:03 +01:00
antirez
00e5fefe6d Fix ip and missing mode in RM_GetClusterNodeInfo(). 2019-12-29 15:46:31 +01:00
Salvatore Sanfilippo
d3a9dff6b9
Merge pull request #6615 from soloestoy/wrap-also-propagate-as-multi
Wrap also propagate as multi
2019-12-19 09:24:52 +01:00
antirez
c5bc1c14c0 Modules: rewrite top function doc of AvoidReplicaTraffic(). 2019-12-18 17:11:03 +01:00
Salvatore Sanfilippo
ef0b45ece8
Merge pull request #6497 from oranagra/avoid_replica_traffic
Add config and module API for AvoidReplicaTraffic
2019-12-18 17:06:05 +01:00
antirez
5b9d3ac6c6 Avoid changing setKey() API after #6679 fix. 2019-12-18 11:58:02 +01:00
zhaozhao.zz
24044f3356 add a new SET option KEEPTTL that doesn't remove expire time 2019-12-18 15:20:36 +08:00
Salvatore Sanfilippo
b7c78b7651
Merge pull request #5916 from madolson/dev-unstable-acl-module-pr
Add module APIs for custom authentication
2019-12-17 09:58:26 +01:00
Madelyn Olson
576a08908b Split error message so dependandent callers give a useful result 2019-12-16 23:34:37 -08:00
Madelyn Olson
44aa22c635 Added better exception handling around scripting and module 2019-12-16 23:33:53 -08:00
Madelyn Olson
f891b64a83 Tweaking the documentation 2019-12-17 07:28:55 +00:00
Madelyn Olson
034dcf185c Add module APIs for custom authentication 2019-12-17 06:59:59 +00:00
antirez
aa3f13761f Merge branch 'unstable' of github.com:/antirez/redis into unstable 2019-12-16 11:18:20 +01:00
antirez
096592506e Modules: allow to execute RM_Call() from the module init function. 2019-12-13 17:34:37 +01:00
Yossi Gottlieb
0283db5883 Improve RM_ModuleTypeReplaceValue() API.
With the previous API, a NULL return value was ambiguous and could
represent either an old value of NULL or an error condition. The new API
returns a status code and allows the old value to be returned
by-reference.

This commit also includes test coverage based on
tests/modules/datatype.c which did not exist at the time of the original
commit.
2019-12-12 18:50:11 +02:00
antirez
476333d192 Remove useless space from moduleLoad(). 2019-12-12 09:29:10 +01:00
Salvatore Sanfilippo
2968d8e3cb
Merge branch 'unstable' into ModuleSecurity 2019-12-12 09:27:14 +01:00
Oran Agra
b5f3247ca5 Add module API for AvoidReplicaTraffic
This is useful to tell redis and modules to try to avoid doing things that may
increment the replication offset, and should be used when draining a master
and waiting for replicas to be in perfect sync before a failover.
2019-12-12 08:38:09 +02:00
Salvatore Sanfilippo
c6fb9d0963
Merge pull request #6656 from oranagra/leak_rm_load_from_str
fix leak in RM_LoadDataTypeFromString, and save
2019-12-11 11:39:27 +01:00
Oran Agra
a37cca3644 fix leak in RM_LoadDataTypeFromString, and save 2019-12-11 12:35:00 +02:00
antirez
e4b6070c0f Modules: more clarification about disconnection callback. 2019-12-09 12:15:38 +01:00
antirez
2271cf03f5 Modules: clarify when the disconnection callback is called. 2019-12-05 10:38:18 +01:00