From: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com> |
---|---|
To: | Mat Arye <mat(at)timescaledb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Syncing sql extension versions with shared library versions |
Date: | 2017-07-26 00:54:37 |
Message-ID: | CAMsr+YFfHsD6NkCTVOYoi8_fumhLh5ok7hdsV1n6Djcf9hHe7A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
(Re-added hackers to Cc as this doesn't seem private, just accidentally
didn't reply-all?)
On 24 July 2017 at 23:50, Mat Arye <mat(at)timescaledb(dot)com> wrote:
>
>
>
>> Issue 1: Preloading the right shared library.
>> When preloading libraries (either via local_preload_libraries, or
>> session_preload_libraries, shared_preload_libraries), it would be nice to
>> preload the shared_library according to it's version. But, I looked through
>> the code and found no logic for adding version numbers to shared library
>> names.
>>
>>
>> You can't do that for shared_preload_libraries, because at
>> shared_preload_libraries time we don't have access to the DB and can't look
>> up the installed extension version(s). There might be different ones in
>> different DBs too.
>>
>>
> Yeah shared_preload_libraries is a special case I guess. Something like
> that could work with local_preload_libraries or session_preload_libraries
> right?
>
It could work, but since it doesn't offer a complete solution I don't think
it's especially compelling.
>
>> Solution 1: Set session_preload_libraries on the database via ALTER
>> DATABASE SET. This can be done in the sql and the sql version-migration
>> scripts can change this value as you change extensions versions. I think
>> this would work, but it seems very hack-ish and less-than-ideal.
>>
>>
>> Won't work for some hooks, right?
>>
>> I've faced this issue with pglogical and BDR. If the user tries to update
>> the extension before a new enough .so is loaded we ERROR due to failure to
>> load missing C functions.
>>
>
> This is a good point. Thanks for bringing it to my attention. I guess if
> the CREATE FUNCTION call contained the name of the new .so then it would
> force a load, right? But that means you need to be safe with regard to
> having both .so file loaded at once (not sure that's possible). I think
> this is the biggest unknown in terms of whether a stub-loader /can/ work.
>
Unless both .so's have different filenames, you can't have both loaded in
the same backend. Though if you unlink and replace the .so with the same
file name while Pg is running, different backends could have different
versions loaded.
If you do give them different names and they both get linked into one
backend, whether it works will depend on details of linker options, etc. I
wouldn't want to do it personally, at least not unless I prefixed all the
.so's exported symbols. If you're not worried about being portable it's
less of a concern.
Personally I just make sure to retain stub functions in the C extension for
anything removed. It's trivial clutter, easily swept into a corner in a
backward compat file.
>
>
>> If the .so is updated first the old extension function definitions can
>> fail at runtime if funcs are removed or change signature, but won't fail at
>> startup or load.
>>
>> So we let the C extension detect when it's newer than the loaded SQL ext
>> during its startup and run an ALTER EXTENSION to update it.
>>
>
> Yeah that's very similar to what we do now. It doesn't work for multiple
> dbs having different extension versions, though (at least for us).
>
Makes sense. Not a case I have ever cared to support.
--
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2017-07-26 01:21:26 | Log LDAP "diagnostic messages"? |
Previous Message | Craig Ringer | 2017-07-26 00:45:12 | Re: TAP: allow overriding PostgresNode in get_new_node |