Rethink create and attach APIs of shared TidStore.
authorMasahiko Sawada <[email protected]>
Thu, 28 Mar 2024 01:03:28 +0000 (10:03 +0900)
committerMasahiko Sawada <[email protected]>
Thu, 28 Mar 2024 01:03:28 +0000 (10:03 +0900)
commit2d8f56dabbfd2f85da9a4e0fe4a4b4d6654864f1
treedb71b4598643fe3c16fd614a3ba11ef89595f6ec
parentd1cf5319e9ae16435e5ca416c06c2290bfca000e
Rethink create and attach APIs of shared TidStore.

Previously, the behavior of TidStoreCreate() was inconsistent between
local and shared TidStore instances in terms of memory limitation. For
local TidStore, a memory context was created with initial and maximum
memory block sizes, as well as a minimum memory context size, based on
the specified max_bytes values. However, for shared TidStore, the
provided DSA area was used for TID storage. Although commit bb952c8c8b
allowed specifying the initial and maximum DSA segment sizes, callers
would have needed to clamp their own limits, which was not consistent
and user-friendly.

With this commit, when creating a shared TidStore, a dedicated DSA
area is created for TID storage instead of using a provided DSA
area. The initial and maximum DSA segment sizes are chosen based on
the specified max_bytes. Other processes can attach to the shared
TidStore using the handle of the created DSA returned by the new
TidStoreGetDSA() function and the DSA pointer returned by
TidStoreGetHandle(). The created DSA has the same lifetime as the
shared TidStore and is deleted when all processes detach from it.

To improve clarity, the TidStoreCreate() function has been divided
into two separate functions: TidStoreCreateLocal() and
TidStoreCreateShared().

Reviewed-by: John Naylor
Discussion: https://postgr.es/m/CAD21AoAyc1j%3DBCdUqZfk6qbdjZ68UgRx1Gkpk0oah4K7S0Ri9g%40mail.gmail.com
src/backend/access/common/tidstore.c
src/include/access/tidstore.h
src/test/modules/test_tidstore/test_tidstore.c