Skip to content

Commit

Permalink
HPCC-14116 Redis plugin: fail when attempting to initiate a persisten…
Browse files Browse the repository at this point in the history
…t lock

Signed-off-by: James Noss <james.noss@lexisnexis.com>
  • Loading branch information
jamienoss committed Aug 25, 2015
1 parent 737d43a commit e65513b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions plugins/redis/redis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void Connection::parseOptions(ICodeContext * ctx, const char * _options)
}
else
{
VStringBuffer err("RedisPlugin: unsupported option string %s", opt);
VStringBuffer err("Redis Plugin: unsupported option string %s", opt);
rtlFail(0, err.str());
}
}
Expand Down Expand Up @@ -339,11 +339,11 @@ void Connection::updateTimeout(unsigned __int64 _timeout)
{
if (context->err)
{
VStringBuffer msg("RedisPlugin: failed to set timeout - %s", context->errstr);
VStringBuffer msg("Redis Plugin: failed to set timeout - %s", context->errstr);
rtlFail(0, msg.str());
}
else
rtlFail(0, "RedisPlugin: failed to set timeout - no message available");
rtlFail(0, "Redis Plugin: failed to set timeout - no message available");
}
}
void Connection::assertOnError(const redisReply * reply, const char * _msg)
Expand Down Expand Up @@ -526,7 +526,7 @@ template<class type> void Connection::get(ICodeContext * ctx, const char * key,
size_t returnSize = reply->query()->len;
if (sizeof(type)!=returnSize)
{
VStringBuffer msg("RedisPlugin: ERROR - Requested type of different size (%uB) from that stored (%uB).", (unsigned)sizeof(type), (unsigned)returnSize);
VStringBuffer msg("Redis Plugin: ERROR - Requested type of different size (%uB) from that stored (%uB).", (unsigned)sizeof(type), (unsigned)returnSize);
rtlFail(0, msg.str());
}
memcpy(&returnValue, reply->query()->str, returnSize);
Expand Down Expand Up @@ -692,6 +692,8 @@ void Connection::encodeChannel(StringBuffer & channel, const char * key) const
}
bool Connection::lock(ICodeContext * ctx, const char * key, const char * channel, unsigned expire)
{
if (expire == 0)
rtlFail(0, "Redis Plugin: ERROR - invalid value for 'expire', persistent locks not allowed.");
StringBuffer cmd("SET %b %b NX PX ");
cmd.append(expire);

Expand Down Expand Up @@ -802,7 +804,7 @@ void Connection::handleLockOnGet(ICodeContext * ctx, const char * key, MemoryAtt
bool err = redisGetReply(subConnection->context, (void**)&nakedReply);
reply->setClear(nakedReply);
if (err != REDIS_OK)
rtlFail(0, "RedisPlugin: ERROR - GET timed out.");
rtlFail(0, "Redis Plugin: ERROR - GET timed out.");
assertOnCommandErrorWithKey(nakedReply, "GET", key);
if (nakedReply->type == REDIS_REPLY_ARRAY && strcmp("message", nakedReply->element[0]->str) == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion testing/regress/ecl/key/redislockingtest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<Row><value>Redis Plugin: ERROR - the key &apos;channelTest1&apos;, on database 0, is locked with a channel (&apos;redis_ecl_lock_blah_blah_blah&apos;) different to that subscribed to (redis_ecl_lock_channelTest1_0).</value></Row>
</Dataset>
<Dataset name='Result 26'>
<Row><value>RedisPlugin: ERROR - GET timed out.</value></Row>
<Row><value>Redis Plugin: ERROR - GET timed out.</value></Row>
</Dataset>
<Dataset name='Result 27'>
<Row><Result_27>databaseThenExpire</Result_27></Row>
Expand Down

0 comments on commit e65513b

Please sign in to comment.