From d66b07823baf8b60486dc04b36ba9d7c0e3452d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Tue, 25 Jul 2023 09:42:45 -0400 Subject: [PATCH] db/view/view_updating_consumer: account for the size of mutations All partitions will have a corresponding mutation object in the buffer. These objects have non-negligible sizes, yet the consumer did not bump the _buffer_size when a new partition was consumer. This resulted in empty partitions not moving the _buffer_size at all, and thus they could accumulate without bounds in the buffer, never triggering a flush just by themselves. We have recently seen this causing OOM. This patch fixes that by bumping the _buffer_size with the size of the freshly created mutation object. --- db/view/view_updating_consumer.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/view/view_updating_consumer.hh b/db/view/view_updating_consumer.hh index 6070846920..dd6954cddb 100644 --- a/db/view/view_updating_consumer.hh +++ b/db/view/view_updating_consumer.hh @@ -83,7 +83,11 @@ public: void consume_new_partition(const dht::decorated_key& dk) { _mut_builder.emplace(_schema); - _mut_builder->consume_new_partition(dk); + // Further accounting is inaccurate as we base it on the consumed + // mutation-fragments, not on their final form in the mutation. + // This is good enough, as long as the difference is small and mostly + // constant (per fragment). + _buffer_size += _mut_builder->consume_new_partition(dk).memory_usage(*_schema); } void consume(tombstone t) {