Nebo15 / annon.api

Configurable API gateway that acts as a reverse proxy with a plugin system.
http://docs.annon.apiary.io/
MIT License
331 stars 25 forks source link

Race condition when settings are applied #256

Closed AndrewDryga closed 7 years ago

AndrewDryga commented 7 years ago
{"time":"2017-06-21T10:02:13.889Z","sourceLocation":{"moduleName":null,"line":null,"functionName":null,"file":null},"severity":"ERROR","metadata":{"error_logger":"format"},"logMessage":"#PID<0.31977.8> running Annon.ManagementAPI.Router terminated\nServer: 35.187.188.208:8080 (http)\nRequest: PUT /apis/ca9e5956-1cb3-47a1-94ba-d5c489301edb/plugins/cors\n** (exit) an exception was raised:\n    ** (Ecto.ConstraintError) constraint error when attempting to insert struct:\n\n    * unique: plugins_pkey\n\nIf you would like to convert this constraint into an error, please\ncall unique_constraint/3 in your changeset and define the proper\nconstraint name. The changeset defined the following constraints:\n\n    * unique: plugins_api_id_name_index\n    * foreign_key: plugins_api_id_fkey\n\n        (ecto) lib/ecto/repo/schema.ex:493: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3\n        (elixir) lib/enum.ex:1229: Enum.\"-map/2-lists^map/1-0-\"/2\n        (ecto) lib/ecto/repo/schema.ex:479: Ecto.Repo.Schema.constraints_to_errors/3\n        (ecto) lib/ecto/repo/schema.ex:213: anonymous fn/13 in Ecto.Repo.Schema.do_insert/4\n        (ecto) lib/ecto/repo/schema.ex:684: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6\n        (ecto) lib/ecto/adapters/sql.ex:620: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3\n        (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4\n        (db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3"}
AndrewDryga commented 7 years ago

Reproduces with UUID's:

{"timestamp":"2017-07-19T14:43:30.102Z","sourceLocation":{"line":null,"function":null,"file":null},"severity":"ERROR","metadata":{"error_logger":"format"},"jsonPayload":{"serviceContext":{"version":null,"service":null},"message":"#PID<0.3268.0> running Annon.ManagementAPI.Router terminated\nServer: 35.187.188.208:8080 (http)\nRequest: PUT /apis/35d6d358-d33a-423a-9e96-88a2b235d3f5\n** (exit) an exception was raised:\n    ** (Ecto.ConstraintError) constraint error when attempting to insert struct:\n\n    * unique: apis_pkey\n\nIf you would like to convert this constraint into an error, please\ncall unique_constraint/3 in your changeset and define the proper\nconstraint name. The changeset defined the following constraints:\n\n    * unique: api_unique_request_index\n    * unique: apis_name_index\n\n        (ecto) lib/ecto/repo/schema.ex:493: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3\n        (elixir) lib/enum.ex:1229: Enum.\"-map/2-lists^map/1-0-\"/2\n        (ecto) lib/ecto/repo/schema.ex:479: Ecto.Repo.Schema.constraints_to_errors/3\n        (ecto) lib/ecto/repo/schema.ex:213: anonymous fn/13 in Ecto.Repo.Schema.do_insert/4\n        (ecto) lib/ecto/repo/schema.ex:684: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6\n        (db_connection) lib/db_connection.ex:1366: DBConnection.transaction_nested/2\n        (db_connection) lib/db_connection.ex:1226: DBConnection.transaction_meter/3\n        (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3"}}