Skip to content

Commit 8b16c8f

Browse files
committed
Merge branch 'PGPROEE9_6_CFS' into PGPROEE9_6
2 parents c357e30 + 94e921b commit 8b16c8f

File tree

9 files changed

+438
-88
lines changed

9 files changed

+438
-88
lines changed

doc/src/sgml/cfs.sgml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,36 @@
296296
This function takes first ten blocks of relation and tries to compress them ands returns average compress ratio.
297297
So if returned value is 7.8 then compressed table occupies about eight time less space than original table.
298298
</para>
299-
299+
300+
<para>
301+
Function <varname>cfs_compression_ratio(relation)</varname> allows to check how precise was estimation of
302+
<varname>cfs_estimate(relation)</varname> function. It returns real compression ration for all segments of the compressed
303+
relation. Compression ration is total sum of virtual size of all relation segments (number of blocks multiplied by 8kb) divided
304+
by sum of physical size of the segment files.
305+
</para>
306+
307+
<para>
308+
As it was mentioned before, CFS always appends updated blocks to the end of the compressed file. So physical size of the file
309+
can be greater than used size in this file. I.e. CFS file is fragmented and defragmentation is periodically performed by CFS
310+
garbage collector. <varname>cfs_fragmentation(relation)</varname> functions returns average fragmentation of relation files.
311+
It is calculated as sum of physical sizes of the files minus sum of used size of the files divided by sum of physical sizes of the files.
312+
</para>
313+
314+
<para>
315+
Particular relation can be defragmented using <varname>cfs_gc_relation(relation)</varname> function.
316+
This function can be used only if there are no active GC workers (<varname>cfs_gc_workers</varname> equals to zero).
317+
It returns number of defragmented segments of relation. If there is on relation with such OID or it is not compressed
318+
or some other GC process is active, 0 is returned.
319+
</para>
320+
321+
<para>
322+
There are several functions allowing to monitors garbage collection activity:
323+
<varname>cfs_gc_activity_scanned_files</varname> returns number of files scanned by GC,
324+
<varname>cfs_gc_activity_processed_files</varname> returns number of file compacted by GC,
325+
<varname>cfs_gc_activity_processed_pages</varname> returns number of pages transferred by GC during files defragmentation,
326+
<varname>cfs_gc_activity_processed_bytes</varname> returns total size of transferred pages.
327+
All this functions calculate their values since system start.
328+
</para>
329+
300330
</sect1>
301331
</chapter>

src/backend/access/transam/xlog.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "storage/barrier.h"
5656
#include "storage/bufmgr.h"
5757
#include "storage/fd.h"
58+
#include "storage/cfs.h"
5859
#include "storage/ipc.h"
5960
#include "storage/large_object.h"
6061
#include "storage/latch.h"
@@ -122,6 +123,7 @@ int CheckPointSegments;
122123
/* Estimated distance between checkpoints, in bytes */
123124
static double CheckPointDistanceEstimate = 0;
124125
static double PrevCheckPointDistance = 0;
126+
static bool SavedGCState = false;
125127

126128
/*
127129
* GUC support
@@ -9905,6 +9907,8 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
99059907
XLogCtl->Insert.forcePageWrites = true;
99069908
WALInsertLockRelease();
99079909

9910+
SavedGCState = cfs_control_gc(false); /* disable GC during backup */
9911+
99089912
/* Ensure we release forcePageWrites if fail below */
99099913
PG_ENSURE_ERROR_CLEANUP(pg_start_backup_callback, (Datum) BoolGetDatum(exclusive));
99109914
{
@@ -10267,6 +10271,8 @@ pg_start_backup_callback(int code, Datum arg)
1026710271
XLogCtl->Insert.forcePageWrites = false;
1026810272
}
1026910273
WALInsertLockRelease();
10274+
10275+
cfs_control_gc(SavedGCState); /* Restore CFS GC activity */
1027010276
}
1027110277

1027210278
/*
@@ -10627,6 +10633,8 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
1062710633
ereport(NOTICE,
1062810634
(errmsg("WAL archiving is not enabled; you must ensure that all required WAL segments are copied through other means to complete the backup")));
1062910635

10636+
cfs_control_gc(SavedGCState); /* Restore CFS GC activity */
10637+
1063010638
/*
1063110639
* We're done. As a convenience, return the ending WAL location.
1063210640
*/

0 commit comments

Comments
 (0)