Adjust page cache locking (#21240)
Ensure aral free happens after queue unlock
Stelios Fragkakis committed
Nov 4, 2025 at 16:34 UTC
7d0a5ac4f3f32fe8a7f2859ebf8787fdbf198877
1 file changed
+6
-2
src/database/engine/cache.c
+6
-2
@@ -715,6 +715,8 @@ static ALWAYS_INLINE void pgc_queue_del(PGC *cache __maybe_unused, struct pgc_qu
715
716
page_flag_clear(page, q->flags);
717
718
+ struct section_pages *sp_to_free = NULL;
719
+
720
if(q->linked_list_in_sections_judy) {
721
Pvoid_t *section_pages_pptr = JudyLGet(q->sections_judy, page->section, PJE0);
722
if(section_pages_pptr == NULL || section_pages_pptr == PJERR)
@@ -735,8 +737,7 @@ static ALWAYS_INLINE void pgc_queue_del(PGC *cache __maybe_unused, struct pgc_qu
737
if(!rc)
738
fatal("DBENGINE CACHE: cannot delete section from Judy LL");
739
738
- // freez(sp);
739
- aral_freez(pgc_sections_aral, sp);
740
+ sp_to_free = sp;
741
742
mem_delta -= sizeof(struct section_pages);
743
mem_delta += JudyAllocThreadPulseGetAndReset();
@@ -751,6 +752,9 @@ static ALWAYS_INLINE void pgc_queue_del(PGC *cache __maybe_unused, struct pgc_qu
752
753
if(!having_lock)
754
pgc_queue_unlock(cache, q);
755
+
756
+ if (sp_to_free)
757
+ aral_freez(pgc_sections_aral, sp_to_free);
758
}
759
760
static ALWAYS_INLINE void page_has_been_accessed(PGC *cache, PGC_PAGE *page) {