magefree / magefree/mage

Server: add auto-restart on memory problems (database error, card not found, etc)

Open
#8,130 1 comment 0 reactions 0 assignees View on GitHub
enhancement server
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

Current problem: server can gets a freeze games, memory leaks (#4520), etc. So it requires a restart after some time (card not found error is most popular, also AI can stops to work).

Steps to reproduce from #8065:
* run local server under 500Mb settings;
* cast [[Brain Pry]];
* you will catch database error, search code by `catch (SQLException ex)`

Another possible reason is memory leaks, search code by `Tried to restart the DB`

Another one: OutOfMemoryError -- search code by `GameWorker general error`:
```
FATAL 2021-08-17 23:23:13,385 GameWorker general error [28836ada-fe1f-42ca-a412-4d0a007662e0] java.lang.OutOfMemoryError: Java heap space =>[GAME 28836ada-fe1f-42ca-a412-4d0a007662e0] GameWorker.call
java.lang.OutOfMemoryError: Java heap space
```

TODO:
* [ ] Both database errors must follow to server restart;
* [ ] Restart procedure must be defined in server's config as additional param like `restartCommand` with operation system commands;
* [ ] Must support app restart commands for windows, linux, docker host, docker guest (it can be direct commands to restart or workaround as txt file creation in the folder for third party service). Add commands examples in config;
* [ ] Inform all users about restart (see Mage.Console for example). Can be related to #5353
* [ ] Inform admin by email;
* [ ] Restart by timeout like 30 seconds;
* [ ] Only one attempt to restart (ignore db errors after execute).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the `catch (SQLException ex)` paths, the `Tried to restart the DB` message, and the `GameWorker general error` entry point. Review `Mage.Console` for user notification behavior and inspect the server configuration. Done means the listed database and memory failure cases have a defined, single-attempt restart flow with configurable examples, timeout handling, and user/admin notifications.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
backend, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.