Logging sometimes reports wrong database in multisite

I was investigating an issue and it seems like the lines in production.log sometimes report the wrong database.

I’ve seen this a few times before, so this is not a single incident. Here’s a good and clear example where you can see that the third line has been logged as belonging to database db3785 where it obviously is about the same request as the fourth line, which is logged as belonging to db9210.

I was unable to pinpoint the responsible code, it might be deep inside Rails, and this is probably a race condition.

v1.8.x on Unicorn.

No, we’re not using Docker, no, I don’t think that matters here, and no, I don’t expect a quick solution.
Just letting you guys know what we are seeing :slight_smile:

1 个赞

Rails logs are a trashfire, we plan to start using a new format in future

6 个赞

I’ll put this on my list first, it seems like the connection is switched even before logging is complete.

6 个赞

This is really unsolvable with the current log format. @tgxworld is going to investigate making GitHub - roidrage/lograge: An attempt to tame Rails' default policy to log everything. an optional (and hopefully default) log format for rails to avoid this mess and give us properly parsable log files.

3 个赞

Note that lograge can now be enabled via a hidden SiteSetting.logging_provider or setting ENABLE_LOGRAGE to 1. We’ll be testing this on our servers for awhile before deciding if lograge should be the default for all Discourse users.

4 个赞

Is lograge the default now?

1 个赞

Nope but we can make it so.

3 个赞

I am moving this to feature as we already have a system that works nicely for multisite and multisite is very very uncommon.

I am fine to move to lograge by default longer term it will give Discourse Doctor more ammo.

3 个赞

lograge seems like a vast improvement and it took me forever to find this topic to find how to start it.

Is it too soon to un-hide the site setting?

Would it be disastrous to change the default to lograge for new installs?

It’s not immediately clear what discourse-doctor might do, grep for “Error”, but having some logs around to look at is a first step. . .

Yeah @tgxworld let’s make lograge the default?

你好,
在我们组织中,所有应用都使用 lograge/graylog,并且我们采用 JSON 格式器,因为它能更有序地帮助我们排查问题。

我们正在使用 Discourse 搭建一个论坛,它虽然提供了 lograge 选项,但默认使用的是 KeyValue 格式器,这会让我们的现有配置变得复杂。

我提交了一个 PR:adding a lograge formatter env var by dscataglini · Pull Request #12206 · discourse/discourse · GitHub PR 仍将默认格式器保留为当前的 KeyValue,但允许通过设置 LOGRAGE_FORMATTER 环境变量来自定义格式器。

1 个赞