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

Commit756b7f3

Browse files
committed
abort running concurrent partitioning task if table is not partitioned anymore
1 parent9555f74 commit756b7f3

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

‎src/pathman_workers.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include"utils/datum.h"
3737
#include"utils/memutils.h"
3838
#include"utils/lsyscache.h"
39+
#include"utils/syscache.h"
3940
#include"utils/typcache.h"
4041
#include"utils/resowner.h"
4142
#include"utils/snapmgr.h"
@@ -488,6 +489,17 @@ bgw_main_concurrent_part(Datum main_arg)
488489
intret;
489490
boolisnull;
490491

492+
/* Make sure that relation exists and has partitions */
493+
if (!SearchSysCacheExists1(RELOID,ObjectIdGetDatum(part_slot->relid))||
494+
get_pathman_relation_info(part_slot->relid)==NULL)
495+
{
496+
/* Fail fast */
497+
failures_count=PART_WORKER_MAX_ATTEMPTS;
498+
499+
elog(ERROR,"relation %u is not partitioned (or does not exist)",
500+
part_slot->relid);
501+
}
502+
491503
ret=SPI_execute_with_args(sql,2,types,vals,nulls, false,0);
492504
if (ret==SPI_OK_SELECT)
493505
{
@@ -525,25 +537,6 @@ bgw_main_concurrent_part(Datum main_arg)
525537

526538
FreeErrorData(error);
527539

528-
/*
529-
* The most common exception we can catch here is a deadlock with
530-
* concurrent user queries. Check that attempts count doesn't exceed
531-
* some reasonable value
532-
*/
533-
if (failures_count >=PART_WORKER_MAX_ATTEMPTS)
534-
{
535-
/* Mark slot as FREE */
536-
cps_set_status(part_slot,CPS_FREE);
537-
538-
elog(LOG,
539-
"concurrent partitioning worker has canceled the task because "
540-
"maximum amount of attempts (%d) had been exceeded, "
541-
"see the error message below",
542-
PART_WORKER_MAX_ATTEMPTS);
543-
544-
return;/* exit quickly */
545-
}
546-
547540
/* Set 'failed' flag */
548541
failed= true;
549542
}
@@ -552,7 +545,27 @@ bgw_main_concurrent_part(Datum main_arg)
552545
SPI_finish();
553546
PopActiveSnapshot();
554547

555-
if (failed)
548+
/*
549+
* The most common exception we can catch here is a deadlock with
550+
* concurrent user queries. Check that attempts count doesn't exceed
551+
* some reasonable value
552+
*/
553+
if (failures_count >=PART_WORKER_MAX_ATTEMPTS)
554+
{
555+
AbortCurrentTransaction();
556+
557+
/* Mark slot as FREE */
558+
cps_set_status(part_slot,CPS_FREE);
559+
560+
elog(LOG,
561+
"concurrent partitioning worker has canceled the task because "
562+
"maximum amount of attempts (%d) had been exceeded, "
563+
"see the error message below",
564+
PART_WORKER_MAX_ATTEMPTS);
565+
566+
return;
567+
}
568+
elseif (failed)
556569
{
557570
/* Abort transaction and sleep for a second */
558571
AbortCurrentTransaction();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp