Files
doc-exports/docs/dws/dev/dws_04_0103.html
luhuayi 177cd61a57 DWS DEVG 910.211 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2025-05-05 07:44:03 +00:00

50 lines
11 KiB
HTML

<a name="EN-US_TOPIC_0000002100586254"></a><a name="EN-US_TOPIC_0000002100586254"></a>
<h1 class="topictitle1">GaussDB(DWS) Connection Management Specifications</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section1066113812212"><h4 class="sectiontitle">Rule 1.1: Configuring Load Balancing for GaussDB(DWS) Clusters</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note2140203851914"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p1394716567548"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b16764135122411">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul7365125219571"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li536595215715">Load imbalance causes performance problems and even service interruption.</li><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1236595210574">When a CN is faulty, services cannot be automatically recovered or the recovery may take a long time.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p7991132685110"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b1034622155913">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul149752618017"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li5631141110232">Configure ELB load balancing and connect the application to the load balancing IP address.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section13247184232218"><h4 class="sectiontitle">Rule 1.2: Ending the Database Connection After Necessary Operations (Except in Connection Pool Scenarios)</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note1292214195917"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p14108411584"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b978134812249">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul19708232111014"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li2708123211017">The number of idle connections exceeds the maximum limit, causing connection creation failure.</li><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1070833211108">Resource overload occurs because there are too many idle connections.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p148901753683"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b19130152212620">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul243714261118"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1543752610118">After the connection between the application and the database is established and used, manually end the connection.</li><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li19437112641114">Set the <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b11275172318501">session_timeout</strong> parameter on the service side to set the idle timeout duration. The connection will be automatically ended when the idle timeout duration expires.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section1568113152617"><h4 class="sectiontitle">Rule 1.3: Ensuring a Started Transaction Is Committed or Rolled Back</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note179425519583"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p256983971910"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b197661151152415">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul139022036102110"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li18902123672112">If a transaction remains uncommitted for an extended period, it blocks operations such as <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b146314203112">ALTER</strong>, thereby affecting all services.</li><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1190253652111">The number of idle connections exceeds the maximum limit, causing connection creation failure.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p1535535214192"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b10131122252618">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul1961142782619"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li096182711269"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b1440085752010">autocommit</strong> is enabled by default, so there is no need to manually commit any transaction unless you modify the default setting.</li><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li10961132722610">If a transaction is explicitly started, it must be explicitly ended (either by committing or rolling back) once the relevant operations are finished.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section201871334162616"><h4 class="sectiontitle">Rule 1.4: Ensuring the Idle Timeout Duration Is Shorter Than SESSION_TIMEOUT Value When Connection Pool Is Used for Applications</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note204501448132519"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p11331449124718"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b5767125113244">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul1413394916475"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li613424964719">The idle timeout mechanism on the service side clears connections in the connection pool, which negatively impacts connection reuse.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p31341849134717"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b6132122272613">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul9134349194711"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li10134104924717">To ensure everything works correctly, make sure the idle timeout duration of the connection pool is shorter than the <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b173280349461">SESSION_TIMEOUT</strong> value in GaussDB(DWS). It is advised to adjust the idle timeout duration rather than modifying the <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b16409245466">SESSION_TIMEOUT</strong> value.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section161471750112613"><h4 class="sectiontitle">Rule 1.5: Restoring Parameters to Default Values in Connections Before Returning Them to the Pool</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note1538455015415"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p5384550114117"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b177681251162414">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul163841250124111"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li938410509415">When a connection is reused by another service, the parameters set by the service may also be reused. This can result in performance issues or service errors.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p9384165034116"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b141331222182620">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul1238465014119"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1384115074115">Before returning the connection to the connection pool, use <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b1645439121417">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to reset parameters.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p93851050174113"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b179738585313">Notes:</strong></p>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p8385105017415">When connection pool is used for applications, if you set the global GUC parameter using <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b6565817448">GS_GUC RELOAD</strong> in GaussDB(DWS), restart the connection pool for the changes to be applied. This is because the modification only affects new connections in the connection pool.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_section8501127112718"><h4 class="sectiontitle">Rule 1.6: Manually Clearing Temporary Tables Created with a Connection Before Returning it to the Pool</h4><div class="note" id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_note3817101220272"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p17818181272711"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b2076925116242">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul1159524823510"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1054885616361">When a connection is reused by other services, an error may be reported when a temporary table is created.</li></ul>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p881813126272"><strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b11134112213261">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_ul19865131117396"><li id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_li1086561153913">Before returning a connection to the connection pool, use <strong id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_b1725318426513">DROP</strong> to clear the temporary table created by the current session.</li></ul>
</div></div>
</div>
<p id="EN-US_TOPIC_0000002100586254__en-us_topic_0000002134166293_p15611032152213"></p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development Design Proposal</a></div>
</div>
</div>