I am storing arbitrary exceptions thrown by user defined goals into a redis stream, the storing and retrieving works fine most of the time, except when there is a blob involved. I am storing using the as prolog
specification for the terms as you can deduce from the \x00T\x00
below.
From redis-cli
here is what the stream contains:
127.0.0.1:6379> xrevrange pl:redisjobs:cgrp:log + - count 3
1) 1) "1666391352021-0"
2) 1) "consumer"
2) "\x00T\x00'cgrp:h.local:434164:1'"
3) "goal"
4) "\x00T\x00:(plunit_redis_jobs,addone)"
5) "group"
6) "\x00T\x00cgrp"
7) "inid"
8) "\x00T\x00'1666391352019-0'"
9) "instream"
10) "\x00T\x00'pl:rj:in'"
11) "outid"
12) "\x00T\x00_9974"
13) "outstream"
14) "\x00T\x00'pl:rj:out'"
15) "status"
16) "\x00T\x00exception(error(existence_error(matching_rule,:(plunit_redis_jobs,addone(redis{val:1},_8736{consumer:'cgrp:h.local:434164:1',group:cgrp,message:'1666391352019-0',redis:redis_connection(default,<stream>(0x5646d8635100,0x5646d82cc900),0,[address(:(localhost,6379)),group(-(cgrp,'cgrp:h.local:434164:1')),reconnect(true),server(default),start(0),version(3)])},_8722,_8724))),context(:(plunit_redis_jobs,/(addone,4)),_8840)))"
2) 1) "1666391351988-0"
2) 1) "consumer"
2) "\x00T\x00'cgrp:h.local:434164:1'"
3) "goal"
4) "\x00T\x00:(plunit_redis_jobs,addone)"
5) "group"
6) "\x00T\x00cgrp"
7) "inid"
8) "\x00T\x00'1666391351987-0'"
9) "instream"
10) "\x00T\x00'pl:rj:in'"
11) "outid"
12) "\x00T\x00_6820"
13) "outstream"
14) "\x00T\x00'pl:rj:out'"
15) "status"
16) "\x00T\x00exception(hey_some_exception)"
3) 1) "1666391351956-0"
2) 1) "consumer"
2) "\x00T\x00'cgrp:h.local:434164:1'"
3) "goal"
4) "\x00T\x00:(plunit_redis_jobs,addone)"
5) "group"
6) "\x00T\x00cgrp"
7) "inid"
8) "\x00T\x00'1666391351955-0'"
9) "instream"
10) "\x00T\x00'pl:rj:in'"
11) "outid"
12) "\x00T\x00-(1666391351956,0)"
13) "outstream"
14) "\x00T\x00'pl:rj:out'"
15) "status"
16) "\x00T\x00exit"
Here is what happens when we try to retrieve some problematic entries:
7 ?- redis(default,xrevrange('pl:redisjobs:cgrp:log',+,-,count,1),R1).
ERROR: Syntax error: Operator expected
ERROR: exception(error(existence_error(matching_rule,:(plunit_redis_jobs,addone(redis{val:1},_8736{consumer:'cgrp:h.local:434164:1',group:cgrp,message:'1666391352019-0',redis:redis_connection(default,
ERROR: ** here **
ERROR: <stream>(0x5646d8635100,0x5646d82cc900),0,[address(:(localhost,6379)),group(-(cgrp,'cgrp:h.local:434164:1')),reconnect(true),server(default),start(0),version(3)])},_8722,_8724))),context(:(plunit_redis_jobs,/(addone,4)),_8840))) .
Obviously, the problem is that the stream blob is stored as <stream>(0x..., 0x...)
whereas I think it should be stored as '<stream>'(0x..., 0x...)
so that it is properly parsed.
I looked at the source in redis4pl.c
and it is prperly asking for CVT_WRITE_CANONICAL
. Should this not write <stream>
surrounded by single quotes?
NOTE: I do want to keep the terms in the redis stream as they were originally, even if it was a blob. Of course we are never going to instantiate the blob again, it is used for other purposes.