All articles

Investigating a Production Outage and Moving Telegram Bots to a Second Host

Personal projectsRead in Chinese

Starting with a resource review

The Tasuki Keifu site, its agent, and several Telegram services initially shared one 2 GB Lightsail host. A resource review looked beyond disk usage: although disk had room, historical kernel logs showed a global OOM event that killed the site's Next.js process. Short samples also showed periods of sharply reduced available memory.

That did not establish that a particular bot or deployment caused the event. The services shared a host, database, and deployment windows, and current container health could not reconstruct the earlier causal chain.

A startup change with a narrow validation path

The site container started through pnpm start, keeping an extra pnpm/Node wrapper process alive. We tested the direct Next.js entry point with the same image in isolation: it started, served a request, and exited on SIGTERM. We then changed only the site's Compose command, leaving the image and database untouched.

After deployment, the site used one resident process instead of two. Short cgroup samples showed lower memory use, but a container restart also changes caches and workload. The difference cannot all be treated as a stable saving, and it does not prove the OOM problem was solved.

Preserving causal boundaries after an outage

The host later became unreachable from the public network. Cloud system checks and CPU metrics looked normal, while SSH and website requests timed out. Services recovered after an authorized reboot. Pre-reboot logs showed a DHCPv6 timeout followed by the primary network interface entering a failed state; an earlier global OOM was also confirmed. The timing is close, but the evidence does not prove that the OOM caused the network failure. DHCP lease renewal remains a hypothesis to test, not a confirmed root cause.

The review also found a separate, confirmed issue: an automated deployment ran a global image prune and deleted the old site image intended for rollback. There is no evidence that this caused the outage, but it weakened recovery options. Future cleanup needs to be scoped to a project and its release records, while retaining the current and previous accepted versions.

Moving the bots away from a shared failure domain

Further observation found an in-limit OOM in the Job Alerts container, while the site's working set was also growing. Instead of imposing hard limits everywhere without enough evidence, we moved two Telegram bots, their separate databases, and a scheduled channel task to a new 2 GB host. The site, agent, and original shared database stayed on the old host.

The migration focused on avoiding split state and duplicate sends. After writes stopped, we backed up each of the three databases, restored them on the new host, and compared row counts, sorted content digests, and sequence values. We also checked deletion logs and the channel publishing ledger. After cutover, we verified bot readiness, Telegram webhooks, the channel timer, and automated deployments. The deployment process exposed one configuration omission: the Job Alerts migration environment lacked existing settings, so its first deployment stopped at the database identity check. We added the settings and reran it successfully; the failed attempt had not replaced the running container.

Results and remaining work

Both bots and the channel task now run on the new host. Database comparisons matched, webhooks point to the new host, and both GitHub Actions deployments succeeded. The move reduced service density on the old host and gave the bots separate databases and resource budgets.

This is not a complete reliability postmortem. The root cause of the DHCP/network failure is still unresolved; the new Job Alerts memory limit needs observation through real workload cycles; off-host channel backups, site growth, and stronger image-retention rules still need follow-up. A passing health check only validates the path it exercised at that moment.

What we learned

The most useful engineering step was not “cleaning up more resources”; it was separating evidence from hypotheses, then choosing changes that could be checked and rolled back independently. Outage investigations need pre-reboot logs, deployments need to protect rollback artifacts, and migrations need to validate persistent state rather than only process startup.

The full local investigation and operational record stays in the workbench and is not part of this public account.

Investigating a Production Outage and Moving Telegram Bots to a Second Host | Xuhuan / Gelatoni