<html><head><meta http-equiv="content-type" content="text/html; charset=iso-2022-jp"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><div>Hi, Usama</div><div><br></div><div>I use the raw_expression_tree_walker() function to find out relname.</div><div>This function is only valid for DML statements (SELECT/INSERT/UPDATE/DELETE).</div><div>So I named this feature ‘dml_load_balance’.</div><div><br></div><div>‘adaptive’ it feels like that can parse all statements. It can't actually.</div><div>Maybe we can call it 'dml_adaptive'.</div><div><br></div><div>According to comments from you and Tatsuo Ishii, i will make a new patch.</div><div><br></div><div>Thanks</div><div>Best Regards</div></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>sunbiao@highgo.com</div></div></span></div>
<blockquote style="margin-Top: 0px; margin-Bottom: 0px; margin-Left: 0.5em; margin-Right: inherit"><div>&nbsp;</div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b>&nbsp;<a href="mailto:ishii@sraoss.co.jp">Tatsuo Ishii</a></div><div><b>Date:</b>&nbsp;2020-06-20&nbsp;17:50</div><div><b>To:</b>&nbsp;<a href="mailto:m.usama@gmail.com">m.usama@gmail.com</a></div><div><b>CC:</b>&nbsp;<a href="mailto:sunbiao@highgo.com">sunbiao@highgo.com</a>; <a href="mailto:pgpool-hackers@pgpool.net">pgpool-hackers@pgpool.net</a></div><div><b>Subject:</b>&nbsp;Re: [pgpool-hackers: 3592] add a feature: dml object level load balance</div></div></div><div><div>Hi Usama,</div>
<div>&nbsp;</div>
<div>&gt; Hi Sunbiao,</div>
<div>&gt; </div>
<div>&gt; Thanks for the updated patch. Overall the patch looks good and works as</div>
<div>&gt; expected.</div>
<div>&gt; </div>
<div>&gt; However, I am a little concerned about the performance aspect of</div>
<div>&gt; the check_object_relationship_list() function.</div>
<div>&gt; Since it is parsing the item in the</div>
<div>&gt; dml_load_balance_object_relationship_list</div>
<div>&gt; list every time it is invoked. So I think we need to fissure out the way to</div>
<div>&gt; store the pre-parsed list (which can be constructed at session start) and</div>
<div>&gt; try</div>
<div>&gt; to save the parsing at each function call.</div>
<div>&gt; </div>
<div>&gt; Other than that you need to provide the documentation updates for the</div>
<div>&gt; feature.</div>
<div>&gt; </div>
<div>&gt; Finally, one last comment is how about if we change the</div>
<div>&gt; disable_load_balance_on_write</div>
<div>&gt; setting name from 'dml_load_balance' to 'adaptive'?</div>
<div>&gt; </div>
<div>&gt; </div>
<div>&gt; @Tatsuo Ishii &lt;ishii@sraoss.co.jp&gt;</div>
<div>&gt; What do you think about this feature and patch? If you do not have any</div>
<div>&gt; reservations then</div>
<div>&gt; I will commit it after Sunbiao takes care of review comments.</div>
<div>&nbsp;</div>
<div>Looks good to me except subtle points below:</div>
<div>&nbsp;</div>
<div>- The test should include tests for extended query:</div>
<div>&nbsp; i.e. src/test/extended-query-test. There are some tests or</div>
<div>&nbsp; disable-load-balance. So it's better to add a test to them.</div>
<div>&nbsp;</div>
<div>- There are extra spaces in the patch. Also it needs rebase.</div>
<div>&nbsp;</div>
<div>t-ishii$ git apply ~/0001-dml-load-balance-patch-v3.patch </div>
<div>/home/t-ishii/0001-dml-load-balance-patch-v3.patch:327: space before tab in indent.</div>
<div>                                                                                                                                  * dml_load_balance_object_relationship_list */</div>
<div>/home/t-ishii/0001-dml-load-balance-patch-v3.patch:679: trailing whitespace.</div>
<div>CREATE OR REPLACE FUNCTION insert_tb_t2_func() RETURNS TRIGGER AS $example_table$&nbsp; </div>
<div>/home/t-ishii/0001-dml-load-balance-patch-v3.patch:680: trailing whitespace.</div>
<div>&nbsp;&nbsp;&nbsp; BEGIN&nbsp; </div>
<div>/home/t-ishii/0001-dml-load-balance-patch-v3.patch:681: trailing whitespace.</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO tb_t2 VALUES (1);&nbsp; </div>
<div>/home/t-ishii/0001-dml-load-balance-patch-v3.patch:682: trailing whitespace.</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETURN NEW;&nbsp;&nbsp; </div>
<div>error: patch failed: src/context/pool_session_context.c:170</div>
<div>error: src/context/pool_session_context.c: patch does not apply</div>
<div>&nbsp;</div>
<div>&gt; Thanks</div>
<div>&gt; Best Regards</div>
<div>&gt; Muhammad Usama</div>
<div>&gt; </div>
<div>&gt; </div>
<div>&gt; Thanks</div>
<div>&gt; Best Regards</div>
<div>&gt; Muhammad Usama</div>
<div>&gt; </div>
<div>&gt; On Mon, Jun 15, 2020 at 7:25 AM sunbiao@highgo.com &lt;sunbiao@highgo.com&gt;</div>
<div>&gt; wrote:</div>
<div>&gt; </div>
<div>&gt;&gt; Hi, Usama</div>
<div>&gt;&gt; I found a problem in patch v2.</div>
<div>&gt;&gt; I can not use “pool show” to show new added parameter.</div>
<div>&gt;&gt; So i made patch v3.</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; I make disable_load_balance_on_write to accept new value.</div>
<div>&gt;&gt; Set disable_load_balance_on_write = 'dml_load_balance' to enable this</div>
<div>&gt;&gt; feature.</div>
<div>&gt;&gt; This new patch contains a test script in path</div>
<div>&gt;&gt; ‘src/test/dml-load-balance-test’.</div>
<div>&gt;&gt; If pg installed by default in /usr/local/pgsql, just execute test.sh.</div>
<div>&gt;&gt; If pg is in other dir, execute&nbsp; ‘test.sh -p /path_to_pg_dir/’.</div>
<div>&gt;&gt; It will show “success: dml load balance test pass.” , when test pass.</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; this script will test below sql:</div>
<div>&gt;&gt; show pool_nodes;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; -- test DML</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; insert into tb_dml_insert values (1);</div>
<div>&gt;&gt; select * from tb_dml_insert ;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; update tb_dml_update SET a = 2;</div>
<div>&gt;&gt; select * from tb_dml_update ;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; delete from tb_dml_delete;</div>
<div>&gt;&gt; select * from tb_dml_delete;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; -- test trigger</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; insert into tb_t1 values (1);</div>
<div>&gt;&gt; select * from tb_t2 ;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; -- test function</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; select insert_tb_f_func(6);</div>
<div>&gt;&gt; select * from tb_f ;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; -- test view</div>
<div>&gt;&gt; begin ;</div>
<div>&gt;&gt; insert into tb_v values (8);</div>
<div>&gt;&gt; select * from tb_v_view ;</div>
<div>&gt;&gt; commit ;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; Thanks</div>
<div>&gt;&gt; Best Regards</div>
<div>&gt;&gt; ------------------------------</div>
<div>&gt;&gt; sunbiao@highgo.com</div>
<div>&gt;&gt;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; *From:* Muhammad Usama &lt;m.usama@gmail.com&gt;</div>
<div>&gt;&gt; *Date:* 2020-06-12 18:08</div>
<div>&gt;&gt; *To:* sunbiao@highgo.com</div>
<div>&gt;&gt; *CC:* pgpool-hackers &lt;pgpool-hackers@pgpool.net&gt;</div>
<div>&gt;&gt; *Subject:* Re: [pgpool-hackers: 3592] add a feature: dml object level</div>
<div>&gt;&gt; load balance</div>
<div>&gt;&gt; Hi Sunbiao,</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; Can you kindly resend the 0001-dml-load-balance-patch-v2.patch patch? I</div>
<div>&gt;&gt; am not able to download the patch file.</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; Thanks</div>
<div>&gt;&gt; Best regards</div>
<div>&gt;&gt; Muhammad Usama</div>
<div>&gt;&gt;</div>
<div>&gt;&gt;</div>
<div>&gt;&gt; On Fri, Apr 24, 2020 at 9:55 PM Muhammad Usama &lt;m.usama@gmail.com&gt; wrote:</div>
<div>&gt;&gt;</div>
<div>&gt;&gt;&gt; Hi Sunbiao,</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; Thanks for the patch and it looks line an interesting feature. I have</div>
<div>&gt;&gt;&gt; just skimmed</div>
<div>&gt;&gt;&gt; through the patch and I have a few of small comments.</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; 1 - Wouldn't it be better to add a new mode existing</div>
<div>&gt;&gt;&gt; disable_load_balance_on_write parameter</div>
<div>&gt;&gt;&gt; instead of adding a new configuration parameter i.e</div>
<div>&gt;&gt;&gt; dml_object_level_load_balance ?</div>
<div>&gt;&gt;&gt; You can make disable_load_balance_on_write to accept new value like</div>
<div>&gt;&gt;&gt; disable_load_balance_on_write = 'object' to enable this feature.</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; 2- The patch contains some invalid changes in pgpool.conf.sample-stream</div>
<div>&gt;&gt;&gt; file</div>
<div>&gt;&gt;&gt; i.e it changes the default values of black_function_list and</div>
<div>&gt;&gt;&gt; disable_load_balance_on_write</div>
<div>&gt;&gt;&gt; configuration parameters which I am sure were not intended</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; 3- The default value for new configuration parameter</div>
<div>&gt;&gt;&gt; dml_object_level_load_balance_token_list</div>
<div>&gt;&gt;&gt; better be an empty</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; 4- Instead of attaching a separate test script you could include a proper</div>
<div>&gt;&gt;&gt; test case for the feature.</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; Thanks</div>
<div>&gt;&gt;&gt; Best Regards</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; Muhammad Usama</div>
<div>&gt;&gt;&gt; Highgo Software (Canada/China/Pakistan)</div>
<div>&gt;&gt;&gt; URL : http://www.highgo.ca</div>
<div>&gt;&gt;&gt; ADDR: 10318 WHALLEY BLVD, Surrey, BC</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt; On Fri, Apr 24, 2020 at 3:43 PM sunbiao@highgo.com &lt;sunbiao@highgo.com&gt;</div>
<div>&gt;&gt;&gt; wrote:</div>
<div>&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; Hi Hackers,</div>
<div>&gt;&gt;&gt;&gt; If sql like below:</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; begin ;</div>
<div>&gt;&gt;&gt;&gt; update tb_1 SET id = 1;</div>
<div>&gt;&gt;&gt;&gt; select * from tb_1 ;</div>
<div>&gt;&gt;&gt;&gt; select * from tb_2 ;</div>
<div>&gt;&gt;&gt;&gt; select * from tb_3 ;</div>
<div>&gt;&gt;&gt;&gt; select * from tb_4 ;</div>
<div>&gt;&gt;&gt;&gt; select * from tb_5 ;</div>
<div>&gt;&gt;&gt;&gt; commit ;</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; when set disable_load_balance_on_write = 'transaction'. write queries</div>
<div>&gt;&gt;&gt;&gt; appear in an explicit transaction, subsequent read queries are not load</div>
<div>&gt;&gt;&gt;&gt; balanced until the transaction ends. so all sql will be sent to primary</div>
<div>&gt;&gt;&gt;&gt; node.</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; i think that “update tb_1 SET id = 1” and “select * from tb_1” should be</div>
<div>&gt;&gt;&gt;&gt; sent to primary node.</div>
<div>&gt;&gt;&gt;&gt; actually, tb_2 tb_3 tb_4 tb_5 can be sent to standby node. if do this,</div>
<div>&gt;&gt;&gt;&gt; will reduce primary load.</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; so i made a patch to implement my idea.</div>
<div>&gt;&gt;&gt;&gt; when transaction start, i will initialize a list to save table name of</div>
<div>&gt;&gt;&gt;&gt; write queries.</div>
<div>&gt;&gt;&gt;&gt; read queries will check the list, if find the table name in list, read</div>
<div>&gt;&gt;&gt;&gt; queries will be sent to primary.</div>
<div>&gt;&gt;&gt;&gt; when transaction end, i destroy the list.</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; i add two parameter:</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; dml_object_level_load_balance = on</div>
<div>&gt;&gt;&gt;&gt; dml_object_level_load_balance_token_list=</div>
<div>&gt;&gt;&gt;&gt; 'tb_t1:tb_t2,insert_tb_f_func():tb_f,tb_v:tb_v_view'</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; use dml_object_level_load_balance_token_list to set relationships</div>
<div>&gt;&gt;&gt;&gt; between objects, such as trigger, function, view.</div>
<div>&gt;&gt;&gt;&gt; If set dml_object_level_load_balance = on, disable_load_balance_on_write</div>
<div>&gt;&gt;&gt;&gt; should be off.</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;&gt; Is it possible to add this feature?</div>
<div>&gt;&gt;&gt;&gt; ------------------------------</div>
<div>&gt;&gt;&gt;&gt; sunbiao@highgo.com</div>
<div>&gt;&gt;&gt;&gt; _______________________________________________</div>
<div>&gt;&gt;&gt;&gt; pgpool-hackers mailing list</div>
<div>&gt;&gt;&gt;&gt; pgpool-hackers@pgpool.net</div>
<div>&gt;&gt;&gt;&gt; http://www.pgpool.net/mailman/listinfo/pgpool-hackers</div>
<div>&gt;&gt;&gt;&gt;</div>
<div>&gt;&gt;&gt;</div>
</div></blockquote>
</body></html>