Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
140
|
第
7
章
所有已经接受的写操作都必须等待。这样,刷写进程(作为消耗者)就知道哪些其他进
程(作为生产者)依赖于它。
更一般地,我们有以下同步点:
memtable
切换
在此之后,所有的写操作都去到新的 memtable,使其成为主 memtable,而旧的
memtable 仍可用于读操作。
刷写完成
在表视图中用刷写完的磁盘驻留表来替换旧的 memtable。
预写日志截断
丢弃持有与被刷写 memtable 相关联的记录的日志段。
这些操作隐含着严苛的正确性要求。继续写入旧的 memtable 可能导致数据丢失(例如,
如果写入已被刷写的 memtable 段)。类似地,在驻留磁盘的对应部分准备就绪之前,如
果旧的 memtable 不提供读取,则将导致读取到不完整的结果。
在压实期间,表视图也会更改,但这里的过程稍微简单一些:旧的磁盘驻留表被丢弃,
而被压实的版本则被添加进来。旧表必须保持可访问性,直到新表完全写入并准备好代
替它进行读操作。同一个表参与多个并行压实的情况也必须避免。
在 B 树中,日志截断必须与从页缓存中刷写脏页相协调,以保证持久性。在 LSM 树
中,我们有一个类似的要求:写入操作在 memtable 中被缓冲,并且它们的内容在完
全刷盘之前是不具备持久性的,因此日志截断必须与 memtable 刷盘相协调。刷盘一
旦完成,日志管理器就会得到最新的已刷写日志段的信息,因此可以安全地丢弃其中
的内容。
不将日志截断与刷盘同步也会导致数据丢失:如果在刷盘完成之前丢弃了日志段,并且在
此时节点崩溃,那么这些日志内容将不会被重放,从而导致该段的数据也不会被恢复。 ...
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