Skip to content
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

Large action table may cause 500 error for home page #18666

Closed
wxiaoguang opened this issue Feb 8, 2022 · 6 comments
Closed

Large action table may cause 500 error for home page #18666

wxiaoguang opened this issue Feb 8, 2022 · 6 comments

Comments

@wxiaoguang
Copy link
Contributor

2022/02/08 11:26:51 .../web/feed/profile.go:22:RetrieveFeeds() [E] GetFeeds: Find: Error 1038: Out of sort memory, consider increasing server sort buffer size
2022/02/08 11:26:51 router: completed GET / for 106.38.223.242:0, 500 Internal Server Error in 87.5ms @ web/home.go:26(web.Home)

And related to:

@lunny
Copy link
Member

lunny commented Feb 8, 2022

I think we have two choices:

  1. Split action table according years. i.e. action will contains this year, action-2021 will contain last year actions.
  2. Create an action_stats table to save history(over 1 year) actions as statistics information and delete real actions from action table.

@lafriks
Copy link
Member

lafriks commented Feb 8, 2022

For postgresql, mssql and mysql we could use partitioned tables this would still allow to select data from action table as we do right now and when date provided it would select only from partitions needed. I usually create also an background task that checks periodically if date is close enough and creates new partition for future records. This way we could easily create also table partitioned not only by year but also for month if needed.

PostgreSQL: https://www.postgresql.org/docs/14/ddl-partitioning.html
MySQL: https://dev.mysql.com/doc/refman/5.7/en/partitioning-management.html
MSSQL: https://docs.microsoft.com/en-us/sql/relational-databases/partitions/create-partitioned-tables-and-indexes?view=sql-server-ver15

As for sqlite we could probably create multiple tables and have view with union select of tables for last year

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Feb 8, 2022

I have enough DBA knowledge and I know how action table works, so I can handle this problem easily (actually, I just deleted most data in my table).

However, some users do not know how to handle it, like

So the question is:

  • should we document about this problem and tell users how to handle it
  • or should we delete old data periodically.

And I do not think Gitea should touch the partitioning mechanism by itself, we should keep things as simple as possible.

@lafriks
Copy link
Member

lafriks commented Feb 8, 2022

I agree that partitioning can be done transparently to gitea. Like creating partitioned table manually, moving data from unpartitioned table and than adding crontab job to create partitions

@lafriks
Copy link
Member

lafriks commented Feb 8, 2022

But documentation for this could be nice to have

@wxiaoguang
Copy link
Contributor Author

The indices have been re-designed. Close this one.

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants