mariusor / brutalinks

Link aggregator inspired by (old)reddit using ActivityPub federation. (mirror repository)
https://brutalinks.tech
MIT License
261 stars 12 forks source link

Error bootstrapping a database #24

Closed eyedeekay closed 5 years ago

eyedeekay commented 5 years ago

I am trying to set up an instance of littr.go, but unfortunately I'm quite bad at debugging SQL-related issues. When I attempt to bootstrap the database, I get the following error:

    time="2019-08-27T23:00:51-04:00" level=error msg="query: create table items (
    id serial constraint items_pk primary key,
    key char(32) unique,
    mime_type varchar default NULL,
    title varchar default NULL,
    data text default NULL,
    score bigint default 0,
    path ltree default NULL,
    submitted_by int references accounts(id),
    submitted_at timestamp default current_timestamp,
    updated_at timestamp default current_timestamp,
    metadata jsonb default '{}',
    flags bit(8) default 0::bit(8)
    );" file=/home/dev/go/src/github.com/mariusor/littr.go/app/cmd/bootstrap.go line=373 trace="goroutine 1 [running]:
    runtime/debug.Stack(0x9eca36, 0x9, 0xc00025bc28)
        /snap/go/4301/src/runtime/debug/stack.go:24 +0x9d
    github.com/mariusor/littr.go/internal/errors.Annotatef(0xaab100, 0xc0000c1c20, 0x9eca36, 0x9, 0xc00025bc28, 0x1, 0x1, 0x0, 0x0)
        /home/dev/go/src/github.com/mariusor/littr.go/internal/errors/errors.go:91 +0xad
    github.com/mariusor/littr.go/app/cmd.BootstrapDB(0xc0000a61c0, 0x0, 0x0)
        /home/dev/go/src/github.com/mariusor/littr.go/app/cmd/bootstrap.go:373 +0xa6e
    main.main()
        /home/dev/go/src/github.com/mariusor/littr.go/cli/bootstrap/main.go:77 +0x54b
    "

Is this a bug, or am I missing something?

mariusor commented 5 years ago

Hi, thank you for trying my project, but for the moment the codebase is in relative flux as I'm trying to migrate to a different ActivityPub backend.

I'll take a look as soon as possible to see what the problem is, but on a first look it might not be an error, just a debug message. Have you tried checking if bootstrap has actually created the tables ?

eyedeekay commented 5 years ago

Looks like it stops immediately after it creates the accounts table, none of the others are created.

mariusor commented 5 years ago

OK, thanx for double checking. Currently I'm busy with some work in another part of the project but keep an eye on this ticket, I'll have some updates soon (hopefully the weekend).

mariusor commented 5 years ago

Hi, so I've tested with latest master version and for me everything works fine out of the box:

$ ./bin/bootstrap -overwrite -testing -seed
DEBU[0000] Connecting to postgres@localhost:5432//postgres 
DEBU[0000] Connecting to postgres@localhost:5432//littr-test 
DEBU[0000] Connecting to littr-test@localhost:5432//littr-test 
DEBU[0000] Connecting to littr-test@localhost:5432//littr-test 
DEBU[0000] Connecting to littr-test@localhost:5432//littr-test 
DEBU[0000] Connecting to littr-test@localhost:5432//littr-test 

Can you dump your .env file here, please?

Also, which postgresql version are you using ?

eyedeekay commented 5 years ago

It's not altered much, I tried to remove potentially sensitive information, hopefully it is still helpful.


HOSTNAME=localhost
LISTEN=:3000
ENV=dev
DB_HOST=db
DB_NAME=littr
DB_USER=postgres
DB_PASSWORD=postgrespassword
POSTGRESS_PASSWORD=postgrespassword
SESS_AUTH_KEY=16_chars_enc_key=
SESS_ENC_KEY=16_chars_enc_key+
SESS_BACKEND=cookie
DISABLE_SESSIONS=false
DISABLE_DOWNVOTING=false
DISABLE_VOTING=false

postgresql version is version 10.9-0ubuntu0-18.10.1

mariusor commented 5 years ago

Nothing looks weird and postgresql 10 is fine.

I'm not sure what the problem is, so I added a bit more debugging messages (in a8508c1eb30dcde) to the bootstrap command. Please try again and paste the output of the error. It should now include a "wrapped" field with the message of the underlying db problem.

mariusor commented 5 years ago

@eyedeekay I'm going to close this ticket as my ongoing effort is to move away from using a local database backend for littr.go in favour of using a generic ActivityPub service. This will make the bootstrapping command obsolete, or at least, heavily modify its functionality.

You can track the progress for this task in PR #25.

Sorry for this abrupt end :)