File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,15 @@ tsl_compact_chunk(PG_FUNCTION_ARGS)
257257
258258 ts_feature_flag_check (FEATURE_HYPERTABLE_COMPRESSION );
259259 TS_PREVENT_FUNC_IF_READ_ONLY ();
260+
261+ if (IsolationUsesXactSnapshot ())
262+ {
263+ ereport (ERROR ,
264+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
265+ errmsg ("compact_chunk is not supported in REPEATABLE READ or SERIALIZABLE "
266+ "isolation level" )));
267+ }
268+
260269 Chunk * chunk = ts_chunk_get_by_relid (uncompressed_relid , true);
261270
262271 ts_hypertable_permissions_check (chunk -> hypertable_relid , GetUserId ());
Original file line number Diff line number Diff line change @@ -178,6 +178,13 @@ SELECT _timescaledb_functions.compact_chunk(chunk) FROM show_chunks('metrics') c
178178ERROR: cannot execute compact_chunk() in a read-only transaction
179179\set ON_ERROR_STOP 1
180180SET default_transaction_read_only TO off;
181+ -- compact_chunk in REPEATABLE READ must fail
182+ \set ON_ERROR_STOP 0
183+ BEGIN ISOLATION LEVEL REPEATABLE READ;
184+ SELECT _timescaledb_functions.compact_chunk(chunk) FROM show_chunks('metrics') chunk;
185+ ERROR: compact_chunk is not supported in REPEATABLE READ or SERIALIZABLE isolation level
186+ COMMIT;
187+ \set ON_ERROR_STOP 1
181188-- Create a hypertable with a segmentby column.
182189-- Each segment ('d1', 'd2') will have its own set of batches, and
183190-- compact_chunk should handle overlaps per segment independently.
Original file line number Diff line number Diff line change @@ -136,6 +136,13 @@ SELECT _timescaledb_functions.compact_chunk(chunk) FROM show_chunks('metrics') c
136136
137137SET default_transaction_read_only TO off;
138138
139+ -- compact_chunk in REPEATABLE READ must fail
140+ \set ON_ERROR_STOP 0
141+ BEGIN ISOLATION LEVEL REPEATABLE READ;
142+ SELECT _timescaledb_functions .compact_chunk (chunk) FROM show_chunks(' metrics' ) chunk;
143+ COMMIT ;
144+ \set ON_ERROR_STOP 1
145+
139146-- Create a hypertable with a segmentby column.
140147-- Each segment ('d1', 'd2') will have its own set of batches, and
141148-- compact_chunk should handle overlaps per segment independently.
You can’t perform that action at this time.
0 commit comments