|
411 | 411 | $node_standby3->stop; |
412 | 412 |
|
413 | 413 | # ============================================================================= |
414 | | -# Testcase start: Check last_inactive_time property of the streaming standby's slot |
| 414 | +# Testcase start: Check inactive_since property of the streaming standby's slot |
415 | 415 | # |
416 | 416 |
|
417 | 417 | # Initialize primary node |
|
440 | 440 | SELECT pg_create_physical_replication_slot(slot_name := '$sb4_slot'); |
441 | 441 | ]); |
442 | 442 |
|
443 | | -# Get last_inactive_time value after the slot's creation. Note that the slot |
444 | | -# is still inactive till it's used by the standby below. |
445 | | -my $last_inactive_time = |
446 | | - capture_and_validate_slot_last_inactive_time($primary4, $sb4_slot, $slot_creation_time); |
| 443 | +# Get inactive_since value after the slot's creation. Note that the slot is |
| 444 | +# still inactive till it's used by the standby below. |
| 445 | +my $inactive_since = |
| 446 | + capture_and_validate_slot_inactive_since($primary4, $sb4_slot, $slot_creation_time); |
447 | 447 |
|
448 | 448 | $standby4->start; |
449 | 449 |
|
450 | 450 | # Wait until standby has replayed enough data |
451 | 451 | $primary4->wait_for_catchup($standby4); |
452 | 452 |
|
453 | | -# Now the slot is active so last_inactive_time value must be NULL |
| 453 | +# Now the slot is active so inactive_since value must be NULL |
454 | 454 | is( $primary4->safe_psql( |
455 | 455 | 'postgres', |
456 | | - qq[SELECT last_inactive_time IS NULL FROM pg_replication_slots WHERE slot_name = '$sb4_slot';] |
| 456 | + qq[SELECT inactive_since IS NULL FROM pg_replication_slots WHERE slot_name = '$sb4_slot';] |
457 | 457 | ), |
458 | 458 | 't', |
459 | 459 | 'last inactive time for an active physical slot is NULL'); |
460 | 460 |
|
461 | | -# Stop the standby to check its last_inactive_time value is updated |
| 461 | +# Stop the standby to check its inactive_since value is updated |
462 | 462 | $standby4->stop; |
463 | 463 |
|
464 | | -# Let's restart the primary so that the last_inactive_time is set upon |
465 | | -# loading the slot from the disk. |
| 464 | +# Let's restart the primary so that the inactive_since is set upon loading the |
| 465 | +# slot from the disk. |
466 | 466 | $primary4->restart; |
467 | 467 |
|
468 | 468 | is( $primary4->safe_psql( |
469 | 469 | 'postgres', |
470 | | - qq[SELECT last_inactive_time > '$last_inactive_time'::timestamptz FROM pg_replication_slots WHERE slot_name = '$sb4_slot' AND last_inactive_time IS NOT NULL;] |
| 470 | + qq[SELECT inactive_since > '$inactive_since'::timestamptz FROM pg_replication_slots WHERE slot_name = '$sb4_slot' AND inactive_since IS NOT NULL;] |
471 | 471 | ), |
472 | 472 | 't', |
473 | 473 | 'last inactive time for an inactive physical slot is updated correctly'); |
474 | 474 |
|
475 | 475 | $standby4->stop; |
476 | 476 |
|
477 | | -# Testcase end: Check last_inactive_time property of the streaming standby's slot |
| 477 | +# Testcase end: Check inactive_since property of the streaming standby's slot |
478 | 478 | # ============================================================================= |
479 | 479 |
|
480 | 480 | # ============================================================================= |
481 | | -# Testcase start: Check last_inactive_time property of the logical subscriber's slot |
| 481 | +# Testcase start: Check inactive_since property of the logical subscriber's slot |
482 | 482 | my $publisher4 = $primary4; |
483 | 483 |
|
484 | 484 | # Create subscriber node |
|
499 | 499 | "SELECT pg_create_logical_replication_slot(slot_name := '$lsub4_slot', plugin := 'pgoutput');" |
500 | 500 | ); |
501 | 501 |
|
502 | | -# Get last_inactive_time value after the slot's creation. Note that the slot |
503 | | -# is still inactive till it's used by the subscriber below. |
504 | | -$last_inactive_time = |
505 | | - capture_and_validate_slot_last_inactive_time($publisher4, $lsub4_slot, $slot_creation_time); |
| 502 | +# Get inactive_since value after the slot's creation. Note that the slot is |
| 503 | +# still inactive till it's used by the subscriber below. |
| 504 | +$inactive_since = |
| 505 | + capture_and_validate_slot_inactive_since($publisher4, $lsub4_slot, $slot_creation_time); |
506 | 506 |
|
507 | 507 | $subscriber4->start; |
508 | 508 | $subscriber4->safe_psql('postgres', |
|
512 | 512 | # Wait until subscriber has caught up |
513 | 513 | $subscriber4->wait_for_subscription_sync($publisher4, 'sub'); |
514 | 514 |
|
515 | | -# Now the slot is active so last_inactive_time value must be NULL |
| 515 | +# Now the slot is active so inactive_since value must be NULL |
516 | 516 | is( $publisher4->safe_psql( |
517 | 517 | 'postgres', |
518 | | - qq[SELECT last_inactive_time IS NULL FROM pg_replication_slots WHERE slot_name = '$lsub4_slot';] |
| 518 | + qq[SELECT inactive_since IS NULL FROM pg_replication_slots WHERE slot_name = '$lsub4_slot';] |
519 | 519 | ), |
520 | 520 | 't', |
521 | 521 | 'last inactive time for an active logical slot is NULL'); |
522 | 522 |
|
523 | | -# Stop the subscriber to check its last_inactive_time value is updated |
| 523 | +# Stop the subscriber to check its inactive_since value is updated |
524 | 524 | $subscriber4->stop; |
525 | 525 |
|
526 | | -# Let's restart the publisher so that the last_inactive_time is set upon |
| 526 | +# Let's restart the publisher so that the inactive_since is set upon |
527 | 527 | # loading the slot from the disk. |
528 | 528 | $publisher4->restart; |
529 | 529 |
|
530 | 530 | is( $publisher4->safe_psql( |
531 | 531 | 'postgres', |
532 | | - qq[SELECT last_inactive_time > '$last_inactive_time'::timestamptz FROM pg_replication_slots WHERE slot_name = '$lsub4_slot' AND last_inactive_time IS NOT NULL;] |
| 532 | + qq[SELECT inactive_since > '$inactive_since'::timestamptz FROM pg_replication_slots WHERE slot_name = '$lsub4_slot' AND inactive_since IS NOT NULL;] |
533 | 533 | ), |
534 | 534 | 't', |
535 | 535 | 'last inactive time for an inactive logical slot is updated correctly'); |
536 | 536 |
|
537 | | -# Testcase end: Check last_inactive_time property of the logical subscriber's slot |
| 537 | +# Testcase end: Check inactive_since property of the logical subscriber's slot |
538 | 538 | # ============================================================================= |
539 | 539 |
|
540 | 540 | $publisher4->stop; |
541 | 541 | $subscriber4->stop; |
542 | 542 |
|
543 | | -# Capture and validate last_inactive_time of a given slot. |
544 | | -sub capture_and_validate_slot_last_inactive_time |
| 543 | +# Capture and validate inactive_since of a given slot. |
| 544 | +sub capture_and_validate_slot_inactive_since |
545 | 545 | { |
546 | 546 | my ($node, $slot_name, $slot_creation_time) = @_; |
547 | 547 |
|
548 | | - my $last_inactive_time = $node->safe_psql('postgres', |
549 | | - qq(SELECT last_inactive_time FROM pg_replication_slots |
550 | | - WHERE slot_name = '$slot_name' AND last_inactive_time IS NOT NULL;) |
| 548 | + my $inactive_since = $node->safe_psql('postgres', |
| 549 | + qq(SELECT inactive_since FROM pg_replication_slots |
| 550 | + WHERE slot_name = '$slot_name' AND inactive_since IS NOT NULL;) |
551 | 551 | ); |
552 | 552 |
|
553 | 553 | # Check that the captured time is sane |
554 | 554 | is( $node->safe_psql( |
555 | 555 | 'postgres', |
556 | | - qq[SELECT '$last_inactive_time'::timestamptz > to_timestamp(0) AND |
557 | | - '$last_inactive_time'::timestamptz >= '$slot_creation_time'::timestamptz;] |
| 556 | + qq[SELECT '$inactive_since'::timestamptz > to_timestamp(0) AND |
| 557 | + '$inactive_since'::timestamptz >= '$slot_creation_time'::timestamptz;] |
558 | 558 | ), |
559 | 559 | 't', |
560 | 560 | "last inactive time for an active slot $slot_name is sane"); |
561 | 561 |
|
562 | | - return $last_inactive_time; |
| 562 | + return $inactive_since; |
563 | 563 | } |
564 | 564 |
|
565 | 565 | done_testing(); |
0 commit comments