Re: BUG #19382: Server crash at __nss_database_lookup - Mailing list pgsql-bugs

From surya poondla
Subject Re: BUG #19382: Server crash at __nss_database_lookup
Date
Msg-id CAOVWO5pjSeYh1UOGaROXr51GhAf9QsLXJeqp__-D4BtHs5oESA@mail.gmail.com
Whole thread
In response to Re: BUG #19382: Server crash at __nss_database_lookup  (surya poondla <suryapoondla4@gmail.com>)
List pgsql-bugs
Hi Zsolt,

Thanks for the testing, both issues you reported were real; v10 (attached) fixes them.

Case 1 (plain "record" still crashed): the snapshot keyed off the variable's declared type, which is just RECORDOID for a RECORD variable, so nothing was tracked. 
v10 uses the actual composite type adopted from the assigned value (er_typeid), so "r record := ROW(...)::foo" is now covered.

Case 2 (reassignment wrongly rejected): a fast path only re-checked the outermost type, so a stale nested entry survived a reassignment and caused a false positive. 
v10 refreshes the snapshot on every whole-record assignment, so reassigning with fresh data after an ALTER now succeeds (matching master), while the same sequence without the reassignment still errors.

While testing, I also found a related crash the earlier versions missed: a composite reached through a container (e.g. a field of type "t_comp[]") wasn't tracked, because the recursion stopped at the array. An ALTER TYPE on the element type then crashed in record_out() and caused a connection timeout. 
v10 iterates domain/array/range/multirange layers to reach the composite element.

v10 adds regression coverage for all of the above cases.
Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #19519: REPACK can fail due to missing chunk for toast value
Next
From: Thom Brown
Date:
Subject: Re: EXPLAIN (VERBOSE) fails with for JSON_ARRAYAGG/JSON_OBJECTAGG + window function