Commits

Anonymous committed cd7569a

dummy commit

Comments (0)

Files changed (4)

contrib/pg_upgrade/pg_upgrade.c

 			  new_cluster.pgdata);
 	check_ok();
 
+	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();
+
 	create_script_for_cluster_analyze(&analyze_script_file_name);
 	create_script_for_old_cluster_deletion(&deletion_script_file_name);
 

contrib/pg_upgrade/server.c

 	 * a gap of 2000000000 from the current xid counter, so autovacuum will
 	 * not touch them.
 	 *
-	 *	synchronous_commit=off improves 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.
+	 * 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.
 	 */
 	snprintf(cmd, sizeof(cmd),
 			 "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" -o \"-p %d%s%s%s%s\" start",
 			 (cluster->controldata.cat_ver >=
 			  BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? " -b" :
 			 " -c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
-			 (cluster == &new_cluster) ? " -c synchronous_commit=off" : "",
+			 (cluster == &new_cluster) ?
+				" -c synchronous_commit=off -c fsync=off -c full_page_writes=off" : "",
 			 cluster->pgopts ? cluster->pgopts : "", socket_string);
 
 	/*

doc/src/sgml/ref/initdb.sgml

      </varlistentry>
 
      <varlistentry>
+      <term><option>-S</option></term>
+      <term><option>--sync-only</option></term>
+      <listitem>
+       <para>
+        Safely write all database files to disk and exit.  This does not
+        perform any of the normal <application>initdb</> operations.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><option>-T <replaceable>CFG</></option></term>
       <term><option>--text-search-config=<replaceable>CFG</></option></term>
       <listitem>

src/bin/initdb/initdb.c

 static bool debug = false;
 static bool noclean = false;
 static bool do_sync = true;
+static bool sync_only = false;
 static bool show_setting = false;
 static char *xlog_dir = "";
 
 	printf(_("  -n, --noclean             do not clean up after errors\n"));
 	printf(_("  -N, --nosync              do not wait for changes to be written safely to disk\n"));
 	printf(_("  -s, --show                show internal settings\n"));
+	printf(_("  -S, --sync-only           only sync data directory\n"));
 	printf(_("\nOther options:\n"));
 	printf(_("  -V, --version             output version information, then exit\n"));
 	printf(_("  -?, --help                show this help, then exit\n"));
 		{"show", no_argument, NULL, 's'},
 		{"noclean", no_argument, NULL, 'n'},
 		{"nosync", no_argument, NULL, 'N'},
+		{"sync-only", no_argument, NULL, 'S'},
 		{"xlogdir", required_argument, NULL, 'X'},
 		{NULL, 0, NULL, 0}
 	};
 
 	/* process command-line options */
 
-	while ((c = getopt_long(argc, argv, "dD:E:L:nNU:WA:sT:X:", long_options, &option_index)) != -1)
+	while ((c = getopt_long(argc, argv, "dD:E:L:nNU:WA:sST:X:", long_options, &option_index)) != -1)
 	{
 		switch (c)
 		{
 			case 'N':
 				do_sync = false;
 				break;
+			case 'S':
+				sync_only = true;
+				break;
 			case 'L':
 				share_path = pg_strdup(optarg);
 				break;
 		exit(1);
 	}
 
+	/* If we only need to fsync, just to it and exit */
+	if (sync_only)
+	{
+		setup_pgdata();
+		perform_fsync();
+		return 0;
+	}
+	
 	if (pwprompt && pwfilename)
 	{
 		fprintf(stderr, _("%s: password prompt and password file cannot be specified together\n"), progname);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.