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

Production bug - constraint error when attempting to insert #40

Open
Cinderella-Man opened this issue Oct 2, 2019 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Cinderella-Man
Copy link
Owner

Observed in live system:

iex(1)> 15:47:20.982 application=hefty module=Hefty.Algos.Naive.Trader [info] Trader(8654) - Rebuy triggered for trade 253938705 bought @ 0.24153000 as price fallen below 0.24128847
iex(1)> 15:47:20.983 application=hefty module=Hefty.Algos.Naive.Leader [info] Rebuy notification received, starting a new trader
iex(1)> 15:47:21.001 application=hefty module=Hefty.Algos.Naive.Trader [info] Starting trader(9241) on symbol XRPUSDT with budget of 11.36414556234
iex(1)> 15:47:21.261 application=phoenix module=Phoenix.Channel.Server [info] Replied phoenix:live_reload :error
iex(1)> 15:47:23.118 application=hefty module=Hefty.Algos.Naive.Trader [info] Trader(9241) - Placing BUY order for XRPUSDT @ 0.24099, quantity: 47.1
iex(1)> 15:48:38.045 application=hefty module=Hefty.Algos.Naive.Trader [info] Trader(9241) received an transaction of 0.40000000 for BUY order 253948392 @ 0.24099000
iex(1)> 15:48:38.751 application=hefty module=Hefty.Algos.Naive.Trader [info] Trader(9241) received an transaction of 33.00000000 for BUY order 253948392 @ 0.24099000
iex(1)> 15:48:39.005 application=hefty module=Hefty.Algos.Naive.Trader [info] Placing SELL order for XRPUSDT @ 0.24195, quantity: 47.1
iex(1)> 15:48:39.812 application=hefty module=Hefty.Algos.Naive.Trader [info] Trader(9241) received an transaction of 13.70000000 for BUY order 253948392 @ 0.24099000
iex(1)> 15:48:40.215 module=gen_server [error] GenServer #PID<0.2938.0> terminating
** (Ecto.ConstraintError) constraint error when attempting to insert struct:

    * trades_pkey (unique_constraint)

If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `unique_constraint/3` on your changeset with the constraint
`:name` as an option.

The changeset has not defined any constraint.


    (ecto) lib/ecto/repo/schema.ex:687: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
    (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
    (ecto) lib/ecto/repo/schema.ex:672: Ecto.Repo.Schema.constraints_to_errors/3
    (ecto) lib/ecto/repo/schema.ex:274: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
    (hefty) lib/hefty/trades.ex:70: Hefty.Trades.create_trade/1
    (hefty) lib/hefty/algos/naive/trader.ex:269: anonymous fn/5 in Hefty.Algos.Naive.Trader.handle_info/2
    (ecto_sql) lib/ecto/adapters/sql.ex:874: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection) lib/db_connection.ex:1415: DBConnection.run_transaction/4
    (hefty) lib/hefty/algos/naive/trader.ex:268: Hefty.Algos.Naive.Trader.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Broadcast{event: "trade_event", payload: %Hefty.Repo.Binance.TradeEvent{__meta__: #Ecto.Schema.Metadata<:loaded, "trade_events">, buyer_market_maker: true, buyer_order_id: 25394839$
iex(1)> 15:48:40.252 application=hefty module=Hefty.Algos.Naive.Leader [info] Leader restarts process as it died
iex(1)> 15:48:40.252 application=hefty module=Hefty.Algos.Naive.Leader [info] Trader found in the list of traders. Removing
@Cinderella-Man Cinderella-Man added the bug Something isn't working label Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant