|
98 | 98 | IF compression_job_id IS NULL THEN |
99 | 99 | old_time = NULL::timestamptz; |
100 | 100 | ELSE |
101 | | - SELECT next_start INTO old_time FROM _timescaledb_internal.bgw_job_stat WHERE job_id = compression_job_id; |
| 101 | + SELECT next_start INTO old_time FROM _timescaledb_internal.bgw_job_stat WHERE job_id = compression_job_id FOR UPDATE; |
102 | 102 |
|
103 | 103 | IF version = 1 THEN |
104 | 104 | PERFORM alter_job_schedule(compression_job_id, next_start=> new_time); |
@@ -171,6 +171,7 @@ BEGIN |
171 | 171 | -- Push the compression job out for some period of time so we don't end up compressing a decompressed chunk |
172 | 172 | -- Don't disable completely because at least then if we fail and fail to move it back things won't get completely weird |
173 | 173 | SELECT move_compression_job(hypertable_row.id, hypertable_row.schema_name, hypertable_row.table_name, now() + compression_job_push_interval) INTO old_compression_job_time; |
| 174 | + COMMIT; |
174 | 175 |
|
175 | 176 | --Get the min and max times in timescale internal format from the source table, this will tell us which chunks we need to decompress |
176 | 177 | EXECUTE FORMAT($$SELECT _timescaledb_internal.time_to_internal(min(%1$I)) , |
@@ -284,9 +285,10 @@ BEGIN |
284 | 285 | GET DIAGNOSTICS affected = ROW_COUNT; |
285 | 286 | RAISE NOTICE '% rows moved in range % to %', affected, r_start, r_end ; |
286 | 287 | COMMIT; |
287 | | ---Move our job back to where it was |
288 | | -SELECT move_compression_job(hypertable_row.id, hypertable_row.schema_name, hypertable_row.table_name, old_compression_job_time) INTO old_compression_job_time; |
289 | | -COMMIT; |
| 288 | + |
| 289 | + --Move our job back to where it was |
| 290 | + SELECT move_compression_job(hypertable_row.id, hypertable_row.schema_name, hypertable_row.table_name, old_compression_job_time) INTO old_compression_job_time; |
| 291 | + COMMIT; |
290 | 292 | END; |
291 | 293 |
|
292 | 294 | $proc$ |
|
0 commit comments