Coder Social home page Coder Social logo

ecto-ordered's People

Contributors

gjaldon avatar mootpointer avatar yrashk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ecto-ordered's Issues

Still maintained ?

Hello!

I'd like to know if this repo is still maintained so that I can try to contribute to it.

Thanks ! ๐Ÿ˜„

Reconsider interface

At the moment the interface for setting the ranking column is a set_order/4 which is fine, but makes things inconvenient if you only want to set the scope column (which is something I've done in Zova's implementation).

So, perhaps set_order/2 with a keyword list of options is more appropriate.

To continue along that line, then maybe a __using__ macro would make sense to push that config out of the normal flow.

Postgres ShareLock deadlocks occur with large number of writes

In a write-heavy environment reordering results in ShareLock deadlocks in PostgreSQL.

Relevant application error trace:

Process 14260 waits for ShareLock on transaction 1966288; blocked by process 14258.
Process 14258 waits for ShareLock on transaction 1966289; blocked by process 14260.
    (ecto) lib/ecto/adapters/sql.ex:440: Ecto.Adapters.SQL.execute_or_reset/7
    (ecto_ordered) lib/ecto_ordered.ex:242: EctoOrdered.increment_other_ranks/2
    (ecto_ordered) lib/ecto_ordered.ex:172: EctoOrdered.ensure_unique_position/2
    (ecto) lib/ecto/repo/schema.ex:456: anonymous fn/2 in Ecto.Repo.Schema.run_prepare/2
    (elixir) lib/enum.ex:1811: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/repo/schema.ex:193: anonymous fn/14 in Ecto.Repo.Schema.do_insert/4
    (ecto) lib/ecto/repo/schema.ex:768: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
    (ecto) lib/ecto/adapters/sql.ex:576: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
    (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
    (db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3

Relevant lines from postgresql.log:

ERROR:  deadlock detected
DETAIL:  Process 14254 waits for ShareLock on transaction 1929658; blocked by process 14258.
	Process 14258 waits for ShareLock on transaction 1929659; blocked by process 14254.
	Process 14254: UPDATE "tasks" AS t0 SET "order" = t0."order" + $1 WHERE (t0."order" >= $2)
	Process 14258: UPDATE "tasks" AS t0 SET "order" = t0."order" + $1 WHERE (t0."order" >= $2) AND (t0."id" != $3)
HINT:  See server log for query details.
CONTEXT:  while updating tuple (341,256) in relation "tasks"
STATEMENT:  UPDATE "tasks" AS t0 SET "order" = t0."order" + $1 WHERE (t0."order" >= $2)

I'm not sure if this has been encountered before by you @mootpointer. I'd be happy to submit a PR but I'm not sure I know where to start.

Ecto 2 / Ecto.Multi version

Since callbacks have been deprecated since Ecto 1.1 and are being removed in Ecto 2, are there plans to update to a solution which doesn't rely on callbacks?

I'm guessing it's going involve some use of Ecto.Multi to handle the transactional side of this without having to pessimistically lock.

I'm happy to help out, I'm just wondering whether there were plans or if there was a better solution you could point to.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.