Перейти к основному содержимому

Особенности обновления, связанные с переходом на ядро PostgreSQL 17.5

Внимание!

Информация актуальна для обновления с версии 6.5.2 на 7.1.0.

Особенности миграции

При переходе на новую версию ядра для миграции данных необходимо использовать pg_dumpall или pg_upgrade. В разделе «Обновление кластера PostgreSQL, интегрированной переведенной документации PostgreSQL, можно ознакомиться с общими рекомендациями при переходе на обновленную версию ядра для каждого из способов.

Перед обновлением на версию Pangolin 7.x.x:

Сохранение совместимости с ранними версиями

Для сохранения совместимости с предыдущими выпусками продукта:

  • Не используйте устаревшие reg-типы данных, (включая операторы, классы операторов, семейства операторов, агрегаты, индексы и пр.):

    • pg_catalog.regcollation;
    • pg_catalog.regconfig;
    • pg_catalog.regdictionary;
    • pg_catalog.regnamespace;
    • pg_catalog.regoper;
    • pg_catalog.regoperator;
    • pg_catalog.regproc;
    • pg_catalog.regprocedure.
  • Убедитесь в отсутствии модулей adminpack и old_snapshot, так как их поддержка прекращена в 17 ядре.

  • Убедитесь в отсутствии расширений pg_pathman и pgcompacttable, так как они удалены из состава продукта в версии 7.1.0.

  • В случае изменения прав на процедуры и функции системного каталога отмените изменения перед началом миграции.

    Для 17 версии СУБД изменились сигнатуры (схема, имена, порядок, значения входных переменных по умолчанию) следующих процедур/функций:

    • pg_catalog.interval_accum','postgres',NULL,'interval[],interval;
    • pg_catalog.interval_accum_inv','postgres',NULL,'interval[],interval;
    • pg_catalog.interval_avg','postgres',NULL,'interval[];
    • pg_catalog.interval_combine','postgres',NULL,'interval[],interval[];
    • pg_catalog.pg_create_logical_replication_slot','postgres',NULL,'name,name,boolean,boolean;
    • pg_catalog.pg_current_logfile','postgres','{postgres=X/postgres}','text;
    • pg_catalog.pg_get_publication_tables','postgres',NULL,'text;
    • pg_catalog.pg_logical_emit_message','postgres',NULL,'boolean,text,bytea;
    • pg_catalog.pg_logical_emit_message','postgres',NULL,'boolean,text,text;
    • pg_catalog.pg_read_file_old','postgres',NULL,'text,bigint,bigint.
    • information_schema.__pg_foreign_data_wrappers;
    • information_schema.__pg_foreign_servers;
    • information_schema.__pg_foreign_table_columns;
    • information_schema.__pg_foreign_tables;
    • information_schema.__pg_user_mappings;
    • information_schema._administrable_role_authorizations;
    • information_schema._applicable_roles;
    • information_schema._attributes;
    • information_schema._cardinal_number;
    • information_schema._character_data;
    • information_schema._character_sets;
    • information_schema._check_constraint_routine_usage;
    • information_schema._check_constraints;
    • information_schema._collation_character_set_applicability;
    • information_schema._collations;
    • information_schema._column_column_usage;
    • information_schema._column_domain_usage;
    • information_schema._column_options;
    • information_schema._column_privileges;
    • information_schema._column_udt_usage;
    • information_schema._columns;
    • information_schema._constraint_column_usage;
    • information_schema._constraint_table_usage;
    • information_schema._data_type_privileges;
    • information_schema._domain_constraints;
    • information_schema._domain_udt_usage;
    • information_schema._domains;
    • information_schema._element_types;
    • information_schema._enabled_roles;
    • information_schema._foreign_data_wrapper_options;
    • information_schema._foreign_data_wrappers;
    • information_schema._foreign_server_options;
    • information_schema._foreign_servers;
    • information_schema._foreign_table_options;
    • information_schema._foreign_tables;
    • information_schema._information_schema_catalog_name;
    • information_schema._key_column_usage;
    • information_schema._parameters;
    • information_schema._pg_foreign_data_wrappers;
    • information_schema._pg_foreign_servers;
    • information_schema._pg_foreign_table_columns;
    • information_schema._pg_foreign_tables;
    • information_schema._pg_user_mappings;
    • information_schema._referential_constraints;
    • information_schema._role_column_grants;
    • information_schema._role_routine_grants;
    • information_schema._role_table_grants;
    • information_schema._role_udt_grants;
    • information_schema._role_usage_grants;
    • information_schema._routine_column_usage;
    • information_schema._routine_privileges;
    • information_schema._routine_routine_usage;
    • information_schema._routine_sequence_usage;
    • information_schema._routine_table_usage;
    • information_schema._routines;
    • information_schema._schemata;
    • information_schema._sequences;
    • information_schema._sql_features;
    • information_schema._sql_identifier;
    • information_schema._sql_implementation_info;
    • information_schema._sql_parts;
    • information_schema._sql_sizing;
    • information_schema._table_constraints;
    • information_schema._table_privileges;
    • information_schema._tables;
    • information_schema._time_stamp;
    • information_schema._transforms;
    • information_schema._triggered_update_columns;
    • information_schema._triggers;
    • information_schema._udt_privileges;
    • information_schema._usage_privileges;
    • information_schema._user_defined_types;
    • information_schema._user_mapping_options;
    • information_schema._user_mappings;
    • information_schema._view_column_usage;
    • information_schema._view_routine_usage;
    • information_schema._view_table_usage;
    • information_schema._views;
    • information_schema._yes_or_no;
    • information_schema.administrable_role_authorizations;
    • information_schema.applicable_roles;
    • information_schema.attributes;
    • information_schema.cardinal_number;
    • information_schema.character_data;
    • information_schema.character_sets;
    • information_schema.check_constraint_routine_usage;
    • information_schema.check_constraints;
    • information_schema.collation_character_set_applicability;
    • information_schema.collations;
    • information_schema.column_column_usage;
    • information_schema.column_domain_usage;
    • information_schema.column_options;
    • information_schema.column_privileges;
    • information_schema.column_udt_usage;
    • information_schema.columns;
    • information_schema.constraint_column_usage;
    • information_schema.constraint_table_usage;
    • information_schema.data_type_privileges;
    • information_schema.domain_constraints;
    • information_schema.domain_udt_usage;
    • information_schema.domains;
    • information_schema.element_types;
    • information_schema.enabled_roles;
    • information_schema.foreign_data_wrapper_options;
    • information_schema.foreign_data_wrappers;
    • information_schema.foreign_server_options;
    • information_schema.foreign_servers;
    • information_schema.foreign_table_options;
    • information_schema.foreign_tables;
    • information_schema.information_schema_catalog_name;
    • information_schema.key_column_usage;
    • information_schema.parameters;
    • information_schema.referential_constraints;
    • information_schema.role_column_grants;
    • information_schema.role_routine_grants;
    • information_schema.role_table_grants;
    • information_schema.role_udt_grants;
    • information_schema.role_usage_grants;
    • information_schema.routine_column_usage;
    • information_schema.routine_privileges;
    • information_schema.routine_routine_usage;
    • information_schema.routine_sequence_usage;
    • information_schema.routine_table_usage;
    • information_schema.routines;
    • information_schema.schemata;
    • information_schema.sequences;
    • information_schema.sql_features;
    • information_schema.sql_identifier;
    • information_schema.sql_implementation_info;
    • information_schema.sql_parts;
    • information_schema.sql_sizing;
    • information_schema.table_constraints;
    • information_schema.table_privileges;
    • information_schema.tables;
    • information_schema.time_stamp;
    • information_schema.transforms;
    • information_schema.triggered_update_columns;
    • information_schema.triggers;
    • information_schema.udt_privileges;
    • information_schema.usage_privileges;
    • information_schema.user_defined_types;
    • information_schema.user_mapping_options;
    • information_schema.user_mappings;
    • information_schema.view_column_usage;
    • information_schema.view_routine_usage;
    • information_schema.view_table_usage;
    • information_schema.views;
    • information_schema.yes_or_no.

