Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wA9my-00278l-0d for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 17:00:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wA9mw-001eOr-1e for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 17:00:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wA9mw-001eOj-0h for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 17:00:30 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wA9mu-000000014Ho-1g35 for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 17:00:29 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-66f74fa69ceso1089846a12.2 for ; Tue, 07 Apr 2026 10:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775581226; cv=none; d=google.com; s=arc-20240605; b=ThYLvN7+PS0MoFoOa+hNh5dvQoJAF5i7EyiW8dcTy8GJieaUDNkQtLNwMlx8p1Qyvt 2RIyMnHz6FWLBeL59nzTIfgmsOGBbEf1+6EGTC2AYNwbMAliW7VsaUUDsCMpfbK4kTAy usWZfdNuk+OH/UZGIEwy4b+iwTuE6CAXGLYWkC4e99GmRy+5UK362+2Is3C458sUaD3u Bov7Bq6AsDDBrJXNM4U4HES3CVEUJo9VB0YsKpB6KzGiw/lCoSBMqhPddEEjR1z5GbGO 0kxWcETOKVrS127VrJbVelspvzSYOCZXDHeBuiDsu+zDJhVbgpiyUnXBtqtno8iLVCfy I7Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=qMoYMqAppOY/sZ9kQuPhtugbxvMs6ZonNf2N//gGDPw=; fh=/xiGNfEAfipYW6lpUhnBIWT0qNLbutiWV5uYU3kRGJM=; b=Ws6f8Irge/NIvf2Vm8p1BsD0053ij+Ug0BINqG5pm4fjzmwBeVFqsngLQVijpjaeO5 cfLdJG7iIcQyHmvQsHPine9qlojhKfFQC3h2psCu3DdBqW+Bz1Pq3O4QkDMbQmoiwFOA aAD7YCOuZgBLs9Y6QGRPIZwm/ws9q45sdCDW1c+BzTzzR7RDNmsps5iA2FSJ/QP8fb9w v/eLwYdbVeeQPSeGxEqrX3fbk1WIaPNdXqK07/TWEZnVT8MbFnSK0iWAjrcAzdY79WYB MXArlNkLAFZ3rocK+Fmng1q1U72Sz0RwVV0N1jBOloEdKdLnV9ZLX+ygP1VxA2pz71wu T/og==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775581226; x=1776186026; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qMoYMqAppOY/sZ9kQuPhtugbxvMs6ZonNf2N//gGDPw=; b=NUyxn1S7QF7a1XF28SlQbvCm3Cx5XCuGFZzvvuF0kuSiLefO3zHXngNINexE07T7tK H8d9g7SYOyF9NKb7ss0HlYN3KCGJmYRGojmpuETkspGqzvTf2YV8KVOuX+3flAp4MV3z AdAHwKmonQHJdM+aX7bi46fEMOeoQhTc0yasfVfNrZrePxdq63RFt0hpED+Bq1HpiWEN NIH8udtlRhcyagjCzEkRzsIO2d8XPjnZRtRwC6sXDbI8fVXoyK499HX7EoxTtH21GdLt txlkdPGL89XrDBPcSpCy1r5mwbV1Nw5rTih0FzEHuQ0eTwv02Ukeh2DP2M58zNVZA4jV lcag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775581226; x=1776186026; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qMoYMqAppOY/sZ9kQuPhtugbxvMs6ZonNf2N//gGDPw=; b=CTIZWdR0HF545YXDWdtZ6UpmU861yuJ2pZbWSI6J4Ds3IJ3Fxu20FcqS6zXLyOmOeL kDnBX4mhkXISqW0UVWEReiw9f3X3nWDfQ2ODHMYeqemRS1PCp9wd9DZfAwRdP5TQztB3 HbHuP1SzKOx6ZCLpVkojaQ1a2GWPBsB8MSSJFIpuP2BdHyzBAgRs608HGJtd2XER3U9/ eBwroyUr3rqbakrfGmA7VlZ/D3FZ1ZNTD35BOd5eD6g5YXvPxwTDMCBs6kH7u1hq+pJF TDTnjhYpPOYl9yGYE6+XMNMBO5Uxh7RpZlRK0LBikss6vxOwMuppFey5WJ4PAjeyxmbG 4SyA== X-Forwarded-Encrypted: i=1; AJvYcCVhCUlX7U5nvaXDtEH9yMuzogYmiKiFOdIkBJ2R4TxkzK3ywJFP2MytXd8kpFqSrToGMm1z1qFNrirS0F5q@lists.postgresql.org X-Gm-Message-State: AOJu0YyPDos97WoL1GSsqOm7M/49e0mLmOjkZUpgVkr9zLcBC35Ehn0W INEvWLBYyakINo4ZHu/nyiouDEEcTbk1kjr7gFnkzzd/drP0dJlDRqbTEcoUbM9M8JM+tACS961 f0egmOF3I9p4R6AH2VvgVVEPAMaLtwDY= X-Gm-Gg: AeBDieuiwwNYcq1tCtyg9dB0e5xWtwpjMV8LRYgIvaGVZX4480W4j0cKf9/96rhRKJ1 XBbnrjY8cxNLsV9bEMPqFSEeoBMZwwKqTwCqOl4KZt1BaZMMtwih5y/eHZSh8BEo7b1gumEY8IU GTsmjvR9pITEB5D5Ya+AViQ6i03FRCTFSfiQZOhQNee8a/2OLU9oA43uNIIsmy8daawARBkkp9y sBDMH70zsDIKeE95ZaEeACHUN27fwAz+l5mhJgTqEnl3dsuwq1neWyATrMOGe9MNsKLU10QNNC7 VtqsZA== X-Received: by 2002:a05:6402:3492:b0:66e:43a4:448e with SMTP id 4fb4d7f45d1cf-66e43a444f6mr8974716a12.17.1775581225997; Tue, 07 Apr 2026 10:00:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Tue, 7 Apr 2026 12:00:14 -0500 X-Gm-Features: AQROBzDVzZ8eXV2XFCo07Ar4eeylY-BL6A9po4edo-VbebzdCyy3VcA3zuCcUos Message-ID: Subject: Re: dshash_find_or_insert vs. OOM To: Michael Paquier Cc: Andres Freund , Robert Haas , PostgreSQL Hackers , Thomas Munro Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Thu, Mar 26, 2026 at 04:26:33PM -0400, Andres Freund wrote: > > I think tests like this do have value and I'd definitely run them first while > > hacking on code related to dshash, rather than relying on the regression tests > > or such. E.g. having test_aio was invaluable to being able to get AIO into a > > stable state. When hacking on something with complicated edge cases I'd just > > add a test for it, making development faster as well as ensuring the > > complicated case continues to work into the future. > > These test modules have a lot of value because they are cheap to run > and are very usually able to reproduce edge cases that no other place > of the code tree would be able to reach in a predictible way. Cheap, > fast and reliable is good. On top of that they can serve as code > template. Bonus points. > > > However, creating its own test module for small parts of the codebase doesn't > > quite make sense to me. A pretty decent chunk of the test is just boilerplate > > to add a new module, and every new test module requires its own cluster, which > > adds a fair bit of runtime overhead, particularly on windows. I think > > test_dsa, test_dsm_registry, test_dshash should just be one combined test > > module, they're testing quite closely related code. > > Yeah, perhaps grouping all the DSA things into a single module would > be OK, with a parallel schedule that would speed up things. It > depends on the complexity and the size of the module to me. > > Saying that, I think that the shape of the proposed test_dshash is > wrong: it proposes one SQL function that does a bunch of > dshash-related operations in a single function call, in a random > manner. We have a shared memory state that can survive across SQL > calls, making it a set of thinner SQL function that wrap directly > dshash calls able to manipulate the table would feel much more natural > to me. And it would be easier to design edge cases in the SQL > scripts themselves. My apologies for the late response here. I spent some time looking at this yesterday and came to the conclusion that we can add dshash tests to test_dsm_registry, which already allocates a dshash via GetNamedDSHash(). However, I also realized that the API has a gap: callers cannot set a size limit on the dshash. I need this for the test, but more importantly it's a limitation of the API itself. So I plan to target v20 for the tests, as it's likely too late for v19. To start, I've submitted a patch for allowing callers to set a size limit on a GetNamedDSHash()-allocated dshash [1]. [1] https://commitfest.postgresql.org/patch/6655/ -- Sami