Skip to content

Commit

Permalink
[#26191] YSQL: Disable fast-path transaction for bulk load on colocat…
Browse files Browse the repository at this point in the history
…ed table by default

Summary:
Add a flag FLAGS_ysql_colocated_fastpath_txn_copy to enable/disable the fast-path transaction
for bulk load on colocated table. Disable it by default.
Jira: DB-15536

Test Plan: manual test.

Reviewers: pjain, rthallam

Reviewed By: pjain

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D42163
  • Loading branch information
huapengy committed Mar 3, 2025
1 parent a842915 commit 0046ce7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/postgres/src/backend/commands/copyfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ CopyFrom(CopyFromState cstate)
*/
bool has_rule_or_trigger = resultRelInfo->ri_RelationDesc->rd_rel->relhastriggers ||
resultRelInfo->ri_RelationDesc->rd_rel->relhasrules;
if (!set_txn_batch_size_explicitly && IsYBRelation(resultRelInfo->ri_RelationDesc) &&
if (yb_fast_path_for_colocated_copy &&
!set_txn_batch_size_explicitly && IsYBRelation(resultRelInfo->ri_RelationDesc) &&
YbGetTableProperties(resultRelInfo->ri_RelationDesc)->is_colocated &&
!has_rule_or_trigger && !IsTransactionBlock())
{
Expand Down
1 change: 1 addition & 0 deletions src/postgres/src/backend/executor/ybModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

bool yb_disable_transactional_writes = false;
bool yb_enable_upsert_mode = false;
bool yb_fast_path_for_colocated_copy = false;

/*
* Hack to ensure that the next CommandCounterIncrement() will call
Expand Down
11 changes: 11 additions & 0 deletions src/postgres/src/backend/utils/misc/guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,17 @@ static struct config_bool ConfigureNamesBool[] =
false,
NULL, NULL, NULL
},

{
{"yb_fast_path_for_colocated_copy", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Enable fast-path transaction for copy on colocated tables. For testint now."),
NULL
},
&yb_fast_path_for_colocated_copy,
false,
NULL, NULL, NULL
},

{
{"suppress_nonpg_logs", PGC_SIGHUP, LOGGING_WHAT,
gettext_noop("Suppresses non-Postgres logs from appearing in the Postgres log file."),
Expand Down
8 changes: 8 additions & 0 deletions src/postgres/src/include/executor/ybModifyTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
*/
extern bool yb_disable_transactional_writes;

/**
* YSQL guc variables that can be used to enable/disable fast-path transaction
* on colocated tables for copy.
* e.g. 'SET yb_fast_path_for_colocated_copy=true'
* See also the corresponding entries in guc.c.
*/
extern bool yb_fast_path_for_colocated_copy;

/**
* YSQL guc variables that can be used to enable upsert mode for writes.
* e.g. 'SET yb_enable_upsert_mode=true'
Expand Down
1 change: 1 addition & 0 deletions src/yb/yql/pgwrapper/pg_op_buffering-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void TestBulkLoadUseFastPathForColocated(PGConn* conn, const std::string& table_
generateCSVFileForCopy(csv_filename, num_rows, num_indices + 2);
const int total_write_entries = num_rows * (num_indices + 1);
ASSERT_OK(CreateTableWithIndex(conn, table_name, num_indices));
ASSERT_OK(conn->Execute("SET yb_fast_path_for_colocated_copy=true"));
// will take 2 buffers if not adjusted
ASSERT_OK(SetMaxBatchSize(conn, total_write_entries - 1));
auto write_rpc_count = ASSERT_RESULT(write_rpc_watcher->Delta(
Expand Down

0 comments on commit 0046ce7

Please sign in to comment.