208 Commits

Author SHA1 Message Date
antirez
41d0174213 Modules Timer API: fix wrong raxRemove() key argument. 2018-03-31 09:58:43 +02:00
antirez
ba7d6001ba Modules Timer API: fix infinite loop and export API. 2018-03-31 00:44:46 +02:00
antirez
751ae32f75 Modules Timer API: timer handling implemented. 2018-03-30 22:50:21 +02:00
antirez
397089524e Modules Timer API: initial implementation. 2018-03-30 20:40:35 +02:00
antirez
b3291b0706 Modules Cluster API: node API exported, example improved. 2018-03-30 17:00:45 +02:00
antirez
611a5097e5 Modules Cluster API: nodes list and info API. 2018-03-30 16:16:47 +02:00
antirez
2ce3d47055 Modules Cluster API: node information struct and flags. 2018-03-30 13:16:55 +02:00
antirez
055ab3623b Modules Cluster API: make node IDs pointers constant. 2018-03-30 13:16:07 +02:00
antirez
9d5a054975 Modules Cluster API: fix new API calls exporting. 2018-03-30 12:49:16 +02:00
antirez
0edbb9221b Modules Cluster API: sending / receiving API first implementation. 2018-03-30 11:06:08 +02:00
antirez
72f11ded18 Modules Cluster API: message bus implementation. 2018-03-29 15:13:31 +02:00
charsyam
bc0b9d99b8 fix dlopen leak 2018-03-01 21:22:42 +09:00
antirez
ab4dddc4eb Remove non semantical spaces from module.c. 2018-02-15 21:41:03 +01:00
Dvir Volk
4538c12708 Add doc comment about notification flags 2018-02-14 21:54:00 +02:00
Dvir Volk
f48814e99d Use one static client for all keyspace notification callbacks 2018-02-14 21:40:10 +02:00
Dvir Volk
383edf2101 Remove the NOTIFY_MODULE flag and simplify the module notification flow if there aren't subscribers 2018-02-14 21:40:10 +02:00
Dvir Volk
4f3e266117 Document flags for notifications 2018-02-14 21:38:58 +02:00
Dvir Volk
20f414af40 finished implementation of notifications. Tests unfinished 2018-02-14 21:38:58 +02:00
Salvatore Sanfilippo
2e51347925 Merge pull request #4581 from dvirsky/module_unlink
Added RM_UnlinkKey - a low level analog to UNLINK command
2018-01-12 17:41:09 +01:00
Dvir Volk
7e4794f67c Added RM_UnlinkKey - a low level analog to UNLINK command 2018-01-07 16:41:43 +02:00
Oran Agra
5821e8cf82 fix processing of large bulks (above 2GB)
- protocol parsing (processMultibulkBuffer) was limitted to 32big positions in the buffer
  readQueryFromClient potential overflow
- rioWriteBulkCount used int, although rioWriteBulkString gave it size_t
- several places in sds.c that used int for string length or index.
- bugfix in RM_SaveAuxField (return was 1 or -1 and not length)
- RM_SaveStringBuffer was limitted to 32bit length
2017-12-29 12:24:19 +02:00
antirez
78c28a5a54 Modules: fix memory leak in RM_IsModuleNameBusy(). 2017-11-24 13:29:54 +01:00
Salvatore Sanfilippo
8fa2ab29d8 Merge pull request #4344 from soloestoy/fix-module-name-conflict
Fix module name conflict
2017-11-24 09:37:06 +01:00
antirez
c2097bc95c Modules: fix for scripting replication of modules commands.
See issue #4466 / #4467.
2017-11-23 15:14:17 +01:00
Yossi Gottlieb
4902e26fef Nested MULTI/EXEC may replicate in different cases.
For example:
1. A module command called within a MULTI section.
2. A Lua script with replicate_commands() called within a MULTI section.
3. A module command called from a Lua script in the above context.
2017-11-22 22:02:51 +02:00
antirez
37b501ca84 Limit statement in RM_BlockClient() to 80 cols. 2017-09-28 23:15:34 +02:00
zhaozhao.zz
cc7ef78988 Modules: handle the busy module name 2017-09-28 17:38:40 +08:00
zhaozhao.zz
a06adaec8e Modules: handle the conflict of registering commands 2017-09-28 16:21:21 +08:00
Dvir Volk
890ca935a7 Added safety net preventing redis from crashing if a module decide to block in MULTI 2017-09-27 15:17:53 +03:00
Dvir Volk
2f336b5eb7 Renamed GetCtxFlags to GetContextFlags 2017-09-27 11:58:16 +03:00
Dvir Volk
43e4efc52e Added support for module context flags with RM_GetCtxFlags 2017-09-27 11:58:07 +03:00
antirez
9d76a9a1a5 Modules: don't crash when Lua calls a module blocking command.
Lua scripting does not support calling blocking commands, however all
the native Redis commands are flagged as "s" (no scripting flag), so
this is not possible at all. With modules there is no such mechanism in
order to flag a command as non callable by the Lua scripting engine,
moreover we cannot trust the modules users from complying all the times:
it is likely that modules will be released to have blocking commands
without such commands being flagged correctly, even if we provide a way to
signal this fact.

This commit attempts to address the problem in a short term way, by
detecting that a module is trying to block in the context of the Lua
scripting engine client, and preventing to do this. The module will
actually believe to block as usually, but what happens is that the Lua
script receives an error immediately, and the background call is ignored
by the Redis engine (if not for the cleanup callbacks, once it
unblocks).

