Unit tests for SLRU

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Unit tests for SLRU
Date: 2022-03-31 14:30:41
Message-ID: CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

I learned from Peter [1] that SLRU test coverage leaves much to be
desired and makes it difficult to refactor it. Here is a draft of a
patch that tries to address it.

I used src/test/modules/test_* modules as an example. While on it, I
moved the Asserts() outside of SimpleLruInit(). It didn't seem to be a
right place to check the IsUnderPostmaster value, and complicated the
test implementation. I also renamed SlruSyncFileTag() to
SlruSyncSegment() and changed its signature. I think it makes the
interface easier to reason about.

I noticed that SLRU uses int's for slotno, while FileTag->slotno is
uint32. Can't this cause us any grief? Finally, I believe
SimpleLruWritePage() name is confusing, because in fact it works with
a slot, not a page. But I didn't change the name in my patch, yet.

If time permits, please take a quick look at the patch and let me know
if I'm moving the right direction. There will be more tests in the
final version, but I would appreciate an early feedback.

[1]: https://postgr.es/m/220fab30-dff0-b055-f803-4338219f1021%40enterprisedb.com

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v1-0001-Unit-tests-for-SLRU.patch application/octet-stream 17.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-03-31 14:31:32 Re: Commitfest Update
Previous Message Robert Haas 2022-03-31 14:28:45 Re: Correct docs re: rewriting indexes when table rewrite is skipped