Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failed: ASSERT: failed to test xclaim: 0. #76

Closed
shauningoldsby opened this issue Jul 28, 2020 · 10 comments
Closed

Test failed: ASSERT: failed to test xclaim: 0. #76

shauningoldsby opened this issue Jul 28, 2020 · 10 comments

Comments

@shauningoldsby
Copy link

shauningoldsby commented Jul 28, 2020

Run in Ubuntu 20.04 on WSL with Redis 5.0.7 and then 6.0.6. Same results.

Testing Redis...
Pass sanity tests
Pass connection commands tests
Pass keys commands tests
Pass string commands tests
Pass list commands tests
Pass hash commands tests
Pass set commands tests
Pass zset commands tests
Pass hyperloglog commands tests
Pass geo commands tests
Pass script commands tests
Pass pubsub tests
Pass pipeline and transaction tests
Pass threads tests
Test failed: ASSERT: failed to test xclaim: 0. /home/shaun/src/redis-plus-plus/test/src/sw/redis++/stream_cmds_test.hpp:205

@sewenew
Copy link
Owner

sewenew commented Aug 1, 2020

Hi @shauningoldsby

Sorry for the late reply.

I cannot reproduce your problem with both 5.0.7 and 6.0.6.

Is there any other clients writing to your Redis instance while you are doing the test?

Also can you change the Redis' port to some magic number, i.e. 9135, to ensure that no one else is using your Redis instance.

Regards

@shauningoldsby
Copy link
Author

shauningoldsby commented Aug 1, 2020

Hi @sewenew, thanks for the reply. No, there aren't any other clients connected to the instance, I'm on a development machine.
Regardless, I did restart the server and used a different port and received the same results.

shaun@shaunsthinkpad:~/src/redis-plus-plus$ ./compile/test/test_redis++ -h localhost -p 9135
Testing Redis...
Pass sanity tests
Pass connection commands tests
Pass keys commands tests
Pass string commands tests
Pass list commands tests
Pass hash commands tests
Pass set commands tests
Pass zset commands tests
Pass hyperloglog commands tests
Pass geo commands tests
Pass script commands tests
Pass pubsub tests
Pass pipeline and transaction tests
Pass threads tests
Test failed: ASSERT: failed to test xclaim: 0. /home/shaun/src/redis-plus-plus/test/src/sw/redis++/stream_cmds_test.hpp:205

@sewenew
Copy link
Owner

sewenew commented Aug 3, 2020

Hi @shauningoldsby

I still cannot reproduce your problem. Also I double checked the test code, it should work.

Can you try the following test with your Redis and redis-cli:

127.0.0.1:6379> xgroup create s group $ MKSTREAM
OK
127.0.0.1:6379> xadd s * f1 v1 f2 v2
"1596465859765-0"             // <---------- this is an auto generated id by redis
127.0.0.1:6379> xreadgroup group group consumer1 streams s >
1) 1) "s"
   2) 1) 1) "1596465859765-0"
         2) 1) "f1"
            2) "v1"
            3) "f2"
            4) "v2"
127.0.0.1:6379> xreadgroup group group consumer1 streams s >
(nil)
127.0.0.1:6379> xreadgroup group group xconsumer1 streams s >
(nil)
127.0.0.1:6379> xreadgroup group group consumer1 block 1000 streams s >
(nil)
(1.05s)
127.0.0.1:6379> xpending s group - + 1 consumer1
1) 1) "1596465859765-0"
   2) "consumer1"
   3) (integer) 171482
   4) (integer) 1

// <--------- here wait for 1 second, then run the following xclaim command

127.0.0.1:6379> xclaim s group consumer2 10 1596465859765-0              // <------ specify the id returned by the xpending command
1) 1) "1596465859765-0"
   2) 1) "f1"
      2) "v1"
      3) "f2"
      4) "v2"

// <--------- here wait for 1 second, then run the following xclaim command

127.0.0.1:6379> xclaim s group consumer1 10 1596465859765-0           // <--------- If your Redis returns a result, it should pass the test.
1) 1) "1596465859765-0"
   2) 1) "f1"
      2) "v1"
      3) "f2"
      4) "v2"

Your error message shows that the last xclaim command doesn't return any result. In fact, it should return one result, i.e. the pending message.

