Possible bug in cscli decisions list

Hello crowdsec developers. When I execute cscli decisions list -l 100 - it works When I execute cscli decisions list -l 221 - it works When I execute cscli decisions list -l 0 - it works When I execute cscli decisions list -l 222 - it hangs forever even for higher numbers @blotus can this be possible bug ? For version 1.6.5, after upgrade to 1.6.9 still happening
16 Replies
CrowdSec
CrowdSec3mo ago
Important Information
Thank you for getting in touch with your support request. To expedite a swift resolution, could you kindly provide the following information? Rest assured, we will respond promptly, and we greatly appreciate your patience. While you wait, please check the links below to see if this issue has been previously addressed. If you have managed to resolve it, please use run the command /resolve or press the green resolve button below.
Log Files
If you possess any log files that you believe could be beneficial, please include them at this time. By default, CrowdSec logs to /var/log/, where you will discover a corresponding log file for each component.
Guide Followed (CrowdSec Official)
If you have diligently followed one of our guides and hit a roadblock, please share the guide with us. This will help us assess if any adjustments are necessary to assist you further.
Screenshots
Please forward any screenshots depicting errors you encounter. Your visuals will provide us with a clear view of the issues you are facing.
© Created By WhyAydan for CrowdSec ❤️
blotus
blotus3mo ago
how many local decisions do you have ? (-l 0 -o raw | wc -l)
chladic
chladicOP3mo ago
118
blotus
blotus3mo ago
If i had to guess, I'd say a small off-by-one issue in the pagination code when you limit the number of decisions to the exact amount you have hmmm so maybe not that
chladic
chladicOP3mo ago
does not matter of the output type. Also I have postgres 13 in case it can matter
blotus
blotus3mo ago
yeah the output format is handled client side it's most likely something to do with the DB query
chladic
chladicOP3mo ago
I can upgrade postgres to higher version and let you know whether it disappear
blotus
blotus3mo ago
you can try, but I don't think it will change anything (and postgres 13 is EOL in a few months, so it cannot hurt :D) you can try to set db.log_level to debug in /etc/crowdsec/config.yaml, crowdsec will log all queries (so it's very verbose), but we could see if a query seems to be repeated forever (you'll likely want to send the log file in private, it might contain some sensitive data like bouncers IPs or hash of their API key)
chladic
chladicOP3mo ago
@blotus you were right, it keeps repeating over and over same query
blotus
blotus3mo ago
can you paste the query ? (it should not have anything sensitive in it)
chladic
chladicOP3mo ago
time="2025-06-20T12:54:06Z" level=debug msg="driver.Query: query=SELECT \"alerts\".\"id\", \"alerts\".\"created_at\", \"alerts\".\"updated_at\", \"alerts\".\"scenario\", \"alerts\".\"bucket_id\", \"alerts\".\"message\", \"alerts\".\"events_count\", \"alerts\".\"started_at\", \"alerts\".\"stopped_at\", \"alerts\".\"source_ip\", \"alerts\".\"source_range\", \"alerts\".\"source_as_number\", \"alerts\".\"source_as_name\", \"alerts\".\"source_country\", \"alerts\".\"source_latitude\", \"alerts\".\"source_longitude\", \"alerts\".\"source_scope\", \"alerts\".\"source_value\", \"alerts\".\"capacity\", \"alerts\".\"leak_speed\", \"alerts\".\"scenario_version\", \"alerts\".\"scenario_hash\", \"alerts\".\"simulated\", \"alerts\".\"uuid\", \"alerts\".\"remediation\", \"alerts\".\"machine_alerts\" FROM \"alerts\" WHERE EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"until\" >= $1) AND (((NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"origin\" = $2))) AND (NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"origin\" = $3)))) AND (NOT ((NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\"))) AND (\"alerts\".\"source_scope\" LIKE $4 OR \"alerts\".\"source_scope\" = $5)))) ORDER BY \"alerts\".\"created_at\" DESC, \"alerts\".\"id\" DESC LIMIT 100 OFFSET 10900 args=[2025-06-20 12:54:06.329571431 +0000 UTC CAPI lists lists:% crowdsecurity/community-blocklist]" context=ent
time="2025-06-20T12:54:06Z" level=debug msg="driver.Query: query=SELECT \"alerts\".\"id\", \"alerts\".\"created_at\", \"alerts\".\"updated_at\", \"alerts\".\"scenario\", \"alerts\".\"bucket_id\", \"alerts\".\"message\", \"alerts\".\"events_count\", \"alerts\".\"started_at\", \"alerts\".\"stopped_at\", \"alerts\".\"source_ip\", \"alerts\".\"source_range\", \"alerts\".\"source_as_number\", \"alerts\".\"source_as_name\", \"alerts\".\"source_country\", \"alerts\".\"source_latitude\", \"alerts\".\"source_longitude\", \"alerts\".\"source_scope\", \"alerts\".\"source_value\", \"alerts\".\"capacity\", \"alerts\".\"leak_speed\", \"alerts\".\"scenario_version\", \"alerts\".\"scenario_hash\", \"alerts\".\"simulated\", \"alerts\".\"uuid\", \"alerts\".\"remediation\", \"alerts\".\"machine_alerts\" FROM \"alerts\" WHERE EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"until\" >= $1) AND (((NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"origin\" = $2))) AND (NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\" AND \"decisions\".\"origin\" = $3)))) AND (NOT ((NOT (EXISTS (SELECT \"decisions\".\"alert_decisions\" FROM \"decisions\" WHERE \"alerts\".\"id\" = \"decisions\".\"alert_decisions\"))) AND (\"alerts\".\"source_scope\" LIKE $4 OR \"alerts\".\"source_scope\" = $5)))) ORDER BY \"alerts\".\"created_at\" DESC, \"alerts\".\"id\" DESC LIMIT 100 OFFSET 10900 args=[2025-06-20 12:54:06.329571431 +0000 UTC CAPI lists lists:% crowdsecurity/community-blocklist]" context=ent
blotus
blotus3mo ago
I think i understand the issue, i'll try to reproduce it
chladic
chladicOP3mo ago
Fantastic, thanks a lot. Its not really problem for me, but wanted to let you know in case it might cause another issues in future
blotus
blotus3mo ago
i think it can only be triggered by some special limit values, so we should be safe
blotus
blotus3mo ago
GitHub
Fix infinite loop in decisions list for some values of limit by blo...
We were checking if len(ret) (the number of decisions that we will return) was equal to 0, instead of checked the actual amount of rows returned from the database (len(result)), which would prevent...
chladic
chladicOP3mo ago
Fantastic, thanks a lot @blotus

Did you find this page helpful?