Особенности работы команд ATTACH/DETACH PARTITION

Если целевая таблица партиционирована, то для отдельной, ссылающейся на целевую, таблицы необходимы другие записи каталога. В версиях PostgreSQL до 15.9 команды ATTACH/DETACH PARTITION выполняли это преобразование некорректно. В частности, после выполнения команды DETACH для новой отдельной таблицы терялись триггеры обеспечения целостности внешнего ключа, из-за чего в таблице могли появляться строки, не выполняющие требования по ограничению внешнего ключа. Кроме того, последующее повторное присоединение командой ATTACH могло приводить к неожиданным ошибкам.

Это можно исправить, выполнив команду ALTER TABLE DROP CONSTRAINT для новой отдельной таблицы в отношении каждого ограничения с ошибкой и добавив ограничение заново. Ошибка при повторном добавлении ограничения означает появление ошибочных данных. В этом случае необходимо заново и вручную обеспечить целостность целевой и ссылающейся таблиц, а затем еще раз добавить ограничение.

Используйте запрос ниже, чтобы выявить нарушенные ограничения и подготовить команды для создания таких ограничений заново:

SELECT conrelid::pg_catalog.regclass AS "constrained table",
conname AS constraint,
confrelid::pg_catalog.regclass AS "references",
pg_catalog.format('ALTER TABLE %s DROP CONSTRAINT %I;',
conrelid::pg_catalog.regclass, conname) AS "drop",
pg_catalog.format('ALTER TABLE %s ADD CONSTRAINT %I %s;',
conrelid::pg_catalog.regclass, conname,
pg_catalog.pg_get_constraintdef(oid)) AS "add"
FROM pg_catalog.pg_constraint c
WHERE contype = 'f' AND conparentid = 0 AND
(SELECT count(*) FROM pg_catalog.pg_constraint c2
WHERE c2.conparentid = c.oid) <>
(SELECT count(*) FROM pg_catalog.pg_inherits i
WHERE (i.inhparent = c.conrelid OR i.inhparent = c.confrelid) AND
EXISTS (SELECT 1 FROM pg_catalog.pg_partitioned_table
WHERE partrelid = i.inhparent));

