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

Sync fails with 'too many SQL variables' in select #2559

Open
LZRS opened this issue May 31, 2024 · 3 comments · May be fixed by #2562
Open

Sync fails with 'too many SQL variables' in select #2559

LZRS opened this issue May 31, 2024 · 3 comments · May be fixed by #2562
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue

Comments

@LZRS
Copy link
Collaborator

LZRS commented May 31, 2024

Describe the bug
Currently testing with for a user with many patients, sometimes sync fails with error

2024-05-31 03:02:29.267 12229-12649 SQLiteLog               org...rtregister.fhircore.mwcoreDev  E  (1) too many SQL variables in "SELECT *
                                                                                                            FROM LocalChangeResourceReferenceEntity
                                                                                                            WHERE localChangeId IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
2024-05-31 03:02:29.269 12229-12374 WM-WorkerWrapper        org...rtregister.fhircore.mwcoreDev  E  Work [ id=1f1e3585-b4ae-48fb-8194-65764141585c, tags={ org.smartregister.fhircore.engine.sync.AppSyncWorker } ] failed because it threw an exception/error
                                                                                                    java.util.concurrent.ExecutionException: android.database.sqlite.SQLiteException: too many SQL variables (code 1 SQLITE_ERROR): , while compiling: SELECT *
                                                                                                            FROM LocalChangeResourceReferenceEntity
2024-05-31 03:02:29.271 12229-12374 WM-WorkerWrapper        org...rtregister.fhircore.mwcoreDev  E          WHERE localChangeId IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,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?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,

Component
Engine library

Additional context
Checking the LocalEntity table for our app it has around 54k tasks, it might be related to the above query failing on sync upload

Would you like to work on the issue?
Please state if this issue should be assigned to you or who you think could help to solve this issue.

@aditya-07 aditya-07 added P1 High priority issue effort:small Small effort - 2 days labels May 31, 2024
@aditya-07 aditya-07 self-assigned this May 31, 2024
@aditya-07
Copy link
Collaborator

aditya-07 commented May 31, 2024

@LZRS There seems to be a current limit (999) on the size of the variables that can be passed in an IN(..) query.
There are open issues here in Android :
https://issuetracker.google.com/issues/192284727 .

One way to solve this is by splitting the full query to smaller sized queries (maybe inside a utility function) and joining the results in the end.

Let me know if you would like to work on the issue.

@LZRS
Copy link
Collaborator Author

LZRS commented May 31, 2024

Cool. Yes, I'd like to work on the issue

@aditya-07 aditya-07 assigned LZRS and unassigned aditya-07 May 31, 2024
@aditya-07
Copy link
Collaborator

Cool. Yes, I'd like to work on the issue

Assigned to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue
Projects
Status: New
Development

Successfully merging a pull request may close this issue.

2 participants