Berkeley DB: memp_sync
Google

ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++">

memp_sync


#include <db.h>

int memp_sync(DB_MPOOL *mp, LSN *lsn);

Description

The memp_sync function ensures that all the modified pages in the pool with log sequence numbers (i.e., DB_LSN structures) less than the lsn argument are written to disk.

The memp_sync function returns the value of errno on failure, 0 on success, and DB_INCOMPLETE if there were pages which need to be written but which memp_sync was unable to write immediately. In addition, if memp_sync returns success, the value of lsn will be overwritten with the largest LSN from any page which was written by memp_sync to satisfy this request.

The purpose of the memp_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 memp_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 memp_sync function returns that all pages have been written.

To support the memp_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 memp_fopen 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 memp_sync function may fail and return DB_RUNRECOVERY, at which point all subsequent database calls will also return DB_RUNRECOVERY.

The memp_sync function may fail and return errno 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), log_compare, log_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 memp_sync function may fail and return errno for the following conditions:

EINVAL
An invalid flag value or parameter was specified.

The memp_sync function was called without logging having been initialized in the environment.

See Also

memp_close, memp_fclose, memp_fget, memp_fopen, memp_fput, memp_fset, memp_fsync, memp_open, memp_register, memp_stat, memp_stat, memp_sync, memp_trickle and memp_unlink.