*I%Berkeley DB: memp_sync[P

memp_sync





#include <db.h>

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





Description



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

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

4The purpose of the memp_sync function is to enable aFtransaction manager to ensure, as part of a checkpoint, that all pages5modified by a certain time have been written to disk.IPages in the pool which cannot be written back to disk immediately (e.g.,Mare 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 the9memp_sync function and then, if the return indicates thatFsome 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 theKpool functions know the location of the LSN on the page for each file type.CThis location should be specified when the file is opened using theDmemp_fopen function.J(Note, it is not required that the LSN be aligned on the page in any way.)



Errors

RIf a fatal error occurs in Berkeley DB, the memp_sync function may fail and returnFDB_RUNRECOVERY, at which point all subsequent database calls will alsoreturn DB_RUNRECOVERY.

The memp_sync)function may fail and return errnoKfor 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),9log_compare,5log_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 errnofor the following conditions:

B

EINVAL
An invalid flag value or parameter was specified.

=The memp_sync function was called without logging having beeninitialized in the environment.





See Also

8memp_close,=memp_fclose,9memp_fget,;memp_fopen,9memp_fput,9memp_fset,;memp_fsync,6memp_open,Amemp_register,6memp_stat,6memp_stat, memp_sync,;memp_trickleand:memp_unlink.
ÿÿ