dmitriid
Hi all
I’ve been trying a gung-ho approach to updating ecto_sqlite2 to support ecto3, and on the surface it seems to be straightforward enough: implement the new callbacks, make sure functions return updated responses etc. And now I’m stuck in an issue when running ecto tests:
when running ecto’s Migrator.up , the code seemingly runs all the statement until it tries to insert data into one of the tables. Sqlite returns busy , and then the migration fails with
{"busy",0}
{"busy",1}
{"busy",2}
{"busy",3}
{"busy",4}
{"busy",5}
Sqelect.DbConnection.Protocol (#PID<0.278.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.319.0> exited
** (Sqelect.DbConnection.Error) {{:bad_return_value, :too_many_tries}, {GenServer, :call, [#PID<0.315.0>, {:query_rows, "INSERT INTO \"schema_migrations\" (\"version\",\"inserted_at\") VALUES (?1,?2)", [timeout: :infinity, decode: :manual, types: true, bind: [0, "2020-07-28T13:25:33"]]}, :infinity]}}
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:593: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto 3.4.5) lib/ecto/repo/schema.ex:661: Ecto.Repo.Schema.apply/4
(ecto 3.4.5) lib/ecto/repo/schema.ex:263: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(ecto_sql 3.4.5) lib/ecto/migrator.ex:641: Ecto.Migrator.verbose_schema_migration/3
(ecto_sql 3.4.5) lib/ecto/migrator.ex:293: Ecto.Migrator.async_migrate_maybe_in_transaction/6
(ecto_sql 3.4.5) lib/ecto/migrator.ex:211: anonymous fn/5 in Ecto.Migrator.up/4
(ecto_sql 3.4.5) lib/ecto/migrator.ex:493: Ecto.Migrator.lock_for_migrations/4
integration/sqelect/test_helper.exs:93: (file)
The problem is: I don’t have enough knowledge of either Ecto or Elixir to properly debug this issue. If anyone has some spare time to look at this, it would be greatly appreciated.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Not sure you can get any guarantees since the library is only guaranteed to work with Ecto 2.
But, in this case maybe you just haven’t opened it with the right mode (should be serial).
dmitriid
That’s why I’m attempting to port it to Ecto 3
Thank you, I’ll look into that! (even though the underlying esqlite doesn’t let you provide modes)
idi527
AFAIK Ecto 3 locks tables and uses two connections to the db during migrations. Maybe you can use some combination of
:migration_lockoption and the number of connectionspool_size: 1to work around your problem.I couldn’t make your example work since it’s missing a dependency:
dimitarvp
Well, I am authoring an sqlite3 Elixir library (which is a bridge to an excellent Rust library) but life hasn’t been kind this year and I am just beginning to recover and might resume work on the first stable release Soon™.
dmitriid
Ah! Thank you for the tip on the migration_lock_option! I’ll definitely look into that.
Replace
{:sqlitex, "~>1.7.1", path: "deps/sqlitex"}with{:sqlitex, "~>1.7.1"}inmix.exs. I usepathto sprinkle dependencies’ code withIO.inspectdmitriid
Just tried
migration_lock: nil, pool_size: 1and got a different error:Well, it’s progress
So I can look into the underlying cause more closely
dmitriid
I should’ve
inspected moreBasically, the tests end up opening multiple connections anyway. For
TestRepo:For a total of 11 connections. And in my code I end up starting 11 sqlite gen servers which … is not ideal
Lankester
Hello
I am rather fond of Sqlite and thought it would be fun to update
sqlite_ecto2so it works with Ecto 3.I have hit the same
{"busy",0..5}issue as @dmitriid.This appears to be due to the Ecto migrator running the migration in a transaction via an async task, but before the transaction commits the parent task tries to insert into the
schema_migrationstable. I believe this is the cause of the busy responses because the SQLite database is locked at the beginning of the transaction which prevents the insert to theschema_migrationstable from the parent connection.This home-baked debug output from running the tests shows the PIDs associated with the relevant queries and you can see
#PID<0.425.0>starts a transaction but then the parent#PID<0.426.0>tries an insert before the original transaction commits.This seems to be related to the following function in
ecto_sql:https://github.com/elixir-ecto/ecto_sql/blob/b35dd7c08f76396d7289bd6cd490974e99983749/lib/ecto/migrator.ex#L290-L312
Can anybody point me in the right direction so I can solve this in the adapter? I had a play with implementing
lock_for_migrations/3but don’t think this is relevant as there isn’t, to my knowledge, an SQLite command that would modify the behaviour I’m seeing.I can get around the error by setting
supports_ddl_transaction?to false in the adapter, but that doesn’t feel right as Sqlite3 does support DDL in transactions.lud
Hi @Lankester and @dimitarvp , have you made some progress on your implementations of Sqlite3 / Ecto3 ?
I would be glad to help. PM me
dimitarvp
Ah, I’ve got nothing to hide.
Recently started a new job and it’s taking most of my time – initial good impressions, you know.
Also due to the closure of the gyms I got hit by very low energy levels and I am not motivated to work on anything beyond the main job.
Happily though both things will come to an end soon (not the job itself, just the initial flurry of tasks in it) and I expect to resume work on
xqlite. Going to spend an hour on the treadmill in the gym at Monday or I’ll change my name!Last status was that I completely reworked the Rust code and it’s at least 5x faster now, plus much cleaner. And for my library the Rust code is honestly 90% of the work.
What can you do to help? Well, once I have the Rust code in place (which I do, but have to do a few final iterations on it, add some more unit tests and optionally benchmarks) and push it in the GitHub repo, you can contribute test scenarios and the tests themselves. Also I’d appreciate a second pair of eyes on the Elixir API design. Promise to keep you in the loop since you expressed interest. Expect actual updates in the next 2-4 weeks.