Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
事务处理与恢复
|
83
误通知。由于脏页标志已经被清除了,所以检查点进程会认为数据已成功写入磁盘,
然而事实上可能并非如此。
考虑到潜在的可恢复故障的存在,上述行为的组合可能会导致数据丢失甚至数据库
损坏。这样的行为很难被检测到,并且它们可能导致数据库进入无法恢复的状态。
有时,即使想触发此类行为也不那么容易。在设计恢复机制时我们一定要格外小心,
要仔细考虑并尝试测试每种可能的故障场景。
5.2.1
日志语义
预写日志是仅追加的,并且已写入的内容是不可变的,因此所有对日志的写入都是顺序
的。由于 WAL 是一个不可变的、仅追加的数据结构,所以读取方可以安全地访问写入
边界之前的内容,同时写入方可以继续将数据追加到日志尾部。
WAL 由日志记录组成,每条记录都有一个唯一的、单调递增的
日志序列号
(LSN)。 通
常,LSN 由一个内部的计数器或时间戳表示。由于日志记录不一定占据整个磁盘块,所
以其内容会被缓存在
日志缓冲区
中,并在
强制刷盘
(force)操作时被刷写到磁盘上。强
制刷盘操作发生在日志缓冲区被填满时,也可能被来自事务管理器或页缓存的请求所触
发。各日志记录必须以 LSN 的顺序刷写到磁盘上。
除了单独的操作记录外,WAL 还会保存事务完成的记录。只有当事务提交记录完成刷盘
之后,才能将该事务视为已提交。
系统在回滚或恢复期间也有可能发生崩溃,为了确保这种情况下系统能继续正常工作,
某些系统会在撤销操作时记录
补偿日志记录
(CLR)并将其存储在日志中。
WAL 通常与主存储结构紧密耦合,它提供了允许在到达
检查点 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169