44
44
* wrapper which will continiously try to create subscription if it fails.
45
45
* Besides, there is no way to create logical replication slot if current trxn
46
46
* had written something, and so it is impossible to do that from trigger on
47
- * update. Finally, it is a pretty bad idea to add entry to
48
- * synchronous_standy_names (obviously non-transactional action) from the
49
- * transaction that wrote something, because if remote end is not up, such
50
- * transaction will hang forever during the commit. The moral is that we
51
- * manage LR only manually.
47
+ * update. The moral is that we manage LR only manually.
52
48
*
53
49
* As always, implementations must be written atomically, so that if anything
54
50
* reboots, things are not broken. This requires special attention while
407
403
init_mp_state (MovePartState * mps , const char * part_name , int32 src_node ,
408
404
int32 dst_node )
409
405
{
410
- char * prev_dst_lname ;
411
- char * dst_next_lname ;
412
-
413
406
/* Set up fields neccesary to call init_cp_state */
414
407
mps -> cp .part_name = part_name ;
415
408
if (src_node == SHMN_INVALID_NODE_ID )
@@ -479,32 +472,17 @@ init_mp_state(MovePartState *mps, const char *part_name, int32 src_node,
479
472
mps -> cp .dst_node , part_name , mps -> cp .src_node ,
480
473
mps -> cp .dst_node , part_name , mps -> cp .src_node );
481
474
482
- /*
483
- * Note the careful placement of ensure_sync_standby's. They will
484
- * immediately block the database, because we firstly create pub &
485
- * repslots along with calling those, and only then create subs. We
486
- * execute them in separate transactions to allow other changes commit.
487
- */
488
475
if (mps -> prev_node != SHMN_INVALID_NODE_ID )
489
476
{
490
- prev_dst_lname = get_data_lname_cstr (part_name , mps -> prev_node ,
491
- mps -> cp .dst_node );
492
477
mps -> prev_sql = psprintf (
493
- "begin; select shardman.part_moved_prev('%s', %d, %d); end;"
494
- " select shardman.ensure_sync_standby('%s');" ,
495
- part_name , mps -> cp .src_node , mps -> cp .dst_node ,
496
- prev_dst_lname );
478
+ "select shardman.part_moved_prev('%s', %d, %d);" ,
479
+ part_name , mps -> cp .src_node , mps -> cp .dst_node );
497
480
}
498
481
mps -> dst_sql = psprintf (
499
- "begin; select shardman.part_moved_dst('%s', %d, %d); end ;" ,
482
+ "select shardman.part_moved_dst('%s', %d, %d);" ,
500
483
part_name , mps -> cp .src_node , mps -> cp .dst_node );
501
484
if (mps -> next_node != SHMN_INVALID_NODE_ID )
502
485
{
503
- dst_next_lname = get_data_lname_cstr (part_name , mps -> cp .dst_node ,
504
- mps -> next_node );
505
- mps -> dst_sql = psprintf (
506
- "%s select shardman.ensure_sync_standby('%s');" ,
507
- mps -> dst_sql , dst_next_lname );
508
486
mps -> next_sql = psprintf (
509
487
"select shardman.part_moved_next('%s', %d, %d);" ,
510
488
part_name , mps -> cp .src_node , mps -> cp .dst_node );
@@ -538,7 +516,6 @@ init_cr_state(CreateReplicaState *crs, const char *part_name, int32 dst_node)
538
516
{
539
517
char * sql ;
540
518
uint64 shard_exists ;
541
- char * lname ;
542
519
543
520
/* Check that table with such name is not already exists on dst node */
544
521
sql = psprintf (
@@ -580,7 +557,6 @@ init_cr_state(CreateReplicaState *crs, const char *part_name, int32 dst_node)
580
557
crs -> drop_cp_sub_sql = psprintf (
581
558
"select shardman.replica_created_drop_cp_sub('%s', %d, %d);" ,
582
559
part_name , crs -> cp .src_node , crs -> cp .dst_node );
583
- lname = get_data_lname_cstr (part_name , crs -> cp .src_node , crs -> cp .dst_node );
584
560
/*
585
561
* Separate trxn for ensure_sync_standby as in init_mp_state. It is
586
562
* interesting that while I got expected behaviour (hanged transaction) in
@@ -589,9 +565,8 @@ init_cr_state(CreateReplicaState *crs, const char *part_name, int32 dst_node)
589
565
* settings are not getting reloaded, but not sure why.
590
566
*/
591
567
crs -> create_data_pub_sql = psprintf (
592
- "begin; select shardman.replica_created_create_data_pub('%s', %d, %d); end;"
593
- " select shardman.ensure_sync_standby('%s');" ,
594
- part_name , crs -> cp .src_node , crs -> cp .dst_node , lname );
568
+ "select shardman.replica_created_create_data_pub('%s', %d, %d);" ,
569
+ part_name , crs -> cp .src_node , crs -> cp .dst_node );
595
570
crs -> create_data_sub_sql = psprintf (
596
571
"select shardman.replica_created_create_data_sub('%s', %d, %d);" ,
597
572
part_name , crs -> cp .src_node , crs -> cp .dst_node );
@@ -1381,29 +1356,6 @@ void configure_retry(CopyPartState *cps, int millis)
1381
1356
cps -> exec_res = TASK_WAKEMEUP ;
1382
1357
}
1383
1358
1384
- /*
1385
- * Convention about pub, repslot, sub and application_name used for data
1386
- * replication. We recreate sub while switching pub and recreate pub when
1387
- * switching sub, so including both in the name. See top comment on why we
1388
- * don't reuse pubs and subs.
1389
- */
1390
- char *
1391
- get_data_lname_cstr (const char * part_name , int32 pub_node , int32 sub_node )
1392
- {
1393
- return psprintf ("shardman_data_%s_%d_%d" , part_name , pub_node , sub_node );
1394
- }
1395
- /* SQL interface to it */
1396
- PG_FUNCTION_INFO_V1 (get_data_lname );
1397
- Datum
1398
- get_data_lname (PG_FUNCTION_ARGS )
1399
- {
1400
- char * part_name = text_to_cstring (PG_GETARG_TEXT_PP (0 ));
1401
- int32 pub_node = PG_GETARG_INT32 (1 );
1402
- int32 sub_node = PG_GETARG_INT32 (2 );
1403
- PG_RETURN_TEXT_P (cstring_to_text (
1404
- get_data_lname_cstr (part_name , pub_node , sub_node )));
1405
- }
1406
-
1407
1359
/*
1408
1360
* Get current CLOCK_MONOTONIC time. Fails with PG elog(FATAL) if gettime
1409
1361
* failed.
0 commit comments