Поскольку один или несколько этапов выполнения команды ADD CONSTRAINT могут завершиться ошибкой, сохраните вывод запроса в файл и попробуйте заново повторить каждый этап.

Особенности обновления при выявлении старых неиспользуемых записей каталога pg_init_privs

После удаления расширения, которое предоставляло определенные права на уровне столбцов созданной им таблицы, в каталоге оставались соответствующие записи. Это было безопасно до тех пор, пока/если OID таблицы не переиспользовался для другого отношения и не влиял на результат работы pg_dump для этого отношения. Поведение изменено с переходом на ядро PostgreSQL 17.5, но оставшиеся ранее лишние записи, связь которых с таблицами когда-то удаленных расширений потеряна, могут негативно проявить себя при переиспользовании OID таблицы. Стоит их обнаружить и предупредить пользователя или удалить вместе с общей автоматической или ручной логикой.

Процесс выявления оставшихся ранее лишних записей информирует об их наличии с помощью предупреждения:

"{{ control_name }}.WARNING__W03011:В СУБД обнаружены потерянные записи pg_init_privs после сбоя при удалении таблицы, связанной с проблемой ядер PostgreSQL до 15.8. \ Рекомендуем выполнить их удаление в БД: {} c с помощью команды DELETE: {}.__{{ control_name }}.WARNING"

При выявлении старых неиспользуемых записей каталога pg_init_privs процесс обновления СУБД не блокируется.

Особенности работы с индексами GIN

В предыдущей версии ядра использовалась общая, а не эксклюзивная блокировка буфера. Это могло приводить к повреждению индекса, если два процесса пытались выполнить очистку одновременно. После установки этого обновления рекомендуется перестроить возможно поврежденные индексы.

Если во время автоматического обновления поврежденные индексы будут выявлены, процесс обновления СУБД не блокируется, выводится предупреждение:

"{{ control_name }}.WARNING__W05002: Реиндекс после обновления не будет произведен в соответствии с значением reindexdb_after_pgupgrade: {} в кастомном конфигурационном файле. \ В связи с проблемой ядер PostgreSQL до 15.6, индекс GIN при одновременных изменениях мог быть поврежден. \ После обновления рекомендуем перестроить все GIN индексы вручную.__{{ control_name }}.WARNING"

При указании флага reindexdb_after_pgupgrade пользователю все равно выдается рекомендация произвести дополнительную операцию реиндекса всех GIN-индексов.