⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intro.so

📁 berkeley db 4.6.21的源码。berkeley db是一个简单的数据库管理系统
💻 SO
字号:
m4_comment([$Id: intro.so,v 10.53 2006/11/13 18:04:59 bostic Exp $])m4_ref_title(Application Specific Logging and Recovery,    Introduction to application specific logging and recovery,,    xa/faq, apprec/def)m4_p([dnlIt is possible to use the Locking, Logging and Transaction subsystemsof m4_db to provide transaction semantics on objects other than thosedescribed by the m4_db access methods.  In these cases, the applicationwill need application-specific logging and recovery functions.])m4_p([dnlFor example, consider an application that provides transaction semanticson data stored in plain text files accessed using the POSIX read andwrite system calls.  The read and write operations for which transactionprotection is desired will be bracketed by calls to the standard m4_dbtransactional interfaces, m4_ref(txn_begin) and m4_ref(txn_commit), andthe transaction's locker ID will be used to acquire relevant read andwrite locks.])m4_p([dnlBefore data is accessed, the application must make a call to the lockmanager, m4_ref(lock_get), for a lock of the appropriate type (forexample, read) on the object being locked.  The object might be a pagein the file, a byte, a range of bytes, or some key.  It is up to theapplication to ensure that appropriate locks are acquired.  Before awrite is performed, the application should acquire a write lock on theobject by making an appropriate call to the lock manager,m4_ref(lock_get).  Then, the application should make a call to the logmanager, via the automatically-generated log-writing function describedas follows.  This record should contain enough information to redo theoperation in case of failure after commit and to undo the operation incase of abort.])m4_p([dnlWhen designing applications that will use the log subsystem, it isimportant to remember that the application is responsible for providingany necessary structure to the log record.  For example, the applicationmust understand what part of the log record is an operation code, whatpart identifies the file being modified, what part is redo information,and what part is undo information.])m4_p([dnlAfter the log message is written, the application may issue the writesystem call.  After all requests are issued, the application may callm4_ref(txn_commit).  When m4_ref(txn_commit) returns, the caller isguaranteed that all necessary log writes have been written to disk.])m4_p([dnlAt any time before issuing a m4_ref(txn_commit), the application maycall m4_ref(txn_abort), which will result in restoration of the databaseto a consistent pretransaction state.  (The application may specify itsown recovery function for this purpose using them4_refT(dbenv_set_app_dispatch).  The recovery function must be able toeither reapply or undo the update depending on the context, for eachdifferent type of log record. The recovery functions must not use m4_dbmethods to access data in the environment as there is no way tocoordinate these accesses with either the aborting transaction or theupdates done by recovery or replication.)])m4_p([dnlIf the application crashes, the recovery process uses the log to restorethe database to a consistent state.])m4_p([dnlm4_db includes tools to assist in the development of application-specificlogging and recovery.  Specifically, given a description of informationto be logged in a family of log records, these tools will automaticallycreate log-writing functions (functions that marshall their argumentsinto a single log record), log-reading functions (functions that reada log record and unmarshall it into a structure containing fields thatmap into the arguments written to the log), log-printing functions(functions that print the contents of a log record for debugging), andtemplates for recovery functions (functions that review log recordsduring transaction abort or recovery).  The tools and generated codeare C-language and POSIX-system based, but the generated code should beusable on any system, not just POSIX systems.])m4_p([dnlA sample application that does application-specific recovery is includedin the m4_db distribution, in the directory m4_path(examples_c/ex_apprec).])m4_page_footer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -