MCPcopy Create free account
hub / github.com/apache/cloudberry / SyncPostCheckpoint

Function SyncPostCheckpoint

src/backend/storage/sync/sync.c:220–299  ·  view source on GitHub ↗

* SyncPostCheckpoint() -- Do post-checkpoint work * * Remove any lingering files that can now be safely removed. */

Source from the content-addressed store, hash-verified

218 * Remove any lingering files that can now be safely removed.
219 */
220void
221SyncPostCheckpoint(void)
222{
223 int absorb_counter;
224 ListCell *lc;
225
226 absorb_counter = UNLINKS_PER_ABSORB;
227 foreach(lc, pendingUnlinks)
228 {
229 PendingUnlinkEntry *entry = (PendingUnlinkEntry *) lfirst(lc);
230 char path[MAXPGPATH];
231
232 /* Skip over any canceled entries */
233 if (entry->canceled)
234 continue;
235
236 /*
237 * New entries are appended to the end, so if the entry is new we've
238 * reached the end of old entries.
239 *
240 * Note: if just the right number of consecutive checkpoints fail, we
241 * could be fooled here by cycle_ctr wraparound. However, the only
242 * consequence is that we'd delay unlinking for one more checkpoint,
243 * which is perfectly tolerable.
244 */
245 if (entry->cycle_ctr == checkpoint_cycle_ctr)
246 break;
247
248 /* Unlink the file */
249 if (syncsw[entry->tag.handler].sync_unlinkfiletag(&entry->tag,
250 path) < 0)
251 {
252 /*
253 * There's a race condition, when the database is dropped at the
254 * same time that we process the pending unlink requests. If the
255 * DROP DATABASE deletes the file before we do, we will get ENOENT
256 * here. rmtree() also has to ignore ENOENT errors, to deal with
257 * the possibility that we delete the file first.
258 */
259 if (errno != ENOENT)
260 ereport(WARNING,
261 (errcode_for_file_access(),
262 errmsg("could not remove file \"%s\": %m", path)));
263 }
264
265 /* Mark the list entry as canceled, just in case */
266 entry->canceled = true;
267
268 /*
269 * As in ProcessSyncRequests, we don't want to stop absorbing fsync
270 * requests for a long time when there are many deletions to be done.
271 * We can safely call AbsorbSyncRequests() at this point in the loop.
272 */
273 if (--absorb_counter <= 0)
274 {
275 AbsorbSyncRequests();
276 absorb_counter = UNLINKS_PER_ABSORB;
277 }

Callers 1

CreateCheckPointFunction · 0.85

Calls 9

AbsorbSyncRequestsFunction · 0.85
list_free_deepFunction · 0.85
list_cell_numberFunction · 0.85
list_nthFunction · 0.85
list_delete_first_nFunction · 0.85
foreachFunction · 0.50
errcode_for_file_accessFunction · 0.50
errmsgFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected