Skip to content

Fix: too many open files crash#9

Merged
dzdidi merged 1 commit intomainfrom
fix/too-many-open-files
Apr 9, 2026
Merged

Fix: too many open files crash#9
dzdidi merged 1 commit intomainfrom
fix/too-many-open-files

Conversation

@dzdidi
Copy link
Copy Markdown
Collaborator

@dzdidi dzdidi commented Apr 9, 2026

Scorer crashed with too many files opened . This PR's goal is to fix it:

  • The log file is opened once
  • Daily rotatio
  • Per-message flush

listener.accept().await.unwrap() replaced with a match that prints the error and continues.
A transient fd-limit spike or network hiccup no longer permanently kills the listener.

The log file is opened once at startup and held as a Mutex<BufWriter<File>> — one fd, forever.

Daily rotation: each log() call checks Utc::now().date_naive() against the stored date. On date change, it opens a new logs-YYYY-MM-DD.txt file. If the new file can't be opened, it continues writing to the old one rather than crashing.

Per-message flush: flush() is called after every write_all(), so no log message is lost in the buffer on crash.
Zero panics: every fallible operation uses let _ = or if let Ok(...) — a poisoned mutex falls back to eprintln!, a failed write is silently dropped. A logger must never take down the node.

listener.accept().await.unwrap() replaced with a match that prints the error and continues. A transient fd-limit spike or network hiccup no longer permanently kills the listener.

Signed-off-by: dzdidi <dzdidi@protonmail.com>
@dzdidi dzdidi requested a review from ovitrif April 9, 2026 07:43
Copy link
Copy Markdown

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck

@dzdidi dzdidi merged commit b8ee76d into main Apr 9, 2026
@dzdidi dzdidi deleted the fix/too-many-open-files branch April 9, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants