certtools / intelmq

IntelMQ is a solution for IT security teams for collecting and processing security feeds using a message queuing protocol.

Home Page:https://docs.intelmq.org/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis Pipeline error

gethvi opened this issue · comments

On some occasions (after restarting Redis) connection to Redis is refused and this exception is raised:

File "/opt/venv/lib/python3.9/site-packages/intelmq/lib/pipeline.py", line 311, in count_queued_messages
queue_dict[queue] = self.pipe.llen(queue)
File "/opt/venv/lib/python3.9/site-packages/redis/commands/core.py", line 2668, in llen
return self.execute_command("LLEN", name)
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1258, in execute_command
return conn.retry.call_with_retry(
File "/opt/venv/lib/python3.9/site-packages/redis/retry.py", line 49, in call_with_retry
fail(error)
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1262, in <lambda>
lambda error: self._disconnect_raise(conn, error),
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1248, in _disconnect_raise
raise error
File "/opt/venv/lib/python3.9/site-packages/redis/retry.py", line 46, in call_with_retry
return do()
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1259, in <lambda>
lambda: self._send_command_parse_response(
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1235, in _send_command_parse_response
return self.parse_response(conn, command_name, **options)
File "/opt/venv/lib/python3.9/site-packages/redis/client.py", line 1275, in parse_response
response = connection.read_response()
File "/opt/venv/lib/python3.9/site-packages/redis/connection.py", line 865, in read_response
response = self._parser.read_response(disable_decoding=disable_decoding)
File "/opt/venv/lib/python3.9/site-packages/redis/connection.py", line 346, in read_response
result = self._read_response(disable_decoding=disable_decoding)
File "/opt/venv/lib/python3.9/site-packages/redis/connection.py", line 369, in _read_response
raise error
redis.exceptions.BusyLoadingError: Redis is loading the dataset in memory

This just means we should just wait for a while for Redis to load the dataset in memory, not necessarily throw this on the user.

This particular case is from intelmq manager calling the command: sudo -u intelmq intelmqctl --type json list queues-and-status.

Hmm, I believe that while bots should wait, the intelmqctl is a one-time tool, so it in my opinion should end with a user-friendly command indicating starting Redis. On the other hand, the API wrapper should handle it gracefully, and just retry. What do you think?

Well, for some intelmqctl is a CLI "API" ;-)

Hmm, I believe that while bots should wait, the intelmqctl is a one-time tool, so it in my opinion should end with a user-friendly command indicating starting Redis. On the other hand, the API wrapper should handle it gracefully, and just retry. What do you think?

I agree that one-time tool should probably just notify the user that Redis is not (yet) ready and that the user should wait and try again.

The API wrapper should probably wait for a little while, but eventually do the same really. Redis can be unavailable for a quite a while if the dataset is big (or if it crashes again, this happend to us when redis - in docker container - ran out of memory).