3 ms·
The proper way to handle OOM is to do what mature databases do: implement your own memory accounting, use only your own allocators integrated with the accountin
by senderista 4mo ago
The proper way to handle OOM is to do what mature databases do: implement your own memory accounting, use only your own allocators integrated with the accounting system, and ensure that every allocation path can recover from OOM. Easier said than done.
- man8alexd 4mo agoMariaDB recently implemented memory PSI monitoring but failed with that in a curious way and disabled it afterwards by default. The failure is that under memory pressure, they flushed the entire InnoDB buffer pool.
- zbentley 4mo agoThe issue is that there’s no generally correct behavior. Should a database under memory pressure stay up at all costs even if it becomes unusably slow (by e.g. nuking 99% of the buffer cache)? Or should it crash/failover hard with a likelihood of potential recovery afterwards, even if it technically could have stayed up? Something in between? There’s no correct-in-general answers to those questions. This is a hard problem due to context dependence; that’s why there are so many knobs.
- man8alexd 4mo agoIn this specific case, the correct behaviour would be to drop a part of the buffer pool until the memory pressure is gone. The context-dependent question is how much and how fast to drop. The current implementation drops to a single configurable level but I suspect it could have implemented better heuristics.