DbMpool::sync

#include <db_cxx.h>

int
DbMpool::sync(LSN *lsn);

Description

The DbMpool::sync method ensures that all the modified pages in the pool
with log sequence numbers (i.e., DbLsn objects) less than the
lsn argument are written to disk.

The DbMpool::sync
method either returns errno or throws an exception that
encapsulates an errno on failure, and 0 on success,
and DB_INCOMPLETE if there were pages which need to be written but which
DbMpool::sync was unable to write immediately.
In addition, if DbMpool::sync returns success, the value of
lsn will be overwritten with the largest LSN from any page which
was written by DbMpool::sync to satisfy this request.

The purpose of the DbMpool::sync function is to enable a
transaction manager to ensure, as part of a checkpoint, that all pages
modified by a certain time have been written to disk.
Pages in the pool which cannot be written back to disk immediately (e.g.,
are currently pinned) are written to disk as soon as it is possible to do so.
The expected behavior of the transaction manager is to call the
DbMpool::sync function and then, if the return indicates that
some pages could not be written immediately, to wait briefly and retry
again with the same LSN until the DbMpool::sync function returns
that all pages have been written.

To support the DbMpool::sync functionality, it is necessary that the
pool functions know the location of the LSN on the page for each file type.
This location should be specified when the file is opened using the
DbMpoolFile::open function.
(Note, it is not required that the LSN be aligned on the page in any way.)

Errors

If a fatal error occurs in Berkeley DB, the DbMpool::sync method may fail and either
return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY,
at which point all subsequent database calls will also fail in the same
way. Methods marked as returning errno will, by default, throw
an exception that encapsulates the error information. The default error
behavior can be changed, see DbException.