Berkeley DB: DB_ENV->memp_sync
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++

# DB_ENV->memp_sync |

`

###

    #include <db.h>

    int
    DB_ENV->memp_sync(DB_ENV *env, DB_LSN *lsn);

# Description

The DB_ENV->memp_sync function ensures that any modified pages in the pool with a log sequence number (DB_LSN) less than the lsn argument are written to disk. If lsn is NULL, all modified pages in the pool are flushed.

The primary purpose of the DB_ENV->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 that cannot be written back to disk immediately (for example, pages that are currently pinned) are written to disk as soon as it is possible to do so. The expected behavior of the Berkeley DB or other Transaction subsystem is to call the DB_ENV->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 log sequence number until the DB_ENV->memp_sync function returns that all pages have been written.

To support the DB_ENV->memp_sync functionality, it is necessary that the pool functions know the location of the log sequence number on the page for each file type. This location should be specified when the file is opened using the DB_MPOOLFILE->set_lsn_offset function. It is not required that the log sequence number be aligned on the page in any way.

The DB_ENV->memp_sync function returns a non-zero error value on failure, 0 on success, and returns DB_INCOMPLETE if there were pages which need to be written but that DB_ENV->memp_sync was unable to write immediately. In addition, if DB_ENV->memp_sync returns success, the value of lsn will be overwritten with the largest log sequence number from any page that was written by DB_ENV->memp_sync to satisfy this request.

# Errors

The DB_ENV->memp_sync function may fail and return a non-zero error for the following conditions:

EINVAL
  An invalid flag value or parameter was specified.

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

The DB_ENV->memp_sync function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. If a catastrophic error has occurred, the DB_ENV->memp_sync function may fail and return DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.

# See Also

DB_ENV->set_cachesize, DB_ENV->set_mp_mmapsize, DB_ENV->memp_fcreate, DB_MPOOLFILE->close, DB_MPOOLFILE->get, DB_MPOOLFILE->open, DB_MPOOLFILE->put, DB_MPOOLFILE->set, DB_MPOOLFILE->sync, DB_ENV->memp_register, DB_MPOOLFILE->set_clear_len, DB_MPOOLFILE->set_fileid, DB_MPOOLFILE->set_ftype, DB_MPOOLFILE->set_lsn_offset, DB_MPOOLFILE->set_pgcookie, DB_ENV->memp_stat, DB_ENV->memp_sync, and DB_ENV->memp_trickle.`

Copyright Sleepycat Software