Re: Plugins redux (was Re: [PATCHES] PL instrumentation - Mailing list pgsql-hackers

From korryd@enterprisedb.com
Subject Re: Plugins redux (was Re: [PATCHES] PL instrumentation
Date
Msg-id 1155163386.24313.79.camel@sakai.localdomain
Whole thread Raw
In response to Re: Plugins redux (was Re: [PATCHES] PL instrumentation plugin  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Plugins redux (was Re: [PATCHES] PL instrumentation
List pgsql-hackers
<blockquote type="CITE"><pre>
<font color="#000000">I'm not sure you'll be able to convince everyone that the penalty is so</font>
<font color="#000000">negligible --- any high-rate access to shared memory is potentially very</font>
<font color="#000000">expensive, see nearby threads for examples.  Even if this is affordable</font>
<font color="#000000">for the debugger, what of more-invasive plugins such as the performance</font>
<font color="#000000">monitor?  I think a credible general-purpose plugin design has to</font>
<font color="#000000">address the problem of enabling plugins on-the-fly.</font>
</pre></blockquote><br /> I have no problem with your solution - I think its a very nice design.<br /><br /><blockquote
type="CITE"><pre>

<font color="#000000">> I don't think it could crash because there's no way to unload a plugin</font>
<font color="#000000">> (there is no UNLOAD statement, is there?).</font>

<font color="#000000">What we actually have at the moment is that you can LOAD a library</font>
<font color="#000000">again, which causes an unload of the prior version and then loading the</font>
<font color="#000000">new.  I suppose this feature was intended to speed library development by</font>
<font color="#000000">letting you recompile and then update into your existing backend session.</font>
<font color="#000000">Not sure how many people are using it, but it's there ...</font>
</pre></blockquote><br /> Right, but you still end up with a plugin loaded afterwards so no crash (of course you could
dosomething stupid like load a new plugin with the same name that isn't really a plugin).<br /><br /><blockquote
type="CITE"><pre>
<font color="#000000">> Which reminds me, you haven't proposed a way to unload a shared-library.</font>

<font color="#000000">This depends on the semantics we want to assign to</font>
<font color="#000000">backend_shared_libraries --- I could imagine defining it as "if you</font>
<font color="#000000">remove an entry from the value then we'll unload that library".</font>
</pre></blockquote><br /> That's what I was thinking too.<br /><br /><blockquote type="CITE"><pre>
<font color="#000000">> How about a combination of plan A and plan B?  Make</font>
<font color="#000000">> backend_load_libraries a USERSET variable, but you can't *add* libraries</font>
<font color="#000000">> outside of $libdir/plugins/ unless you are a superuser.</font>

<font color="#000000">Not sure how easy that is (ie, can we track which part of the list came</font>
<font color="#000000">from where), but if doable it'd be OK with me.  We might have to split</font>
<font color="#000000">it into two list variables to make it work, and I'm not sure it's worth</font>
<font color="#000000">the complication.</font>
</pre></blockquote><br /> The GUC assign hook would parse through backend_load_libraries... <br /><br /> for each
library,<br /> {<br />      if ( the library is already loaded )<br />     {<br />         // it's not a new library,
doesn'tmatter where it lives, doesn't matter if we're a superuser<br /><br />         load( library) <br />     }<br />
    else<br />     {<br />         // it's a new entry in backed_load_libraries<br />         <br />         if(
librarylives in $libdir/plugins )<br />             load( library )<br />         else<br />         {<br />
           if( is_superuser())<br />                 load( library )<br />             else<br />                 throw
anerror<br />         }<br />     }<br /> }<br /><br /><blockquote type="CITE"><pre>
 
<font color="#000000">We already broke them by removing the init-function name...</font>
</pre></blockquote><br /> Right...<br /><br /><blockquote type="CITE"><pre>
<font color="#000000">> Do you want me to do any of this coding?</font>

<font color="#000000">Up to you --- I can do it if you don't want to.</font>
</pre></blockquote><br /> I'll take a stab at it...  thanks for your help so far.<br /><br />             -- Korry<br
/><br/><table cellpadding="0" cellspacing="0" width="100%"><tr><td><br /><br /> --<br />   Korry Douglas    <a
href="mailto:korryd@enterprisedb.com">korryd@enterprisedb.com</a><br/>   EnterpriseDB      <a
href="http://www.enterprisedb.com">http://www.enterprisedb.com</a></td></tr></table>

pgsql-hackers by date:

Previous
From: "Luke Lonergan"
Date:
Subject: Re: new job
Next
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: new job