Discourse ran locally for dev stops after a few restarts (macOS)


(Mikael Säker) #1

I’m running a local Discourse on a High Sierra machine, from master. All rspec tests pass ok and everything runs okay for a while. But after a few restarts the server just starts stalling. I’m getting some response in the logs (see below), but after some final sql query there’s nothing.

I’ve looked for stale processes, restarted and flushed redis but nothing helps short of wiping the whole thing and rebuilding it, which is very tedious.

I’ve tried to find anything on the forum about this issue, but to no avail. If anyone got a pointer as to what’s going on, I would be very grateful.

Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.4-p301), codename: Private Caller
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
I, [2018-01-12T11:23:44.612920 #75343]  INFO -- : Started GET "/" for 127.0.0.1 at 2018-01-12 11:23:44 +0100
I, [2018-01-12T11:23:44.613970 #75343]  INFO -- : Started GET "/stylesheets/admin_787065b7345c06bae0a6b9a059aa7e02eda55089.css?__ws=localhost" for 127.0.0.1 at 2018-01-12 11:23:44 +0100
I, [2018-01-12T11:23:44.614363 #75343]  INFO -- : Started GET "/stylesheets/desktop_theme_2_79351136cf8688063df0d9c90150114b2b9bfbcf.css?__ws=localhost" for 127.0.0.1 at 2018-01-12 11:23:44 +0100
I, [2018-01-12T11:23:44.614668 #75343]  INFO -- : Started GET "/stylesheets/admin_787065b7345c06bae0a6b9a059aa7e02eda55089.css.map" for 127.0.0.1 at 2018-01-12 11:23:44 +0100
D, [2018-01-12T11:23:44.811108 #75343] DEBUG -- :    (83.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
I, [2018-01-12T11:23:44.980174 #75343]  INFO -- : Processing by ListController#latest as HTML
D, [2018-01-12T11:23:45.068186 #75343] DEBUG -- :    (22.5ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
D, [2018-01-12T11:23:45.068723 #75343] DEBUG -- :    (25.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
D, [2018-01-12T11:23:45.073171 #75343] DEBUG -- :    (3.5ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
I, [2018-01-12T11:23:45.105083 #75343]  INFO -- : Processing by StylesheetsController#show as CSS
I, [2018-01-12T11:23:45.106911 #75343]  INFO -- : Processing by StylesheetsController#show_source_map as */*
I, [2018-01-12T11:23:45.107335 #75343]  INFO -- : Processing by StylesheetsController#show as CSS
I, [2018-01-12T11:23:45.111310 #75343]  INFO -- :   Parameters: {"__ws"=>"localhost", "name"=>"admin_787065b7345c06bae0a6b9a059aa7e02eda55089"}
D, [2018-01-12T11:23:45.112606 #75343] DEBUG -- :    (1.9ms)  SELECT "groups"."id", "groups"."name" FROM "groups" ORDER BY "groups"."name" ASC
I, [2018-01-12T11:23:45.112676 #75343]  INFO -- :   Parameters: {"name"=>"admin_787065b7345c06bae0a6b9a059aa7e02eda55089"}
I, [2018-01-12T11:23:45.113830 #75343]  INFO -- :   Parameters: {"__ws"=>"localhost", "name"=>"desktop_theme_2_79351136cf8688063df0d9c90150114b2b9bfbcf"}
D, [2018-01-12T11:23:45.142633 #75343] DEBUG -- :   Theme Load (2.8ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."color_scheme_id" IS NULL LIMIT 1
D, [2018-01-12T11:23:45.143359 #75343] DEBUG -- :   Theme Load (4.2ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."color_scheme_id" IS NULL LIMIT 1
D, [2018-01-12T11:23:45.146208 #75343] DEBUG -- :   Category Load (3.7ms)  SELECT categories.*, t.slug topic_slug FROM "categories" LEFT JOIN topics t on t.id = categories.topic_id WHERE (NOT categories.read_restricted) ORDER BY "categories"."position" ASC
D, [2018-01-12T11:23:45.153093 #75343] DEBUG -- :   Theme Load (0.9ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."id" = 2 LIMIT 1
D, [2018-01-12T11:23:45.201659 #75343] DEBUG -- :   Theme Load (2.0ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."key" = '63ed90c3-fe83-4400-88c9-19a9ac24874c' LIMIT 1

(Angus McLeod) #2

Make sure you’re using postgres v9.5.x. Weird things like this happen to me when I’m using the wrong postgres version.

Also, see if there’s anything in the postgres logs. They’re probably in /usr/local/var/log


(Mikael Säker) #3

Thanks, I’ll try that. I started out on 9.6 but switched to 10 to see if the problem would go away. There’s nothing in the logs, but I can perhaps increase the log level.


(Sam Saffron) #4

10 is definitely something we support, we already have a few sites upgraded for testing

Perhaps try the docker dev env we have it’s a bit slower on Mac but works well


(Mikael Säker) #5

Tried a fresh clone with postgres 9.5. Worked for about 4-5 restarts, then it stops. Also tried a completely new setup on a different machine (also macOS). Same thing. Works for a handful of restarts, then stops responding. The log is a tad different and ends like this:

...
D, [2018-01-15T15:01:14.668587 #60994] DEBUG -- :   Theme Load (1.0ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."color_scheme_id" IS NULL LIMIT 1
D, [2018-01-15T15:01:14.674248 #60994] DEBUG -- :   Theme Load (0.7ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."id" = 2 LIMIT 1
D, [2018-01-15T15:01:14.687624 #60994] DEBUG -- :   Theme Load (4.6ms)  SELECT  "themes".* FROM "themes" WHERE "themes"."key" = '44219d99-31c6-4c1b-92d8-a0b7947c3ec5' LIMIT 1
D, [2018-01-15T15:01:14.693403 #60994] DEBUG -- :   SQL (6.4ms)  UPDATE "users" SET "last_seen_at" = '2018-01-15 14:01:14.595346' WHERE "users"."id" = 1

(Mikael Säker) #6

Hmmm… I just restarted the server, then did “curl localhost:3000”. That worked like a charm and the server responded like it should for a few runs.

Can the culprit be that my browser (Safari) sends old session data when I reload after restart?


(Sam Saffron) #7

I recall a few months back @tgxworld was also seeing some stalls. They all went away when running unicorn in dev. I have seen some of the puma stalls as well on Linux but there is no clear pattern to when this happens.

A repro would be helpful. I run PG 10 for my local dev, but it is Linux.


(Jay Jansheski) #8

I was having this problem too, and while I wouldn’t say I solved it, I was able to make the problem mysteriously disappear by adding a couple of put statements to the show method in the StylesheetsController here. To be precise, I changed that method to

  def show
    put "🐖"
    is_asset_path
    put "🐖"
    show_resource
    put "🐖"
  end

…which is obviously nonsensical; all I can guess (based on answers to this question) is that something was waiting for input in the terminal, and adding the put statements gave it what it needed. Removing the put statements didn’t make the problem return, however, and now I can’t reproduce the issue, but I’ll report back here if I see it crop up again.