| From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
|---|---|
| To: | koshino(at)sraoss(dot)co(dot)jp |
| Cc: | pgpool-hackers(at)lists(dot)postgresql(dot)org, emond(dot)papegaaij(at)gmail(dot)com |
| Subject: | Re: Delimit query-cache key to prevent collisions |
| Date: | 2026-08-17 06:24:32 |
| Message-ID: | 20260817.152432.359325906484097959.ishii@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-hackers |
>> I have reviewed the patch(009-encode-key-delimiter) from Emond.
>> It has also passed all regression tests.
>>
>> encode_key() constructs the cache key using md5(user || query || database) without delimiters.
>> This allows different sessions to produce identical keys
>> (e.g., "admin" + "Q" + "testdb" and "adm" + "Q" + "intestdb"),
>> leading to data leakage between users/databases.
>>
>> Changes:
>> Explicit Delimiters: Insert NUL bytes between the user, query, and database fields in the buffer.
>> Hash Full Range: Updated the hash function to process the entire byte range (including NUL separators)
>> instead of stopping at the first NUL byte.
>>
>> Thank you, Emond.
>
> I have looked into this. The patch looks good to me. Also I ran some
> of query cache related regression tests on master branch.
>
> testing 006.memqcache...ok.
> testing 007.memqcache-memcached...ok.
> testing 008.dbredirect...ok.
> testing 120.memory_leak_extended_memqcache...ok.
> testing 124.bug700_memqcache_segfault...ok.
>
> They all passed here.
Small point. Pgindent dislikes following (comment line is too long).
*** /tmp/pool_memqcache.c 2026-08-17 15:20:30.384621930 +0900
--- src/query_cache/pool_memqcache.c 2026-08-17 15:20:30.458960398 +0900
***************
*** 600,606 ****
p += d_length;
*p = '\0';
! /* Hash the full delimited buffer (length - 1 so the final NUL is excluded). */
pool_md5_hash(strkey, length - 1, buf);
ereport(DEBUG1,
(errmsg("memcache encode key"),
--- 600,609 ----
p += d_length;
*p = '\0';
! /*
! * Hash the full delimited buffer (length - 1 so the final NUL is
! * excluded).
! */
pool_md5_hash(strkey, length - 1, buf);
ereport(DEBUG1,
(errmsg("memcache encode key"),
***************
Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-08-17 06:27:37 | Re: Convert close_idle_connection (SIGUSR1) to flag-only handler with main-loop processing. |
| Previous Message | Tatsuo Ishii | 2026-08-17 06:18:07 | Re: Fix unsigned underflow in inject_cached_message |