MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / beginBackup

Method beginBackup

src/jrd/nbak.cpp:249–366  ·  view source on GitHub ↗

Initialize and open difference file for writing

Source from the content-addressed store, hash-verified

247
248// Initialize and open difference file for writing
249void BackupManager::beginBackup(thread_db* tdbb)
250{
251 NBAK_TRACE(("beginBackup"));
252
253 SET_TDBB(tdbb);
254
255 // Check for raw device
256 if ((!explicit_diff_name) && database->onRawDevice()) {
257 ERR_post(Arg::Gds(isc_need_difference));
258 }
259
260 MasterGuard masterGuard(*this);
261
262 WIN window(HEADER_PAGE_NUMBER);
263
264 StateWriteGuard stateGuard(tdbb, &window);
265 Ods::header_page* header = (Ods::header_page*) window.win_buffer;
266
267 // Check state
268 if (backup_state != Ods::hdr_nbak_normal)
269 {
270 NBAK_TRACE(("begin backup - invalid state %d", backup_state));
271 stateGuard.setSuccess();
272 return;
273 }
274
275 // Check crypt state
276 if (header->hdr_flags & Ods::hdr_crypt_process)
277 {
278 NBAK_TRACE(("begin backup - crypt thread runs"));
279 stateGuard.setSuccess();
280 ERR_post(Arg::Gds(isc_wish_list) << Arg::Gds(isc_random) <<
281 "Cannot begin backup: please wait for crypt thread completion");
282 }
283
284 try
285 {
286 // Create file
287 NBAK_TRACE(("Creating difference file %s", diff_name.c_str()));
288 diff_file = PIO_create(tdbb, diff_name, true, false);
289 }
290 catch (const Firebird::Exception&)
291 {
292 // no reasons to set it to unknown if we just failed to create difference file
293 stateGuard.setSuccess();
294 backup_state = Ods::hdr_nbak_normal;
295 throw;
296 }
297
298 { // logical scope
299 if (database->dbb_flags & (DBB_force_write | DBB_no_fs_cache))
300 {
301 setForcedWrites(database->dbb_flags & DBB_force_write,
302 database->dbb_flags & DBB_no_fs_cache);
303 }
304
305#ifdef UNIX
306 // adjust difference file access rights to make it match main DB ones

Callers

nothing calls this directly

Calls 15

SET_TDBBFunction · 0.85
GdsClass · 0.85
PIO_createFunction · 0.85
fstatFunction · 0.85
raiseFunction · 0.85
ERR_puntFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
PAG_replace_entry_firstFunction · 0.85
REPL_journal_switchFunction · 0.85
setSuccessMethod · 0.80
findPageSpaceMethod · 0.80
releaseHeaderMethod · 0.80

Tested by

no test coverage detected