diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 2da24d53f9..db19475335 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -632,6 +632,7 @@ lfc_prewarm(FileCacheStateEntry* fs, size_t n_entries) /* Do not prewarm more entries than LFC limit */ if (lfc_ctl->limit <= lfc_ctl->size) { + elog(LOG, "LFC: skip prewarm because LFC limit is smaller than prewarm size"); LWLockRelease(lfc_lock); return; } @@ -641,12 +642,19 @@ lfc_prewarm(FileCacheStateEntry* fs, size_t n_entries) n_entries = lfc_ctl->limit - lfc_ctl->size; } - LWLockRelease(lfc_lock); - + if (lfc_ctl->prewarm_total_chunks != lfc_ctl->prewarm_curr_chunk) + { + elog(LOG, "LFC: skip prewarm because concurrent prewarm is detected"); + LWLockRelease(lfc_lock); + return; + } /* Initialize fields used to track prewarming progress */ lfc_ctl->prewarm_total_chunks = n_entries; lfc_ctl->prewarm_curr_chunk = 0; + LWLockRelease(lfc_lock); + + ring = (PrewarmRequest*)palloc(sizeof(PrewarmRequest)*ring_size); elog(LOG, "LFC: start loading %ld chunks", (long)n_entries); diff --git a/pgxn/neon/pagestore_client.h b/pgxn/neon/pagestore_client.h index 858dd8b85f..8c25958e5b 100644 --- a/pgxn/neon/pagestore_client.h +++ b/pgxn/neon/pagestore_client.h @@ -186,6 +186,7 @@ typedef struct { /* * Send this request to the PageServer associated with this shard. + * This function assigns request_id to the request which can be extracted by caller from request struct. */ bool (*send) (shardno_t shard_no, NeonRequest * request); /*