Episode importing is failing and Sonarr auto restarts

Sonarr version: 4.0.5.1710
Package Version:4.0.5.1710-ls241 by linuxserver.io
OS: on Kubernetes

Description of issue:
I’m experiencing an unexplained behaviour
The new episode is downloaded successfully but file importing in the storage folder is failing. Sonarr imports only 300-400Mb from 1Gb file and auto-restarts without any error message. In next import attempts it says “Destination already exists.” and restarts again or deletes the partial file and tries again… a chain of failures.

The import process is failing in Sonarr and Radarr, Both app containers were upgraded to the latest version. Kubernetes was upgraded to v1.30*. Everything was working fine a month ago or so…

And I’m wondering where the issue is:

  • in the infrastructure: NAS drives, kubernetes, kubernetes workers or permissions?
  • in Sonarr configuration?

Do you have any ideas why the episode file is imported partially and the container restarts automatically?
How can I get the actual error message?
When I copy the file manually and scan the series, everything works as expected.
The Info, debug and trace logs are normal. As I can see the Sonarr restarts at 05:18:11. Please check part of the logs below:

Info log:

2024-06-12 05:14:53.2|Info|RssSyncService|Starting RSS Sync
2024-06-12 05:14:56.0|Info|DownloadDecisionMaker|Processing 20 releases
2024-06-12 05:14:56.4|Info|DownloadService|Report sent to {my Torrent}. Indexer {my indexer}. {file name}
2024-06-12 05:14:58.0|Info|RssSyncService|RSS Sync Completed. Reports found: 20, Reports grabbed: 1
2024-06-12 05:18:11.8|Info|Bootstrap|Starting Sonarr - /app/sonarr/bin/Sonarr - Version 4.0.5.1710
2024-06-12 05:18:12.1|Info|AppFolderInfo|Data directory is being overridden to [/config]
2024-06-12 05:18:13.7|Info|MigrationController|*** Migrating data source=/config/sonarr.db;cache size=-20000;datetimekind=Utc;journal mode=Wal;pooling=True;version=3;busytimeout=100 ***

Debug log:

2024-06-12 05:17:56.6|Debug|ImportDecisionMaker|File accepted
2024-06-12 05:17:56.7|Debug|EpisodeFileMovingService|Copying episode file: /data/{file name} to /films/Series/{file name}
2024-06-12 05:17:56.7|Debug|DiskTransferService|Copy [/data/{file name}] > [/films/Series/(file name)]
2024-06-12 05:18:13.7|Debug|ProcessProvider|Found 0 processes with the name: Sonarr.Console
2024-06-12 05:18:13.7|Debug|ProcessProvider|Found 1 processes with the name: Sonarr
2024-06-12 05:18:13.7|Debug|ProcessProvider| - [145] Sonarr
2024-06-12 05:18:13.7|Info|MigrationController|*** Migrating data source=/config/sonarr.db;cache size=-20000;datetimekind=Utc;journal mode=Wal;pooling=True;version=3;busytimeout=100 ***

I found the issue:
Kubernetes restarts Sonarr because it exceeds allowed memory aka ‘OOMKilled’ (Out of Memory). The container was limited to 500Mb RAM and it worked fine several years, but after the latest Kubernetes and Sonarr updates, it consumes ~1Gb of RAM during the file inserting, 3-4 times larger the idle memory consumption.
The Developers could check if this is normal or there is a memory leak…