bonfire-networks / bonfire-app

Bonfire - tend to your digital life in community. Customise and host your own online space and control your experience at the most granular level.
https://bonfirenetworks.org
GNU Affero General Public License v3.0
522 stars 37 forks source link

Bug: Co-Op Cloud Release, Migration Error #913

Closed ratchetpatrol closed 3 months ago

ratchetpatrol commented 3 months ago

Got a pretty fresh install of the Bonfire app loaded up this morning. Nearly everything default still. I got to the "Something went wrong" screen on the public-facing site, found out it was an Oban Elixir error. Went to Google that fix, and that brought me here. (https://github.com/bonfire-networks/bonfire-app/issues/854)

Only difference when I followed along with that fix, is when I went to migrate the Repo, instead I was hit with:

19:34:50.385 [error] Error when running migrations on startup: %Ecto.MigrationError{message: "migrations can't be executed, migration name hashtag is duplicated"}

To Reproduce Steps to reproduce the behavior:

  1. Go to Elixir Workshop
  2. Enter 'Bonfire.Application.version'
    1. Enter 'Bonfire.Common.Repo.migrate'
  3. See error

Expected behavior Repos to be migrated, and the skys to open up

Screenshots Screenshot 2024-03-30 154950

Bonfire environment (please complete the following information):

Device (please complete the following information):

Additional context Upon doing a search, the only good extra info I found was this thread, https://elixirforum.com/t/ecto-migration-cant-be-executed-migration-name-is-duplicated/26499/3, where they mentioned ( mix pow.install ) creates a self-migration. Not sure if that's happening with another item maybe, who knows. I'm completely out of my wheelhouse with database management haha.

mayel commented 3 months ago

Thanks for the detailed report! That isn't an error I've seen before but also upon checking the latest docker image (which coop-cloud uses) for the community flavour is 2 months old and so it's worth checking if the error still occurs with a recent version. I will trigger a release and let you know when it's ready. Please note the community flavour is currently in alpha (while classic is in beta), which is why CI doesn't build releases for it by default.

mayel commented 3 months ago

@ratchetpatrol a new build is out, can you please upgrade and let me know the result

ratchetpatrol commented 3 months ago

Screenshot 2024-03-30 215601

Tried it twice. Once on the build I had from before, and since it was basically out of the box anyways, I just started from scratch for this one to test, and same thing unfortunately.

Edit -- I do see now that the 'name' of the duplicated item is different.

mayel commented 3 months ago

@ratchetpatrol a new image is ready to test 🤞 to upgrade without having to start over you can run abra app deploy --force your-server.domain.name

Edit: please hold off, doing some testing of community flavour on my end first

mayel commented 3 months ago

@ratchetpatrol I got the community flavour running fine with coop-cloud on my end, so feel free to give it another shot :)

ratchetpatrol commented 3 months ago

No cigar.

So out the gate after redeploying, it began with the oban peer revolt and such, with a few added nuances that I tagged here for you to see.

%2024-04-01T13:14:05.894699900Z     query: SELECT b0."tag_id", count(b0."id") FROM "bonfire_tagged" AS b0 LEFT OUTER JOIN "pointers_pointer" AS p1 ON p1."id" = b0."tag_id" WHERE (NOT (p1."table_id" = ANY($1))) AND (b0."inserted_at" >= $2) GROUP BY b0."tag_id" ORDER BY b0."count" DESC LIMIT $3
�2024-04-01T13:14:05.894715800Z         (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1
s2024-04-01T13:14:05.894719900Z         (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:952: Ecto.Adapters.SQL.execute/6
s2024-04-01T13:14:05.894723400Z         (ecto 3.11.2) lib/ecto/repo/queryable.ex:232: Ecto.Repo.Queryable.execute/4
n2024-04-01T13:14:05.894727400Z         (ecto 3.11.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
s2024-04-01T13:14:05.894730600Z         (bonfire_tag 0.1.0) lib/tags.ex:124: Bonfire.Tag.Tags.query_list_trending/2
�2024-04-01T13:14:05.894734200Z         (bonfire_common 0.1.0) lib/cache.ex:118: anonymous fn/6 in Bonfire.Common.Cache.do_maybe_apply_cached/4
Z2024-04-01T13:14:05.894737900Z         (cachex 3.6.0) lib/cachex.ex:535: Cachex.execute/3
Y2024-04-01T13:14:05.894741500Z         (cachex 3.6.0) lib/cachex.ex:1: Cachex.execute!/2
v2024-04-01T13:14:27.730388800Z 13:14:27.729 [warning] The `oban_peers` table is undefined and leadership is disabled.
 2024-04-01T13:14:27.730425800Z 
y2024-04-01T13:14:27.730433300Z Run migrations up to v11 to restore peer leadership. In the meantime, distributed plugins
V2024-04-01T13:14:27.730437300Z (e.g. Cron, Pruner, Stager) will not run on any nodes.
 2024-04-01T13:14:27.730441300Z 
�2024-04-01T13:14:57.593874000Z 2024-04-01 13:14:57.593 UTC [1724] ERROR:  relation "public.oban_peers" does not exist at character 13
�2024-04-01T13:14:57.593993300Z 2024-04-01 13:14:57.593 UTC [1724] STATEMENT:  DELETE FROM "public"."oban_peers" AS o0 WHERE (o0."name" = $1) AND (o0."expires_at" < $2)
v2024-04-01T13:14:57.595634600Z 13:14:57.595 [warning] The `oban_peers` table is undefined and leadership is disabled.
 2024-04-01T13:14:57.595663500Z 
y2024-04-01T13:14:57.595672800Z Run migrations up to v11 to restore peer leadership. In the meantime, distributed plugins
V2024-04-01T13:14:57.595678700Z (e.g. Cron, Pruner, Stager) will not run on any nodes.
 2024-04-01T13:14:57.595684500Z 
�2024-04-01T13:14:59.923380800Z 13:14:59.922 [info] [message: "notifier can't receive messages from any nodes, functionality degraded", status: :isolated, source: "oban", event: "notifier:switch"]
^X^C

┌──(rupert㉿kali)-[~]
└─$ abra app run bonfire.gemcity.xyz app bin/bonfire remote
Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]

Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(bonfire@89dc99db1ca9)1> Bonfire.Application.version
"0.9.10-beta.25"
iex(bonfire@89dc99db1ca9)2> Bonfire.Common.Repo.migrate

13:18:06.635 [info] Migrate Bonfire.Common.Repo

13:18:08.947 [error] Error when running migrations on startup: %CompileError{file: "/opt/app/lib/bonfire_umbrella-0.9.10-classic-beta.25/priv/repo/migrations/20220927094947_import_pages.exs", line: 0, description: "cannot compile module Bonfire.Pages.Repo.Migrations.ImportPages (errors have been logged)"}:ok
iex(bonfire@89dc99db1ca9)3> �2024-04-01T13:14:05.894625400Z 13:14:05.892 [error] #PID<0.25116.0> running Bonfire.Web.Endpoint (connection #PID<0.25115.0>, stream id 1) terminated
** (SyntaxError) invalid syntax found on iex:3:1:
    error: unexpected token: "�" (column 1, code point U+FFFD)
    │
  3 │ �2024-04-01T13:14:05.894625400Z 13:14:05.892 [error] #PID<0.25116.0> running Bonfire.Web.Endpoint (connection #PID<0.25115.0>, stream id 1) terminated
    │ ^

Interestingly though, after trying to chug the elixir to migrate the DB, I got flooded with what looks to be just a bunch of of compile / syntax errors for the web portion too. As seen below.

iex(bonfire@89dc99db1ca9)5> "0.9.10-beta.25"
"0.9.10-beta.25"
iex(bonfire@89dc99db1ca9)6> iex(bonfire@89dc99db1ca9)2> Bonfire.Common.Repo.migrate
** (SyntaxError) invalid syntax found on iex:6:5:
    error: invalid character "@" (code point U+0040) in identifier: bonfire@89dc99db1ca9
    │
  6 │ iex(bonfire@89dc99db1ca9)2> Bonfire.Common.Repo.migrate
    │     ^
    │
    └─ iex:6:5
    (iex 1.16.2) lib/iex/evaluator.ex:295: IEx.Evaluator.parse_eval_inspect/4
    (iex 1.16.2) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
    (iex 1.16.2) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
iex(bonfire@89dc99db1ca9)6> 
nil
iex(bonfire@89dc99db1ca9)7> 13:18:06.635 [info] Migrate Bonfire.Common.Repo
** (SyntaxError) invalid syntax found on iex:7:3:
    error: unexpected token: ":" (column 3, code point U+003A)
    │
  7 │ 13:18:06.635 [info] Migrate Bonfire.Common.Repo
    │   ^
    │
    └─ iex:7:3
    (iex 1.16.2) lib/iex/evaluator.ex:295: IEx.Evaluator.parse_eval_inspect/4
    (iex 1.16.2) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
    (iex 1.16.2) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
iex(bonfire@89dc99db1ca9)7> 
nil
iex(bonfire@89dc99db1ca9)8> 13:18:08.947 [error] Error when running migrations on startup: %CompileError{file: "/opt/app/lib/bonfire_umbrella-0.9.10-classic-beta.25/priv/repo/migrations/20220927094947_import_pages.exs", line: 0, description: "cannot compile module Bonfire.Pages.Repo.Migrations.ImportPages (errors have been logged)"}:ok
** (SyntaxError) invalid syntax found on iex:8:3:
    error: unexpected token: ":" (column 3, code point U+003A)
    │
  8 │ 13:18:08.947 [error] Error when running migrations on startup: %CompileError{file: "/opt/app/lib/bonfire_umbrella-0.9.10-classic-beta.25/priv/repo/migrations/20220927094947_import_pages.exs", line: 0, description: "cannot compile module Bonfire.Pages.Repo.Migrations.ImportPages (errors have been logged)"}:ok
    │   ^
    │
    └─ iex:8:3
    (iex 1.16.2) lib/iex/evaluator.ex:295: IEx.Evaluator.parse_eval_inspect/4
    (iex 1.16.2) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
    (iex 1.16.2) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
iex(bonfire@89dc99db1ca9)8> iex(bonfire@89dc99db1ca9)3>

Hadn't had that one, or those, before. Gave just a small sample of them as not to flood this. Essentially they were all the same though. On this particular fresh app instance that I started a few days ago -- I went with classic flavour over community, too. Should I give the community a go as well? If it'll help, I'm all game.

mayel commented 3 months ago

Ok, I have built a new image of the classic flavour and verified that it runs (incl. migrations) on my end. Can you please give it a try after replacing the DB_DOCKER_IMAGE entry in the .env file for one of these:

# For ARM:
DB_DOCKER_IMAGE=ghcr.io/baosystems/postgis:12-3.3
# for x86:
#DB_DOCKER_IMAGE=postgis/postgis:12-3.3-alpine
ratchetpatrol commented 3 months ago

That did it!