PostgreSQL 9.3 initdb add -S only do fsync used with pg_upgrade when server set fsync from off to on

简介:
Add initdb --sync-only option to sync the data directory to durable
storage.
Have pg_upgrade use it, and enable server options fsync=off and
full_page_writes=off.
Document that users turning fsync from off to on should run initdb
--sync-only.

initdb -S选项目前仅仅被pg_upgrade用于fsync数据库集群目录, 因为pg_upgrade使用了fsync=off来加速升级过程.
然后在数据库集群起来之前会修改为fsync=on, 这个过程之间必须要将kernel或文件系统cache中的脏块写入持久化存储中.
所以就有了initdb -S这个选项, 用来做fsync的事情.
initdb src:
+   /* If we only need to fsync, just to it and exit */
+   if (sync_only)
+   {
+       setup_pgdata();
+       perform_fsync();
+       return 0;
+   }

contrib/pg_upgrade/server.c
+    * Turn off durability requirements to improve object creation speed, and
+    * we only modify the new cluster, so only use it there.  If there is a
+    * crash, the new cluster has to be recreated anyway.  fsync=off is a big
+    * win on ext4.

+            (cluster == &new_cluster) ?
+               " -c synchronous_commit=off -c fsync=off -c full_page_writes=off" : "",

contrib/pg_upgrade/pg_upgrade.c
+   prep_status("Sync data directory to disk");
+   exec_prog(UTILITY_LOG_FILE, NULL, true,
+             "\"%s/initdb\" --sync-only \"%s\"", new_cluster.bindir,
+             new_cluster.pgdata);
+   check_ok();

doc/src/sgml/config.sgml
+        For reliable recovery when changing <varname>fsync</varname>
+        off to on, it is necessary to force all modified buffers in the
+        kernel to durable storage.  This can be done while the cluster
+        is shutdown or while fsync is on by running <command>initdb
+        --sync-only</command>, running <command>sync</>, unmounting the
+        file system, or rebooting the server.

doc/src/sgml/ref/initdb.sgml
+        Safely write all database files to disk and exit.  This does not
+        perform any of the normal <application>initdb</> operations.


[参考]
2. man initdb
       -S, --sync-only
           Safely write all database files to disk and exit. This does not perform any of the normal initdb
           operations.

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
SQL Oracle 关系型数据库
实时计算 Flink版操作报错之往GREENPLUM 6 写数据,用postgresql-42.2.9.jar 报 ON CONFLICT (uuid) DO UPDATE SET 语法有问题。怎么解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
关系型数据库 MySQL
mysqldump unknown variable ‘set-gtid-purged=off‘ workbench
mysqldump unknown variable ‘set-gtid-purged=off‘ workbench
673 1
|
数据采集 SQL DataWorks
DataWorks操作报错合集之在DataWorks中出现"Please submit specific code instead of only 'set' or 'use'"这样的异常提示,该怎么处理
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
467 0
|
SQL 存储 Oracle
PostgreSQL 分页, offset, 返回顺序, 扫描方法原理(seqscan, index scan, index only scan, bitmap scan, parallel xx scan),游标
PostgreSQL 分页, offset, 返回顺序, 扫描方法原理(seqscan, index scan, index only scan, bitmap scan, parallel xx scan),游标
4083 0
|
关系型数据库 PostgreSQL
PostgreSQL 的哪些参数不能通过ALTER SYSTEM SET 修改
在 PostgreSQL 中,有一些参数是不能通过 `ALTER SYSTEM SET` 语句进行动态修改的,这些参数通常需要在 PostgreSQL 的配置文件中进行手动修改。以下是一些不能通过 `ALTER SYSTEM SET` 修改的常见参数: 1. **track_activities** 2. **track_counts** 3. **track_io_timing** 4. **track_functions** 5. **track_activity_query_size** 6. **track_commit_timestamp** 7. **shared_preload
382 0
|
关系型数据库 MySQL Java
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
4925 1
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
|
关系型数据库 MySQL Go
idea连接mysql数据库遇到Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ 。。。。。
idea连接mysql数据库遇到Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ 。。。。。错误显示及解决办法。
idea连接mysql数据库遇到Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ 。。。。。
|
关系型数据库 MySQL 数据库
DataGrip 2020.1连接数据库报错 Server returns invalid timezone. Need to set‘serverTimezone’property
DataGrip 2020.1连接数据库报错 Server returns invalid timezone. Need to set‘serverTimezone’property
424 0
DataGrip 2020.1连接数据库报错 Server returns invalid timezone. Need to set‘serverTimezone’property

推荐镜像

更多