Re: Parallel bitmap heap scan
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>, Haribabu Kommi <kommi.haribabu@gmail.com>,
Rafia Sabih <rafia.sabih@enterprisedb.com>, tushar <tushar.ahuja@enterprisedb.com>,
Amit Khandekar <amitdkhan.pg@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-03-07T16:11:19Z
Lists: pgsql-hackers
(On Tue, Feb 28, 2017 at 10:48 AM, Dilip Kumar <dilipbalaut@gmail.com> wrote:
> 0001- same as previous with some changes for freeing the shared memory stuff.
+ if (--ptbase->refcount == 0)
+ dsa_free(dsa, istate->pagetable);
+
+ if (istate->spages)
+ {
+ ptpages = dsa_get_address(dsa, istate->spages);
+ if (--ptpages->refcount == 0)
+ dsa_free(dsa, istate->spages);
+ }
+ if (istate->schunks)
+ {
+ ptchunks = dsa_get_address(dsa, istate->schunks);
+ if (--ptchunks->refcount == 0)
+ dsa_free(dsa, istate->schunks);
+ }
This doesn't involve any locking, which I think will happen to work
with the current usage pattern but doesn't seem very robust in
general. I think you either need the refcounts to be protected by a
spinlock, or maybe better, use pg_atomic_uint32 for them. You want
something like if (pg_atomic_sub_fetch_u32(&refcount, 1) == 0) {
dsa_free(...) }
Otherwise, there's no guarantee it will get freed exactly once.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Commits
-
Pass DSA_ALLOC_HUGE when allocating a shared TIDBitmap.
- a171f01501e1 10.0 landed
-
Support parallel bitmap heap scans.
- f35742ccb7aa 10.0 landed
-
tidbitmap: Support shared iteration.
- 98e6e89040a0 10.0 landed
-
Shut down Gather's children before shutting down Gather itself.
- acf555bc53ac 10.0 landed
-
Revise the way the element allocator for a simplehash is specified.
- c3c4f6e1740b 10.0 cited
-
Refactor bitmap heap scan estimation of heap pages fetched.
- da08a6598973 10.0 landed
-
Use more efficient hashtable for tidbitmap.c to speed up bitmap scans.
- 75ae538bc316 10.0 cited