Skip to content

Multiple db connections opened for sqlite #422

Closed
@nonvis

Description

@nonvis

Describe the bug
sqlite only supports max_open_conn=1, but there are several instances where multiple db connections are opened.

To Reproduce
Steps to reproduce the behavior:

  1. Open any questions page and up/down vote a comment
  2. Now the website should be very unresponsive as there are processes in blocked state

Expected behavior
Pressing up/down vote buttons should not slow down the website.

Platform (please complete the following information):

  • Device: Desktop
  • OS: macOS
  • Browser: chrome
  • Version: 1.1.0

Source code analysis
vote_repo.go (line 78)

  • session.Context(ctx) is called -> new db connection
  • then, at line 90, vr.CheckRank() is called which eventually calls configService.GetConfigByKey, creating another db connection

There are several other instances of this behavior.
I think GetConfigByKey(ctx context.Context, key string)
should take session *Session, not ctx context.Context
Or we could have values from config table, loaded into cache on startup, so that config values could be read from cache all the time.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions