Repository navigation
Closed
Labels
Description
Bug Report
I have a Chef cookbook that deploys Concourse. This is fine, but one of the things it makes difficult is controlling the timing of delayed actions. As an overview, the actions taken by an actual installation look something like this:
- Do a bunch of postgres init stuff- initdb, create the 'atc' database, write out conf files
- Register delayed restarts because we changed config files
- Install concourse, kickstart concourse-web
- Chef run is done! Now do the delayed restarts of postgres and concourse
Everything Works(tm) in Vagrant, but in EC2, with 2.3.1, this fails pretty reliably. The atc database appears to be partly set up:
atc=> \dt
List of relations
Schema | Name | Type | Owner
--------+-------------------+-------+-------
public | migration_version | table | atc
(1 row)
atc=> select * from migration_version;
version
---------
(0 rows)
The concourse logs look like
Oct 25 22:23:27 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434207.567716599","source":"atc","message":"atc.db.migrations.failed-to-acquire-lock-retrying","log_level":2,"data":{"error":"pq: the database system is shutting down","session":"2"}}
Oct 25 22:23:32 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434212.579482079","source":"atc","message":"atc.db.migrations.failed-to-acquire-lock-retrying","log_level":2,"data":{"error":"pq: the database system is shutting down","session":"2"}}
Oct 25 22:23:37 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434217.592168808","source":"atc","message":"atc.db.migrations.failed-to-acquire-lock-retrying","log_level":2,"data":{"error":"pq: the database system is shutting down","session":"2"}}
Oct 25 22:23:42 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434222.599715471","source":"atc","message":"atc.db.migrations.failed-to-acquire-lock-retrying","log_level":2,"data":{"error":"pq: the database system is shutting down","session":"2"}}
Oct 25 22:23:47 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434227.771785975","source":"atc","message":"atc.db.migrations.failed-to-acquire-lock-retrying","log_level":2,"data":{"error":"pq: the database system is starting up","session":"2"}}
Oct 25 22:23:52 ip-172-29-1-168 concourse[10032]: {"timestamp":"1477434232.796749353","source":"atc","message":"atc.db.migrations.migration-lock-acquired","log_level":1,"data":{"session":"2"}}
Oct 25 22:23:53 ip-172-29-1-168 systemd[1]: Stopping Concourse Web...
Oct 25 22:23:53 ip-172-29-1-168 systemd[1]: Started Concourse Web.
Oct 25 22:23:53 ip-172-29-1-168 systemd[1]: Starting Concourse Web...
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: {"timestamp":"1477434247.272916317","source":"atc","message":"atc.db.migrations.migration-lock-acquired","log_level":1,"data":{"session":"2"}}
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: {"timestamp":"1477434247.307472944","source":"atc","message":"atc.db.migrations.failed-to-run-migrations","log_level":3,"data":{"error":"Could not get DB version: sql: no rows in result set","session":"2","trace":"goroutine 1 [running]:\ncode.cloudfoundry.org/lager.(*logger).Fatal(0xc42004e2a0, 0xe35cad, 0x18, 0x
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: mp/build/9674af12/gopath/src/github.com/concourse/bin/vendor/github.com/jessevdk/go-flags/parser.go:185 +0x74\nmain.main()\n\t/tmp/build/9674af12/gopath/src/github.com/concourse/bin/cmd/concourse/main.go:29 +0x113\n"}}
Oct 25 22:24:07 ip-172-29-1-168 systemd[1]: concourse-web.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 25 22:24:07 ip-172-29-1-168 systemd[1]: Unit concourse-web.service entered failed state.
Oct 25 22:24:07 ip-172-29-1-168 systemd[1]: concourse-web.service failed.
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: panic: Could not get DB version: sql: no rows in result set
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: goroutine 1 [running]:
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: panic(0xce9560, 0xc420148d60)
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: /usr/local/go/src/runtime/panic.go:500 +0x1a1
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: code.cloudfoundry.org/lager.(*logger).Fatal(0xc42004e2a0, 0xe35cad, 0x18, 0xef9cc60, 0xc420148d60, 0x0, 0x0, 0x0)
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: /tmp/build/9674af12/concourse/src/code.cloudfoundry.org/lager/logger.go:152 +0x41c
Oct 25 22:24:07 ip-172-29-1-168 concourse[10431]: github.com/concourse/atc/db/migrations.LockDBAndMigrate(0xefaf220, 0xc42004e2a0, 0xe2fd36, 0x13, 0x7ffcf9e1ff69, 0x1c, 0xefaf220, 0xc42004e2a0, 0xc4201c6ce8, 0x599f23)
There is a certain degree of "doctor, doctor, it hurts when I do this" here, but I don't really want to have to litigate a move away from Chef, and it also seems like the "set up the database" step shouldn't fail like this.
Activity
concourse-bot commentedon Oct 25, 2016
Hi there!
We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.
The current status is as follows:
This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.
vito commentedon Oct 26, 2016
Sounds like it maybe died midway through setting up the migrations table? That's a little odd as it happens in one transaction: https://github.com/BurntSushi/migration/blob/master/migration.go#L232-L235
I'd be surprised if any of this was Chef related, but it sounds like your database just straight up got corrupt. Don't know if there's much we can do here.
ahelal commentedon Oct 26, 2016
@hfinucane I have an ansible role, but don't experience anything smiler. Not sure if that helps https://github.com/ahelal/ansible-concourse, But i had smiler issues with Chef before
hfinucane commentedon Oct 26, 2016
I mean, it's Chef related only in the sense that it's super hard to get Chef to not do this while also preserving the ability to have it "do the right thing" if it ever changes any config files later. I can replicate this failure pretty reliably, if that makes you feel more like digging in to it. Happy to produce pg configs, os configs, etc.
hfinucane commentedon Oct 26, 2016
Alright, environment summary- AWS, CentOS 7, EBS, no LVM, XFS root partition mounted with 'defaults', which
mountsays resolves to(rw,relatime,seclabel,attr2,inode64,noquota). Using Postgres 9.5 from Software Collections, postgresql.conf is pretty risible, and doesn't do much of anything.The postgres logs agree with everything else:
Although 'character 21' seems a little odd.
I'm willing to close this if this 'has to be' a pg-side data corruption issue, and you're sure it's transactional on the Concourse side :/.
hfinucane commentedon Oct 26, 2016
OK, with
pg_log_statement=all:So the problem isn't bouncing postgres, or that I've somehow managed to turn on libeatmydata, but the problem is (probably?) bouncing concourse while it's getting set up.
hfinucane commentedon Oct 26, 2016
Are you sure this is wrapped in a transaction? If I type 'BEGIN;' at the prompt I can get
LOG: statement: BEGIN;in the log.hfinucane commentedon Oct 27, 2016
Yeah, so
migrate()in BurntSushi/migration looks like this:This is more obvious with a super-verbose log from a successful build:
vito commentedon Dec 30, 2016
oh gosh. yeah, despite the code saying
func createVersionTable(tx LimitedTx) error {it looks like thattxisn't actually a transaction. maybe that's what they mean byLimited. :P bummer.i'll mark this as a bug and maybe we'll submit a PR upstream (though it'd happen quicker if someone else did it cough). thanks for the sleuthing!
[-]Problems with database setup in 2.3.1[/-][+]Initial database setup is not atomic and can become wedged if interrupted[/+]concourse-bot commentedon Feb 8, 2017
Hello again!
All stories related to this issue have been accepted, so I'm going to automatically close this issue.
At the time of writing, the following stories have been accepted:
If you feel there is still more to be done, or if you have any questions, leave a comment and we'll reopen if necessary!
hfinucane commentedon Feb 15, 2017
Thanks everyone, I'm excited to try it.