#include <db_cxx.h>int DbMpool::sync(LSN *lsn);
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.)
The DbMpool::sync method may fail and throw an exception for any of the errors specified for the following Berkeley DB and C library functions: DBmemp->pgin(3), DBmemp->pgout(3), abort(3), close(3), dbenv->db_paniccall(3), fcntl(3), fflush(3), fprintf(3), free(3), fstat(3), fsync(3), getenv(3), getpid(3), getuid(3), isdigit(3), DbLog::compare, DbLog::flush, lseek(3), malloc(3), memcmp(3), memcpy(3), memset(3), mmap(3), open(3), pread(3), pstat_getdynamic(3), pwrite(3), qsort(3), read(3), realloc(3), sigfillset(3), sigprocmask(3), stat(3), strerror(3), strlen(3), sysconf(3), time(3), unlink(3), vfprintf(3), vsnprintf(3), and write(3). In addition, the DbMpool::sync method may fail and throw an exception or return errno for the following conditions:
The DbMpool::sync function was called without logging having been initialized in the environment.