pg_repack
is a well-known tool to perform online cluster or vacuum on one or
more target tables without locking them for concurrent readers and writers.
Below is the description of its inner working obtained by reading the source
code; it is followed by the risk assessment.
Process