1. Trang chủ
  2. » Giáo án - Bài giảng

thiết kế va quan tri cơ sở dữ liệu vũ tuyết trinh notes12 crash recovery sinhvienzone com

11 33 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 11
Dung lượng 313,21 KB

Nội dung

Crash Recovery Vu Tuyet Trinh trinhvt@it-hut.edu.vn Department of Information Systems, Faculty of Information Technology Hanoi University of Technology Transaction collection of action that preserve consistency Consistent DB T Consistent DB’ with assumption IF THEN SinhVienZone.com T starts with consistent state + T executes in isolation T leaves consistent state https://fb.com/sinhvienzonevn How can constraints be violated?    Transaction bug DBMS bug Hardware failure e.g., disk crash  Data sharing e.g., T1 and T2 in parallel Failures Events Desired Undesired Expected Unexpected processor CPU memory disk M SinhVienZone.com D https://fb.com/sinhvienzonevn Recovery  Maintaining the consistency of DB by ROLLBACK to the last consistency state  Ensuring properties   Atomic  Durability Using LOG Transaction Log  A sequence of log record keeping trace of actions executed by DBMS Log the beginning of the transaction execution transaction is already finished Transaction is calcel Transaction makes an update actio, before update X=v, after update x = w SinhVienZone.com https://fb.com/sinhvienzonevn Transaction Log  Handled in main memory and put to external memory (disk) when possible A = 16 B = 16 Actions Data Log Log Disk Memory Checkpoint  Definition:    Objective    SinhVienZone.com moment where intermediate results and a log record are saved to disk being initiated at specified intervals minimize the amount of time and effort wasted when restart the process can be restarted from the latest checkpoint rather than from the beginning Log record or https://fb.com/sinhvienzonevn Undo-logging Step Action t Mem A 8 16 16 Mem B Disk A Disk B 8 8 8 8 Read(B,t) 16 16 t:=t*2 16 16 8 16 16 16 8 Write(B,t) Flush log Output(A) 16 16 16 16 10 Output(B) 16 16 16 16 16 Read(A,t) t:=t*2 Write(A,t) 11 12 Mem Log Flush log Undo-Logging Rules (1) For every action generate undo log record (containing old value) (2) Before X is modified on disk, log records pertaining to X must be on disk (write ahead logging: WAL) (3) Before commit is flushed to log, all writes of transaction must be reflected on disk SinhVienZone.com https://fb.com/sinhvienzonevn Undo Logging Recovery Rules  Let S is set of unfinished transactions    For each in log   in log or is not in log If Ti  S then - Write(X, v) - Output(X) For each Ti  S  Write to log Undo-Logging & Checkpoint scan SinhVienZone.com scan https://fb.com/sinhvienzonevn Redo-logging Step 10 11 Action t Mem A Mem B Disk A Disk B 8 8 Mem Log Read(A,t) t:=t*2 Write(A,t) Read(B,t) t:=t*2 Write(B,t) Flush log Output(A) Output(B) 16 16 8 16 16 8 8 16 16 16 16 16 8 8 16 16 16 16 16 16 16 16 16 Redo-logging Rules (1) For every action, generate redo log record (containing new value) (2) Before X is modified on disk (DB),all log records for transaction that modified X (including commit) must be on disk (3) Flush log at commit (4) Write END record after DB updates flushed to disk SinhVienZone.com https://fb.com/sinhvienzonevn Redo-logging Recovery Rules  Let S = set of transactions with in log no in log    For each in log, in forward order (earliest  latest) If Ti  S then write(X, v) output(X)   For each Ti  S  write Redo Logging & Checkpoint scan scan SinhVienZone.com https://fb.com/sinhvienzonevn Discussion  Undo Logging    need to write to disk as soon transaction finishes Access disk Redo Logging   need to keep all modified blocks in memory until commit Use memory Undo/Redo Loggin Step 10 11 SinhVienZone.com Action t Mem A Mem B Disk A Disk B 16 16 8 16 16 8 8 8 8 16 16 16 16 16 8 8 16 16 16 16 16 16 16 16 16 Mem Log Read(A,t) t:=t*2 Write(A,t) Read(B,t) t:=t*2 Write(B,t) Flush log Output(A) Output(B) https://fb.com/sinhvienzonevn Undo/Redo Logging Rules    Page X can be flushed before or after T commit Log record flushed before corresponding updated page (WAL) Flush at commit (log only) Undo/Redo Logging & Checkpoint scan SinhVienZone.com scan https://fb.com/sinhvienzonevn 10 Undo/Redo Logging Recovery Rules        SinhVienZone.com Backwards pass (end of log  latest valid checkpoint start) Constructing set S of committed transactions undo actions of transactions not in S undo pending transactions follow undo chains for transactions in (checkpoint active list) – S Forward pass (latest checkpoint start  end of log) redo actions of S transactions https://fb.com/sinhvienzonevn 11 ... modified X (including commit) must be on disk (3) Flush log at commit (4) Write END record after DB updates flushed to disk SinhVienZone. com https://fb .com/ sinhvienzonevn Redo-logging Recovery Rules... https://fb .com/ sinhvienzonevn 10 Undo/Redo Logging Recovery Rules        SinhVienZone. com Backwards pass (end of log  latest valid checkpoint start) Constructing set S of committed transactions... disk crash  Data sharing e.g., T1 and T2 in parallel Failures Events Desired Undesired Expected Unexpected processor CPU memory disk M SinhVienZone. com D https://fb .com/ sinhvienzonevn Recovery

Ngày đăng: 30/01/2020, 21:01

TỪ KHÓA LIÊN QUAN

w