Bug 495675 - database error on akonadi startup: too long list passed to SQL engine
Summary: database error on akonadi startup: too long list passed to SQL engine
Status: REPORTED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.2.1
Platform: Gentoo Packages Linux
: NOR grave
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-01 07:24 UTC by Erik Quaeghebeur
Modified: 2024-11-01 07:24 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Quaeghebeur 2024-11-01 07:24:25 UTC
SUMMARY
When akonadi gets started after a boot, I get the following database error reported on in my log:

---
akonadiserver[2437]: org.kde.pim.akonadiserver: DATABASE ERROR while PREPARING QUERY:
akonadiserver[2437]: org.kde.pim.akonadiserver:   Error code: "1"
akonadiserver[2437]: org.kde.pim.akonadiserver:   DB error:  "too many SQL variables"
akonadiserver[2437]: org.kde.pim.akonadiserver:   Error text: "too many SQL variables Kon statement niet uitvoeren"
akonadiserver[2437]: org.kde.pim.akonadiserver:   Query: "SELECT DISTINCT ResourceTable.name FROM PimItemTable LEFT JOIN CollectionTable ON ( PimItemTable.collectionId = CollectionTable.id ) LEFT JOIN ResourceTable ON ( CollectionTable.resourceId = ResourceTable.id ) WHERE ( PimItemTable.id IN ( :0, :1, :2, […], :65065, :65066 ) )"
---
I elided the list of PimItemTable.id values; all intermediate values are present. (“Kon statement niet uitvoeren” is Dutch for “Could not execute statement”.)

When I restart akonadi (akonadictl restart), the same happens (I see it reported on the console), but it does not seem to be logged.

The issue is clear: a list is passed that is too long to be processed. The code should never pass a list that is too long to be processed to the SQL engine. All occurrences of lists passed to SQL queries in the code should be sanity checked. Likely all these occurrences can be fixed by rewriting the SQL queries in such a way that the list being passed is implicit in them, as is the case for another occurrence of this phenomenon that I reported in Bug 451620. 

STEPS TO REPRODUCE
1. (Re)start akonadi

OBSERVED RESULT
Database error

EXPECTED RESULT
No database error

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0 
Qt Version: 6.7.2

ADDITIONAL INFORMATION
I am using the sqlite backend, sqlite version 3.46.1.

If the plan to use sqlite as the default backend continues, this (type of) issue will appear again and again unless the underlying code is fixed to not pass too long lists (silly long, TBH, 65k! elements).