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

[BUG] asynq client failed when use command stats #309

Closed
duyhungtnn opened this issue Aug 7, 2021 · 5 comments · Fixed by #310
Closed

[BUG] asynq client failed when use command stats #309

duyhungtnn opened this issue Aug 7, 2021 · 5 comments · Fixed by #310
Assignees
Labels
bug Something isn't working

Comments

@duyhungtnn
Copy link

Describe the bug

  • After connect asynq with our Redis server, run a command asynq stats. It take so long to complete and end up with
ryan@ ~ asynq stats

Using config file: /Users/ryan/.asynq.yml

UNKNOWN: UNKNOWN: redis command error: MEMORY USAGE failed: redis: nil

To Reproduce
Steps to reproduce the behavior (Code snippets if applicable):
0. Setup redis with docker-compose

version: '3.1'

services:
  redis:
    container_name: abc_redis
    image: redis:6.2.5-alpine
    command: redis-server --requirepass ${REDIS_PASSWORD}
    environment:
      - ALLOW_EMPTY_PASSWORD=no
      - REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
    ports:
      - '6379:6379'
    volumes:
      - './data:/data'

networks:
  default:
    external:
      name: abc
  1. Setup background processing ...
  2. Enqueue tasks ...
  3. See Error ...

Expected behavior

  • Need to see the stats of the system

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2021-08-07 at 11 07 54

Environment (please complete the following information):

  • OS: [Ubuntu 18.4]
  • Version of asynq package [v0.18.2]

Additional context

  • The worker and scheduler work as normal
    Screen Shot 2021-08-07 at 11 20 15

  • The data on Redis is okay too
    Screen Shot 2021-08-07 at 11 19 05

@duyhungtnn duyhungtnn added the bug Something isn't working label Aug 7, 2021
@duyhungtnn duyhungtnn changed the title [BUG] asynq client fail to when use command stats [BUG] asynq client failed when use command stats Aug 7, 2021
@crossworth
Copy link
Contributor

Hello, I have encoutered this problem as well, but using asynqmon, I could not yet determine why (for this reason I havent create a issue or pr), but I know that I can cause it by enqueuing a lot of tasks and processing they very fast (no code, no printing, just a empty handler).

Probably the MEMORY USAGE command is returning nil and since we dont handle it we get this error message.

I will investigate it.

@hibiken
Copy link
Owner

hibiken commented Aug 7, 2021

@duyhungtnn thank you for reporting this!

Could you double check the CLI version by running asynq version?

@hibiken
Copy link
Owner

hibiken commented Aug 7, 2021

The error message in the screenshot is coming from here:

return 0, errors.E(op, errors.Unknown, &errors.RedisCommandError{Command: "memory usage", Err: err})

My initial guess is that the for loop for the scan command is taking too long (

) since we recently changed each task to have its only redis key.
Since redis only executes one command at a time, since other clients are sending commands to redis while this for loop is executing scan commands to collect all keys, keys may have been deleted (i.e. task processed successfully), you'll see the key not found error when memeorUsage command is invoked.

If this above analysis is correct, then we should make this operation into a Lua script and run the script with EXECUTE so that all of this operation becomes atomic (i.e. other clients commands won't be executing between multiple calls to scan and memoryusage). But now that we can have a lot more redis-keys than before (each task has its own key), maybe getting memory usage within a short timeframe is not feasible anymore.

@duyhungtnn
Copy link
Author

duyhungtnn commented Aug 7, 2021

@duyhungtnn thank you for reporting this!

Could you double check the CLI version by running asynq version?

@hibiken yeah my asynq is asynq version 0.18.2

@crossworth I am facing that issue with asynqmon too. The web dashboard display nothing when viewing the queue info.
Yes, I was using a scheduler to trigger a single task every 2h. On that single task will enqueue 5000 tasks to feed the workers. It may be the cause.

@hibiken
Copy link
Owner

hibiken commented Aug 9, 2021

@duyhungtnn The fix is in 👍
Let me know if you continue to see issues with new versions (asynq: v0.18.3, asynqmon v0.2.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants