erquhart
erquhart14mo ago

500 on import attempt

❯ npx convex import --replace ~/Downloads/snapshot_prod_1704403720633536757.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_1704403720633536757.zip" failed
500 Internal Server Error: InternalServerError: Your request couldn't be completed. Try again later.
❯ npx convex import --replace ~/Downloads/snapshot_prod_1704403720633536757.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_1704403720633536757.zip" failed
500 Internal Server Error: InternalServerError: Your request couldn't be completed. Try again later.
33 Replies
erquhart
erquhartOP14mo ago
Changing the filename doesn't break anything does it?
lee
lee14mo ago
hi yes i just saw this in sentry. sorry about that, fixing imminently
erquhart
erquhartOP14mo ago
Thank you!
lee
lee14mo ago
should be fixed now. was an issue on our side, unrelated to filename thanks for reporting!
erquhart
erquhartOP14mo ago
Thanks! Now seeing this:
503 Service Unavailable: OptimisticConcurrencyControlFailure: Hit an error while importing:
Data read or written in this mutation changed while it was being run. Consider reducing the amount of data read by using indexed queries with selective index range expressions (https://docs.convex.dev/database/indexes/).
503 Service Unavailable: OptimisticConcurrencyControlFailure: Hit an error while importing:
Data read or written in this mutation changed while it was being run. Consider reducing the amount of data read by using indexed queries with selective index range expressions (https://docs.convex.dev/database/indexes/).
Now it's 502 bad gateway
lee
lee14mo ago
the bad gateway is because i restarted your deployment to fix it. the concurrency control failure is unexpected, but might be transient 🤔
erquhart
erquhartOP14mo ago
okay, trying again 503 again, last pasted message It tries for a little longer now before the message though
lee
lee14mo ago
the import is going to conflict with any ongoing mutations, which might be causing the OCC if you have a lot of mutations (but it should be around the same as an npx convex deploy). i'll look into it
erquhart
erquhartOP14mo ago
Okay. I'm importing to my dev server, which has no queries or mutations running right now
lee
lee14mo ago
😦 looks like you've hit a limitation of npx convex import (one i need to document better and fix the error message). it works reliably in two cases (1) importing a deployment's own backup into the same deployment, and (2) importing one deployment's export into another deployment if both deployments were created with versions >1.7. unfortunately your import doesn't fit either case. the problem is your table with id 48 (you can see each table's id in the snapshot's _tables/documents.jsonl file) from the prod deployment has the same id as a system table in the dev deployment. so if we performed the import, the _id fields would conflict.
erquhart
erquhartOP14mo ago
Is there anything I can do to make the export work? is it possible to somehow redeploy a given deployment in place to bring it up to date w/ 1.7 conventions? I could do that with both deployments if so even a one-off fix on your end would be welcome, downtime is no problem as we're not live yet. I just need the data and relations preserved. We can make a new project, whatever is needed.
lee
lee14mo ago
thinking it over on our end. one of the possible solutions is to rewrite all _id rows for the conflicting table. ideally that would be done by npx convex import but you could also do it manually.
erquhart
erquhartOP14mo ago
that's the biggest table 😭
lee
lee14mo ago
there may be other options, i'll ask around btw by "manually" i meant write a python script, not actually manually. still, this is unfortunate if there are foreign references
erquhart
erquhartOP14mo ago
yeah I can script it if need be
lee
lee14mo ago
do you have relations pointing to the _id field of this table? or do you care about the _id field staying stable for another reason (it's persisted in stripe or something)? curious for helping decide
erquhart
erquhartOP14mo ago
hmm actually no, those ids don't matter for that particular table if I deploy to prod does that make prod a 1.7 deployment? Like I could do that and then both dev and prod would be 1.7? Okay, I'll redeploy prod and try an export from that
lee
lee14mo ago
sorry, no. there's a problem if either deployment was created before 1.7. redeploying won't change the table ids, so there will still be a conflict. i think we have a reasonable solution, but we need some changes on our side to make it work. the solution is to remove _id fields from the conflicting table's (with id 48) documents.jsonl in the zip file -- i did this in a text editor replacing the regex "_id":"[^"]+", with an empty string. and also remove the table from _tables/documents.jsonl. then the import will pick a new table id and new _id fields for all documents. it requires a code change on our side though, which i'm working on now
erquhart
erquhartOP14mo ago
sounds great, thank you! I'll stay tuned @lee just checking to see if there's any update here
lee
lee14mo ago
hi! still working on the code change to make this work. i expect to ship it later today
erquhart
erquhartOP14mo ago
thank you!
lee
lee14mo ago
sorry for the delays. should be ready now to try. you will need to remove the _id fields from that table and remove the entry from _tables/documents.jsonl Oh and if you get an error about some other table having a conflict, or you see the OCC error again, let me know. We can probably work out a solution. Sorry about the difficulties.
erquhart
erquhartOP14mo ago
Still need to try this, will update when I'm up and running, hopefully today or tomorrow @lee (for whenever you're on working hours) I've done this with table 48, and am now getting a (helpful!) error message that table 57 also has conflicting ids with a system table. The ids in table 57 have multiple relations per row :/ Sorry for the delayed feedback on this, my app was down for a backend refactor and I just got back to shipping
lee
lee14mo ago
darn i missed that conflict. how feasible would it be to start a new project and import the data into that new project? the old projects have these sorts of conflicts. if starting a new project is cumbersome, we've been thinking about solutions that can reset a dev deployment without touching prod, but it's not implemented yet.
erquhart
erquhartOP14mo ago
Wouldn't importing old data into a new project still have the same issues potentially? I can try it tomorrow
lee
lee14mo ago
I think i made new projects have system tables that don't conflict with old projects. Let's see if it works 🤞
erquhart
erquhartOP14mo ago
npx convex import --replace ~/Downloads/snapshot_prod_20240115.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_20240115.zip" failed
408 Request Timeout
npx convex import --replace ~/Downloads/snapshot_prod_20240115.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_20240115.zip" failed
408 Request Timeout
Ran for a while before timing out. Subsequent attempts result in:
❯ npx convex import --replace ~/Downloads/snapshot_prod_20240115.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_20240115.zip" failed
503 Service Unavailable: OptimisticConcurrencyControlFailure: Hit an error while importing:
Data read or written in this mutation changed while it was being run. Consider reducing the amount of data read by using indexed queries with selective index range expressions (https://docs.convex.dev/database/indexes/).
❯ npx convex import --replace ~/Downloads/snapshot_prod_20240115.zip
✖ Importing data from "/Users/erquhart/Downloads/snapshot_prod_20240115.zip" failed
503 Service Unavailable: OptimisticConcurrencyControlFailure: Hit an error while importing:
Data read or written in this mutation changed while it was being run. Consider reducing the amount of data read by using indexed queries with selective index range expressions (https://docs.convex.dev/database/indexes/).
lee
lee14mo ago
well i'm glad we got past the previous errors. thanks for stress testing the system! i'm not sure where this timeout is coming from (i don't think we set a timeout explicitly), but i can repro by trying to import a large enough file. looking into it
erquhart
erquhartOP14mo ago
Thank you! Mine was 3.3mb Well, the zip is 3.3mb My two largest tables are 16mb and 10mb unzipped documents.jsonl files that is
lee
lee14mo ago
sorry forgot to update here. i found the timeout and i'm working on a fix. i think it requires CLI changes though so it would be released with convex 1.9 basically currently npx convex import does a single HTTP request, which uploads the file and imports the data. by splitting up the APIs into more phases we should become more resilient to timeouts and also transient errors
erquhart
erquhartOP14mo ago
Got it 👍
lee
lee13mo ago
npx convex import should support much bigger files now. Thanks for your patience https://news.convex.dev/announcing-convex-1-9/
Convex News
Announcing Convex 1.9
Big Import and Export Improvements When we released ZIP file imports and exports in Convex 1.7, it wasn't long before industrious developers started hitting the limitations. We’ve got some big improvements for you. * File storage can now be included in Snapshot Export * Snapshot import via npx convex import
erquhart
erquhartOP13mo ago
Thank you!!

Did you find this page helpful?