lsa: Fix segment leak on memory reclamation during alloc_buf
lsa: Fix segment leak on memory reclamation during alloc_buf

alloc_buf() calls new_buf_active() when there is no active segment to
allocate a new active segment. new_buf_active() allocates memory
(e.g. a new segment) so may cause memory reclamation, which may cause
segment compaction, which may call alloc_buf() and re-enter
new_buf_active(). The first call to new_buf_active() would then
override _buf_active and cause the segment allocated during segment
compaction to be leaked.

This then causes abort when objects from the leaked segment are freed
because the segment is expected to be present in _closed_segments, but
isn't. boost::intrusive::list::erase() will fail on assertion that the
object being erased is linked.

Introduced in b5ca0eb2a2f30b1f2d4f0be6d3c5ab8e33db33aa.

Fixes #9821
Fixes #9192
Fixes #9825
Fixes #9544
Fixes #9508
Refs #9573

Message-Id: <469cd3fea11491742943ebde833ef70c833cba89@scylladb.com>

scylladb/scylla,scylladb/scylla,scylladb/scylla,scylladb/scylla