X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A23B8D1D362; Sun, 30 Nov 2003 22:30:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 94701-03; Sun, 30 Nov 2003 18:30:12 -0400 (AST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id CDE01D1C976; Sun, 30 Nov 2003 18:30:08 -0400 (AST) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1AQa4w-0007Qu-0Z; Sun, 30 Nov 2003 22:30:10 +0000 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.24) id 1AQa4r-0005zB-3I; Sun, 30 Nov 2003 22:30:05 +0000 Subject: initdb should create a warning message [was Re: [ADMIN] Size on Disk] From: Oliver Elphick To: Tom Lane Cc: pgsql-hackers@postgresql.org, pgsql-docs@postgresql.org In-Reply-To: <11414.1069826007@sss.pgh.pa.us> References: <20031126043752.51857.qmail@web10804.mail.yahoo.com> <11414.1069826007@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="=-TnyGj7EMiGXg2E9NjKBH" Organization: LFIX Limited Message-Id: <1070231374.7719.2654.camel@linda.lfix.co.uk> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 30 Nov 2003 22:29:35 +0000 X-LFIX-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/83 X-Sequence-Number: 2160 --=-TnyGj7EMiGXg2E9NjKBH Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, 2003-11-26 at 05:53, Tom Lane wrote: > Grzegorz Dostatni writes: > > Currently the datase is roughly 80 Megs. About half of > > the size is stored in pg_xlog directory. I managed to > > figure out that those files are transaction log files? > > How can I delete them safely? > > You can NOT. Don't even think about going there. > > What you can do, if you intend only low-update-volume usage, > is reduce checkpoint_segments to reduce the number of WAL files > the system wants to keep around. The use of the word "log" in the directory name does tend to invite this error, and some have acted on it without asking first. I think initdb should put a README.IMPORTANT file in $PGDATA to say, pg_xlog and pg_clog are crucial to the preservation of your data. They do not contain standard log files. Do not even think about deleting them to save space; you would destroy your database. The cost is only one disk block per cluster, and it might deflect some of the weaponry pointed at hapless feet... Patch for initdb.c attached I notice that pg_clog and pg_xlog are not mentioned in the index to the documentation, which makes it more difficult for people to find out what they are. I therefore also attach a doc patch to add index entries for those two files. -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Who shall ascend into the hill of the LORD? or who shall stand in his holy place? He that hath clean hands, and a pure heart..." Psalms 24:3,4 --=-TnyGj7EMiGXg2E9NjKBH Content-Description: Patch to have initdb write a warning README file in $PGDATA Content-Disposition: inline; filename=initdb.patch Content-Type: text/x-patch; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Index: src/bin/initdb/initdb.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v retrieving revision 1.15 diff -c -r1.15 initdb.c *** src/bin/initdb/initdb.c 29 Nov 2003 19:52:04 -0000 1.15 --- src/bin/initdb/initdb.c 30 Nov 2003 21:52:47 -0000 *************** *** 179,184 **** --- 179,185 ---- static int set_paths(void); static char **replace_token(char **, char *, char *); static void set_short_version(char *, char *); + static void set_warning_file(void); static void set_null_conf(void); static void test_buffers(void); static void test_connections(void); *************** *** 1064,1069 **** --- 1065,1088 ---- } /* + * write out the warning file in the data dir; this is to try to ensure + * that users don't delete pg_xlog in the belief that it is "just" a log + * file + */ + static void + set_warning_file(void) + { + FILE *warning_file; + char *path; + + path = xmalloc(strlen(pg_data) + 20); + sprintf(path, "%s/README.IMPORTANT", pg_data); + warning_file = fopen(path, PG_BINARY_W); + fprintf(warning_file, "pg_xlog and pg_clog are crucial to the preservation of your\ndata. They do not contain standard log files. Do not even think\nabout deleting them to save space; you would destroy your\ndatabase.\n"); + fclose(warning_file); + } + + /* * set up an empty config file so we can check buffers and connections */ static void *************** *** 2427,2432 **** --- 2446,2454 ---- /* Top level PG_VERSION is checked by bootstrapper, so make it first */ set_short_version(short_version, NULL); + + /* Write the warning file - a warning not to delete pg_xlog! */ + set_warning_file(); /* * Determine platform-specific config settings --=-TnyGj7EMiGXg2E9NjKBH Content-Description: Doc patch to add index terms for pg_clog and pg_xlog Content-Disposition: inline; filename=pg_xlog.doc.patch Content-Type: text/x-patch; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Index: doc/src/sgml/backup.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/backup.sgml,v retrieving revision 2.32 diff -c -r2.32 backup.sgml *** doc/src/sgml/backup.sgml 29 Nov 2003 19:51:36 -0000 2.32 --- doc/src/sgml/backup.sgml 30 Nov 2003 22:22:35 -0000 *************** *** 342,347 **** --- 342,350 ---- + + pg_clog + If you have dug into the details of the file system layout of the data you may be tempted to try to back up or restore only certain individual tables or databases from their respective files or Index: doc/src/sgml/wal.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/wal.sgml,v retrieving revision 1.26 diff -c -r1.26 wal.sgml *** doc/src/sgml/wal.sgml 29 Nov 2003 19:51:38 -0000 1.26 --- doc/src/sgml/wal.sgml 30 Nov 2003 22:22:35 -0000 *************** *** 83,88 **** --- 83,92 ---- Future Benefits + + pg_clog + + The UNDO operation is not implemented. This means that changes made by aborted transactions will still occupy disk space and that a permanent pg_clog file to hold *************** *** 283,288 **** --- 287,295 ---- + + pg_xlog + WAL logs are stored in the directory pg_xlog under the data directory, as a set of segment files, each 16 MB in size. Each segment is divided into 8 Index: doc/src/sgml/ref/pg_resetxlog.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/pg_resetxlog.sgml,v retrieving revision 1.8 diff -c -r1.8 pg_resetxlog.sgml *** doc/src/sgml/ref/pg_resetxlog.sgml 29 Nov 2003 19:51:39 -0000 1.8 --- doc/src/sgml/ref/pg_resetxlog.sgml 30 Nov 2003 22:22:35 -0000 *************** *** 73,78 **** --- 73,84 ---- + + pg_clog + + + pg_xlog + The -o, -x, and -l switches allow the next OID, next transaction ID, and WAL starting address values to be set manually. These are only needed when --=-TnyGj7EMiGXg2E9NjKBH--