Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49f7c6c

Browse files
committed
Abort pgbench if script end is reached with an open pipeline
When a pipeline is opened with \startpipeline and not closed, pgbenchwill either error on the next transaction with a "already in pipelinemode" error or successfully end if this was the last transaction --despite not sending anything that was piped in the pipeline.Make it an error to reach end of script is reached while there's anopen pipeline.Backpatch to 14, where pgbench got support for pipelines.Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>Reported-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/Za4IObZkDjrO4TcS@paquier.xyz
1 parent752533d commit49f7c6c

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,10 +3763,21 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
37633763
caseCSTATE_START_COMMAND:
37643764
command=sql_script[st->use_file].commands[st->command];
37653765

3766-
/* Transition to script end processing if done */
3766+
/*
3767+
* Transition to script end processing if done, but close up
3768+
* shop if a pipeline is open at this point.
3769+
*/
37673770
if (command==NULL)
37683771
{
3769-
st->state=CSTATE_END_TX;
3772+
if (PQpipelineStatus(st->con)==PQ_PIPELINE_OFF)
3773+
st->state=CSTATE_END_TX;
3774+
else
3775+
{
3776+
pg_log_error("client %d aborted: end of script reached with pipeline open",
3777+
st->id);
3778+
st->state=CSTATE_ABORTED;
3779+
}
3780+
37703781
break;
37713782
}
37723783

‎src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,34 @@ sub check_data_state
876876
}
877877
});
878878

879+
# Try \startpipeline without \endpipeline in a single transaction
880+
$node->pgbench(
881+
'-t 1 -n -M extended',
882+
2,
883+
[],
884+
[qr{end of script reached with pipeline open}],
885+
'error: call \startpipeline without \endpipeline in a single transaction',
886+
{
887+
'001_pgbench_pipeline_5'=>q{
888+
-- startpipeline only with single transaction
889+
\startpipeline
890+
}
891+
});
892+
893+
# Try \startpipeline without \endpipeline
894+
$node->pgbench(
895+
'-t 2 -n -M extended',
896+
2,
897+
[],
898+
[qr{end of script reached with pipeline open}],
899+
'error: call \startpipeline without \endpipeline',
900+
{
901+
'001_pgbench_pipeline_6'=>q{
902+
-- startpipeline only
903+
\startpipeline
904+
}
905+
});
906+
879907
# Working \startpipeline in prepared query mode with serializable
880908
$node->pgbench(
881909
'-c4 -t 10 -n -M prepared',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp