[pgpool-hackers: 4336] Re: Allow to load balance PREPARE
Tatsuo Ishii
ishii at sraoss.co.jp
Fri May 19 15:42:04 JST 2023
> Currently it is not possible load balance PREPARE even if the prepared
> query is read only SELECT. For example,
>
> PREPARE foo AS SELECT 1;
>
> is always sent to primary node (in streaming replication mode or
> logical replication mode), or main node (in other mode).
>
> Attached patch is trying to load balance PREPARE (and following
> EXECUTE/DEALLOCATE). Documentation changes are not included yet.
>
> For this following changes are made:
>
> - is_select_query() looks into "query" member if node is
> PrepareStmt. Also second argument "sql" (query string) is now
> mandatory. If sql is NULL, warning is emitted and this function
> returns false. If allow_sql_comments is off and node is PrepareStmt
> and query is SelectStmt, is_select_query() does not return false
> anymore.
>
> - pool_has_function_call() looks into "query" member if node is
> PrepareStmt.
>
> - Add PREPARE/EXECUTE/DEALLOCATE test cases to 001.load_balance test.
>
> - Add send_prepare() function which is similar to parse_before_bind in
> extended query protocol case to keep up
> disable_load_balance_on_write rule. send_prepare() is called by
> SimpleQuery() when EXECUTE message is sent by frontend in SL mode so
> that it sends PREPARE message to primary node if it has not sent to
> primary because of load balance. Note that send_prepare() does
> nothing if the clustering mode is other than SL mode. In native
> replication mode or snapshot isolation mode, all backend has the
> same data, and there's no point to keep up
> disable_load_balance_on_write rule.
>
> Comments/suggestions are welcome.
Patch pushd. Thanks!
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
More information about the pgpool-hackers
mailing list