Can you show me the result of the last xclaim command in the above test?

Regards

@shauningoldsby
Copy link
Author

@sewenew will run soon as I can and get back to you. Thank you.

@shauningoldsby
Copy link
Author

@sewenew Looks like my Redis passed. Output below:

127.0.0.1:6379> xgroup create s group $ MKSTREAM
OK
127.0.0.1:6379> xadd s * f1 v1 f2 v2
"1596629739725-0"
127.0.0.1:6379> xreadgroup group group consumer1 streams s >
1) 1) "s"
   2) 1) 1) "1596629739725-0"
         2) 1) "f1"
            2) "v1"
            3) "f2"
            4) "v2"
127.0.0.1:6379> xreadgroup group group consumer1 streams s >
(nil)
127.0.0.1:6379> xreadgroup group group xconsumer1 streams s >
(nil)
127.0.0.1:6379> xreadgroup group group consumer1 block 1000 streams s >
(nil)
(1.09s)
127.0.0.1:6379> xpending s group - + 1 consumer1
1) 1) "1596629739725-0"
   2) "consumer1"
   3) (integer) 31865
   4) (integer) 1
127.0.0.1:6379> xclaim s group consumer2 10 1596629739725-0
1) 1) "1596629739725-0"
   2) 1) "f1"
      2) "v1"
      3) "f2"
      4) "v2"
127.0.0.1:6379> xclaim s group consumer1 10 1596629739725-0
1) 1) "1596629739725-0"
   2) 1) "f1"
      2) "v1"
      3) "f2"
      4) "v2"
127.0.0.1:6379>

@sewenew
Copy link
Owner

sewenew commented Aug 5, 2020

Hi @shauningoldsby

That's really strange. The test seems fail on the last xclaim command since it cannot get any result. However, you can use redis-cli to get result.

Can you modify line 201 of src/sw/redis++/stream_cmds_test.hpp file as follows, to see if the test can be passed:

std::this_thread::sleep_for(std::chrono::seconds(10));     // sleep 10 seconds instead of 1 second to ensure the message is idle long enough.

Regards

@shauningoldsby
Copy link
Author

@sewenew Made the change, but still failed. Same Error:

Test failed: ASSERT: failed to test xclaim: 0. /home/shaun/src/redis-plus-plus/test/src/sw/redis++/stream_cmds_test.hpp:205

Could this problem be related to running Redis on Ubuntu in WSL 1?

@sewenew
Copy link
Owner

sewenew commented Aug 6, 2020

Hi @shauningoldsby

That's an important clue :)

I did some googling, and it seems that WLS has a bug, and std::this_thread::sleep_for doesn't work as expected. That's why the test fails.

Please check the following links:

Since std::this_thread::sleep_for doesn't work, and returns immediately, the message doesn't been idle for 10ms. So XCLAIM returns empty result, and the test fails.

    _redis.xclaim(key,
            group,
            consumer2,
            std::chrono::milliseconds(10),
            ids,
            std::back_inserter(items));
    REDIS_ASSERT(items.size() == 1 && items[0].first == id, "failed to test xclaim");

    // ---NOTE---: If sleep_for works, the message should been idle for 1s, and the next xclaim command will return the message.
    std::this_thread::sleep_for(std::chrono::seconds(1));

    items.clear();
    _redis.xclaim(key, group, consumer1, std::chrono::milliseconds(10), id, std::back_inserter(items));

    // ---NOTE---: however, since sleep_for doesn't work, and return immediately, message hasn't been idled for 10ms,
    // so items.size() == 0, and the test fails.
    REDIS_ASSERT(items.size() == 1 && items[0].first == id, "failed to test xclaim: " + std::to_string(items.size()));

Regards

@shauningoldsby
Copy link
Author

@sewenew thanks for all your hard work. I should have suspected WSL as being the culprit earlier on. It was not included with enough emphasis in my initial post.

@sewenew
Copy link
Owner

sewenew commented Aug 7, 2020

@shauningoldsby Take it easy :)

I'll close this issue. If you still have any problem with redis-plus-plus feel free to let me know. If you like it, also feel free to star it :)

Regards

@sewenew sewenew closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants