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

New error when data has reached certain size #101

Open
coffeymatt opened this issue Jun 1, 2021 · 3 comments
Open

New error when data has reached certain size #101

coffeymatt opened this issue Jun 1, 2021 · 3 comments

Comments

@coffeymatt
Copy link

I've started seeing an error in my app, which I guess is occurring now data has reached a certain size?:

2021-06-01 16:29:56.278 1669-1982/xxx.app E/SQLiteLog: (1) too many SQL variables
2021-06-01 16:29:56.306 1669-1669/xxx.app E/Capacitor/Console: File: http://localhost/vendor.js - Line 76604 - Msg: WebSQL threw an error Error: a statement with no error handler failed: too many SQL variables (code 1): , while compiling:
SELECT 'by-sequence'.seq AS seq, 'by-sequence'.deleted AS deleted, 'by-sequence'.json AS data, 'by-sequence'.rev AS rev, 'document-store'.json AS metadata FROM 'document-store' JOIN 'by-sequence' ON 'by-sequence'.seq = 'document-store'.winningseq WHERE 'document-store'.id IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,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?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ORDER BY 'document-store'.id ASC LIMIT -1 OFFSET 0
#################################################################
Error Code : 1 (SQLITE_ERROR)

I'm still investigating further, this is as much as I've been able to pull out of an android device so far. This seems like a fairly fundamental issue rather than the simple query I'm running.

@paolosanchi
Copy link
Contributor

I think it's somehow related to this:
pouchdb/pouchdb#7011

That query seems to be composed here:
https://github.com/pouchdb/pouchdb/blob/a5a920c9d325ff2e1c65149605193b2dfe8dbb63/tests/integration/deps/pouchdb-3.0.6-postfixed.js#L4233

My supposition is you can't fetch more than 1000 changes per time, due to a limitation of the query engine (WebSql).

Probably you are doing a replication, and that number should be controlled by the following options:

options.batch_size:
options.batches_limit: 

details in docs:
https://pouchdb.com/api.html#replication

Maybe the revs_limit option could be a thing involved, but probably not, I've just took a look to the source:
https://pouchdb.com/api.html#create_database

@paolosanchi
Copy link
Contributor

paolosanchi commented Jun 2, 2021

I just realizes that pouchdb-adapter-cordova-sqlite depends on pouchdb-adapter-websql-core which has been deprecated, and it's official repository has been removed.

@gaodeng created a new one as he says here in pouchdb/pouchdb#7011 (comment)
https://github.com/gaodeng/pouchdb-adapter-websql-core

and fixed your problem.

I could replace the dependency with this one @craftzdog/pouchdb-adapter-websql-core, it's also published on npm

"pouchdb-adapter-websql-core": "^7.0.0"

What do you think @daleharvey?

@coffeymatt, please tell me if you solve by just tweaking the parameters.

@coffeymatt
Copy link
Author

@paolosanchi What you're suggesting might be a good long term solution.

In the meantime, I've worked around it, I changed my query:

const results = await this.caseDb.find({
selector: {name: {$exists: true}}
});

To a simpler:

const results = await this.caseDb.allDocs({
include_docs: true,
});

And then filtering what I need with a for loop on all docs. It's an ok work around for my scenario, but maybe not ideal for others. In the longer term I might need to find a more supported database solution for my ionic app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants