On Fri, Oct 20, 2023 at 8:51 PM Zhijie Hou (Fujitsu) <houzj.f...@fujitsu.com> wrote: > > Attach the new version patch.
Thanks. Here are some comments on v55 patch: 1. A nit: + + /* + * We also skip decoding in 'fast_forward' mode. In passing set the + * 'processing_required' flag to indicate, were it not for this mode, + * processing *would* have been required. + */ How about "We also skip decoding in fast_forward mode. In passing set the processing_required flag to indicate that if it were not for fast_forward mode, processing would have been required."? 2. Don't we need InvalidateSystemCaches() after FreeDecodingContext()? + /* Clean up */ + FreeDecodingContext(ctx); 3. Don't we need to put CreateDecodingContext in PG_TRY-PG_CATCH with InvalidateSystemCaches() in PG_CATCH block? I think we need to clear all timetravel entries with InvalidateSystemCaches(), no? 4. The following assertion better be an error? Or we ensure that binary_upgrade_slot_has_caught_up isn't called for an invalidated slot at all? + + /* Slots must be valid as otherwise we won't be able to scan the WAL */ + Assert(MyReplicationSlot->data.invalidated == RS_INVAL_NONE); 5. This better be an error instead of returning false? IMO, null value for slot name is an error. + /* Quick exit if the input is NULL */ + if (PG_ARGISNULL(0)) + PG_RETURN_BOOL(false); 6. A nit: how about is_decodable_txn or is_decodable_change or some other instead of just a plain name processing_required? + /* Do we need to process any change in 'fast_forward' mode? */ + bool processing_required; 7. Can the following pg_fatal message be consistent and start with lowercase letter something like "expected 0 logical replication slots ...."? + pg_fatal("Expected 0 logical replication slots but found %d.", + nslots_on_new); 8. s/problem/problematic - "A list of problematic slots is in the file:\n" + "A list of the problem slots is in the file:\n" 9. IMO, binary_upgrade_logical_replication_slot_has_caught_up seems better, meaningful and consistent despite a bit long than just binary_upgrade_slot_has_caught_up. 10. How about an assert that the passed-in replication slot is logical in binary_upgrade_slot_has_caught_up? 11. How about adding CheckLogicalDecodingRequirements too in binary_upgrade_slot_has_caught_up after CheckSlotPermissions just in case? 12. Not necessary but adding ReplicationSlotValidateName(slot_name, ERROR); for the passed-in slotname in binary_upgrade_slot_has_caught_up may be a good idea, at least in assert builds to help with input validations. 13. Can the functionality of LogicalReplicationSlotHasPendingWal be moved to binary_upgrade_slot_has_caught_up and get rid of a separate function LogicalReplicationSlotHasPendingWal? Or is it that the function exists in logical.c to avoid extra dependencies between logical.c and pg_upgrade_support.c? 14. I think it's better to check if the old cluster contains the necessary function binary_upgrade_slot_has_caught_up instead of just relying on major version. + /* Logical slots can be migrated since PG17. */ + if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1600) + return; -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com