Long term, the more likely solution, is to introduce a new call called
RedisModule_GetClientFlags(), so that a command can detect if the caller
is a Lua script, and return an error, or avoid blocking at all.

Being the blocking API experimental right now, more work is needed in
this regard in order to reach a level well blocking module commands and
all the other Redis subsystems interact peacefully.

Now the effect is like the following:

    127.0.0.1:6379> eval "redis.call('hello.block',1,5000)" 0
    (error) ERR Error running script (call to
    f_b5ba35ff97bc1ef23debc4d6e9fd802da187ed53): @user_script:1: ERR
    Blocking module command called from Lua script

This commit fixes issue #4127 in the short term.
2017-07-23 12:55:37 +02:00
antirez
f048114d52 Fix typo in unblockClientFromModule() top comment. 2017-07-23 12:41:26 +02:00
antirez
f610db00bd Fix two bugs in moduleTypeLookupModuleByID().
The function cache was not working at all, and the function returned
wrong values if there where two or more modules exporting native data
types.

See issue #4131 for more details.
2017-07-20 14:59:42 +02:00
antirez
f971e4c876 Modules: fix thread safe context DB selection.
Before this fix the DB currenty selected by the client blocked was not
respected and operations were always performed on DB 0.
2017-07-14 13:02:15 +02:00
antirez
07d40ae1f0 Markdown generation of Redis Modules API reference improved. 2017-07-14 11:29:31 +02:00
antirez
0a2b3c6dac Clients blocked in modules: free argv/argc later.
See issue #3844 for more information.
2017-07-11 12:33:01 +02:00
Guy Benoish
eda1c9e6f6 Modules: Fix io->bytes calculation in RDB save 2017-07-10 14:41:57 +03:00
Salvatore Sanfilippo
a929e560d0 Merge pull request #3853 from itamarhaber/issue-3851
Sets up fake client to select current db in RM_Call()
2017-07-06 15:02:11 +02:00
antirez
45c2679529 Modules: DEBUG DIGEST interface. 2017-07-06 11:04:46 +02:00
antirez
a2a406bfef Modules: no MULTI/EXEC for commands replicated from async contexts.
They are technically like commands executed from external clients one
after the other, and do not constitute a single atomic entity.
2017-07-05 10:10:20 +02:00
Dvir Volk
be7ce4a1e5 fixed #4100 2017-07-04 00:02:19 +03:00
antirez
2a26f2a9f6 RDB modules values serialization format version 2.
The original RDB serialization format was not parsable without the
module loaded, becuase the structure was managed only by the module
itself. Moreover RDB is a streaming protocol in the sense that it is
both produce di an append-only fashion, and is also sometimes directly
sent to the socket (in the case of diskless replication).

The fact that modules values cannot be parsed without the relevant
module loaded is a problem in many ways: RDB checking tools must have
loaded modules even for doing things not involving the value at all,
like splitting an RDB into N RDBs by key or alike, or just checking the
RDB for sanity.

In theory module values could be just a blob of data with a prefixed
length in order for us to be able to skip it. However prefixing the values
with a length would mean one of the following:

1. To be able to write some data at a previous offset. This breaks
stremaing.
2. To bufferize values before outputting them. This breaks performances.
3. To have some chunked RDB output format. This breaks simplicity.

Moreover, the above solution, still makes module values a totally opaque
matter, with the fowllowing problems:

1. The RDB check tool can just skip the value without being able to at
least check the general structure. For datasets composed mostly of
modules values this means to just check the outer level of the RDB not
actually doing any checko on most of the data itself.
2. It is not possible to do any recovering or processing of data for which a
module no longer exists in the future, or is unknown.

So this commit implements a different solution. The modules RDB
serialization API is composed if well defined calls to store integers,
floats, doubles or strings. After this commit, the parts generated by
the module API have a one-byte prefix for each of the above emitted
parts, and there is a final EOF byte as well. So even if we don't know
exactly how to interpret a module value, we can always parse it at an
high level, check the overall structure, understand the types used to
store the information, and easily skip the whole value.

The change is backward compatible: older RDB files can be still loaded
since the new encoding has a new RDB type: MODULE_2 (of value 7).
The commit also implements the ability to check RDB files for sanity
taking advantage of the new feature.
2017-06-27 13:19:16 +02:00
antirez
a47d48af1c Modules TSC: put the client in the pending write list. 2017-05-03 14:54:48 +02:00
antirez
0d46ea7473 Module: fix RedisModule_Call() "l" specifier to create a raw string. 2017-05-03 14:07:10 +02:00
antirez
85237f2efa Modules TSC: Release the GIL for all the time we are blocked.
Instead of giving the module background operations just a small time to
run in the beforeSleep() function, we can have the lock released for all
the time we are blocked in the multiplexing syscall.
2017-05-03 11:26:21 +02:00
antirez
d8b3f3f854 Modules TSC: Export symbols of the new API. 2017-05-02 15:19:28 +02:00
antirez
ae9780424a Modules TSC: Handling of RM_Reply* functions. 2017-05-02 15:05:39 +02:00
antirez
3c950d48f1 Modules TSC: Basic TS context creeation and handling. 2017-05-02 12:53:10 +02:00
antirez
5668d9be33 Modules TSC: GIL and cooperative multi tasking setup. 2017-04-28 18:41:10 +02:00