New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL: invalid connection #5532

Closed
alahoo opened this Issue Nov 28, 2018 · 13 comments

Comments

5 participants
@alahoo
Copy link

alahoo commented Nov 28, 2018

  • Gogs version (or commit ref): 0.11.66
  • Git version: ???
  • Operating system: CentOS release 6.10
  • Database (use [x]):
    • MySQL 5.7.24

Description

2018/11/28 15:11:40 [TRACE] Session ID: 2acc52f0e73672aa
2018/11/28 15:11:40 [TRACE] CSRF Token: q59XUUdmPuVH7OSGMV6lAqgOKUM6MTU0MzM4OTA4NTE1OTIyODI3MA==
2018/11/28 15:11:40 [TRACE] Template: user/auth/login
2018/11/28 15:16:07 [TRACE] Session ID: fd72a6c01adff7c9
2018/11/28 15:16:07 [TRACE] CSRF Token: h1boU_PqA9m3uv5jONOX8CU88HM6MTU0MzM4OTM2NzM3NTkxNTQzMw==
2018/11/28 15:16:07 [ERROR] [...g/context/context.go:179 ServerError()] GetUserByName: invalid connection
2018/11/28 15:16:07 [TRACE] Template: status/500
2018/11/28 15:16:48 [TRACE] Doing: MirrorUpdate
2018/11/28 15:26:48 [TRACE] Doing: MirrorUpdate
2018/11/28 15:26:48 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2018/11/28 15:36:07 [TRACE] Session ID: 7ccd468ce7cce310
2018/11/28 15:36:07 [TRACE] CSRF Token: m9GLG1aE5qX2dUw5lXB6P7hUBiY6MTU0MzM5MDU2NzM1MTUxOTEwMg==
2018/11/28 15:36:07 [TRACE] Session ID: f87526ffc25d40da
2018/11/28 15:36:07 [TRACE] CSRF Token: JQdAEMSPkzV8eVHUrdWRTtiJDsE6MTU0MzM5MDU2NzY3ODE2NzM2OQ==
2018/11/28 15:36:07 [TRACE] HTTPGit - Authenticated user: meng.guo
2018/11/28 15:36:48 [TRACE] Doing: MirrorUpdate
2018/11/28 15:46:48 [TRACE] Doing: MirrorUpdate
2018/11/28 15:46:48 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection

每隔一段时间,第一次推送或者更新或者打开web页面的时候,都会报一下500错误,日志如上。
前提环境是服务器做了gogs版本更新以及IP更换

@Unknwon Unknwon added the kind/bug label Nov 28, 2018

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Nov 28, 2018

Possible solution:

Add new config option to disable idle connection with db.SetMaxIdleConns(0).

@Unknwon Unknwon added this to the 0.12 milestone Nov 28, 2018

@Unknwon Unknwon changed the title invalid connection MySQL: invalid connection Nov 28, 2018

@afilippov1985

This comment has been minimized.

Copy link
Contributor

afilippov1985 commented Dec 20, 2018

I also have this error. Sometimes pushing into repository returns 500 error.
Versions 0.11.53, 0.11.66, 0.11.79 affected.
Verision 0.11.43 not affected.

2018/12/20 14:56:56 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2018/12/20 15:16:01 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection

@alahoo

This comment has been minimized.

Copy link
Author

alahoo commented Jan 18, 2019

2019/01/18 02:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 02:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 03:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 03:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 03:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 04:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 04:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 04:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 05:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 05:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 05:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 06:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 06:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 06:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 07:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 07:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 07:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 08:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 08:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 08:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 09:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 09:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 09:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 10:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 10:24:56 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/01/18 10:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 10:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 11:05:24 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/01/18 11:23:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 11:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 11:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 12:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 12:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 12:53:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 13:13:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 13:33:16 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/01/18 13:52:57 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection

@alahoo

This comment has been minimized.

Copy link
Author

alahoo commented Jan 18, 2019

最近越来越严重了,db.SetMaxIdleConns(0) 你说的这个设置,我也不知道去哪里修改。我已经升级到最新的0.11.79 @Unknwon

@dekyfin

This comment has been minimized.

Copy link

dekyfin commented Jan 31, 2019

In which file can i set db.SetMaxIdleConns(0)
@Unknwon

@MarcosBL

This comment has been minimized.

Copy link

MarcosBL commented Feb 5, 2019

Same thing here, Ubuntu 18.04, MySQL 5.7, nginx + Gogs Versión: 0.11.79.1211

2019/02/05 00:02:21 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection
2019/02/05 00:07:11 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/02/05 00:08:21 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection
2019/02/05 00:13:38 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:13:38 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:16:07 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:18:42 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection
2019/02/05 00:18:48 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:23:58 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:27:11 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/02/05 00:34:03 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection
2019/02/05 00:37:11 [ERROR] [...ogs/models/mirror.go:356 MirrorUpdate()] MirrorUpdate: invalid connection
2019/02/05 00:44:18 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:46:49 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:49:24 [ERROR] [...g/context/context.go:191 ServerError()] ActivatedLoginSources: find activated login sources: invalid connection
2019/02/05 00:49:28 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:52:46 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:54:38 [ERROR] [...g/context/context.go:191 ServerError()] GetUserByName: invalid connection
2019/02/05 00:56:14 [ERROR] [...ogs/pkg/auth/auth.go:74 SignedInID()] GetUserByID: invalid connection
@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 6, 2019

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 6, 2019

Patch has pushed to fix this issue, please test on develop branch.

@MarcosBL

This comment has been minimized.

Copy link

MarcosBL commented Feb 8, 2019

Seems to be working fine in the demo website; don't have the abilities to compile the develop branch, but I can test it if someone could provide a amd-64 gogs executable binary

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 8, 2019

@MarcosBL here you go (no tags included)

gogs_linux_amd64_16f95123.zip

@MarcosBL

This comment has been minimized.

Copy link

MarcosBL commented Feb 11, 2019

Thank you very much ! Just updated and restarted, will update with logs info later:

2019/02/11 10:05:44 [ INFO] MarcosBL Git 0.11.87.0206
2019/02/11 10:05:44 [ INFO] Cache Service Enabled
2019/02/11 10:05:44 [ INFO] Session Service Enabled
2019/02/11 10:05:44 [ INFO] Mail Service Enabled
2019/02/11 10:05:44 [ INFO] Notify Mail Service Enabled
2019/02/11 10:05:44 [ INFO] Git Version: 2.17.1
2019/02/11 10:05:44 [ INFO] Run Mode: Production
2019/02/11 10:05:45 [ INFO] Listen: http://0.0.0.0:3000
@MarcosBL

This comment has been minimized.

Copy link

MarcosBL commented Feb 11, 2019

Not a single error in a couple of hours, around 20 commits 👍

@MarcosBL

This comment has been minimized.

Copy link

MarcosBL commented Feb 12, 2019

After a whole day of usage, I can confirm it's working flawlessly

@Unknwon Unknwon closed this Feb 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment