2
Gray & Reuter Log 10a: 2 Log Concept Log is a history of all changes to the state.Log is a history of all changes to the state. Log + old state gives new state Log + new state gives old state (not in this picture) Log is a sequential file. Complete log is the complete history Current state is just a "cache" of the log records. Archive Sunday Master Monday Master Monday Transactions Monday Night Batch Run Monday Master Tuesday Master Tuesday Transactions Tuesday Night Batch Run Tuesday Master Wednesday Transactions Wednesday Night Batch Run Wednesday Master

3
Gray & Reuter Log 10a: 3 How Log is Used Recovery from faults A redundant copy of the state and transitions Security audits: Who did what to whom. Often too low-level for this. Performance Monitor & Accounting: But only records changes (not reads). ISSUES:Who should be allowed to read the log? It is a security hole. Must authorize access on a per-record basis.

8
Gray & Reuter Log 10a: 8 The Log LSN Each log record has a logical sequence number. This number (LSN for Log Sequence Number) plays a key role in many algorithms. Key property MONOTONICITY: If action A happened after action B then LSN(A) > LSN(B).

14
Gray & Reuter Log 10a: 14 Making Optimistic Log Reads Work Log is duplexed. Log manager reads only one copy of the page. What if the "other" copy has more data? Trick: read BOTH copies of FIRST and LAST page in log. Other pages have "full" flag and a timestamp. IF not full or timestamp < prev_timestamp THEN read other page and take highest timestamp Torn log pages Log page consists of disk sectors (512B). Write may only write some sectors. How detect missing fragments? 1. Checksum? 2. Byte stuffing: stuff a parity byte on each page

17
Gray & Reuter Log 10a: 17 Careful Writes If partial pages may be written then subsequent write may invalidate previous write. Standard technique: Serial Writes: write one page then write the second page. Problem: ~ 1/2 disc bandwidth, 2x delay. Ping-Pong technique: Never overwrite good page: Ping-Pong between I and I+1 When complete, assure that page I has final data Never worse than serial write, generally 2x better. Also note the careful techniques for optimistic reads and torn pages. Disc Page i: i+1: Parallel Ping-Pong Writes New Log

18
Gray & Reuter Log 10a: 18 Group Commit (Boxcaring) Batch processing of log writes. If receive 1,000 log force requests/second why not just execute 50 of them? Response time will be the same (~20ms). IOs will be 20x fewer CPU will be ~ 10x smaller (10x fewer dispatches, 20x fewer OS IO). Without it, systems are limited to about 50tps no ping-pong 100tps ping-pong. With it, systems are limited to disc bandwidth >>10ktps. Group commit threshold can be set automatically.

19
Gray & Reuter Log 10a: 19 WADS- Giving the Log Disc Zero Latency Log disc is dedicated, so only has rotational latency. Reserve some cylinders on the disc as scratch. For each write: Write at current position on next track (zero latency). When have a full-track (or two) of log data consolidate the write in ram do a single LARGE write (100KB = 1 rotation) to the log. cost of this is seek + rotation ~ 20ms. This reserved area is called the Write Ahead Data Set (WADS). At restart: read cylinders gather recent log data rewrite end of log. RAID Write Cache makes this obsolete (if it works).

22
Gray & Reuter Log 10a: 22 Preparing For Restart: Careful Write of Log Anchor Use the "standard" careful write techniques: Put the anchor in a special well-known place(s) Ping-Pong to 2 or more copies Timestamp each copy N-plex the copies on devices with independent failures. Align copies so that writes are "atomic" Accept most recent copy on pessimistic reads. Now TM and RMs can bootstrap: their anchors are in the log.

23
Gray & Reuter Log 10a: 23 Finding the End of the Log Find the anchor If using WADS, go to the WADS area and write log end. elseScan forward from the most log-anchor lsn Read optimistic all full pages. At 1/2 full page or bad page read pessimistic. Now have end-of log. Finish 1/2 finished record at end of log and give to TM Pages End of log Half-finished record Invalid Page Pages End of log

28
Gray & Reuter Log 10a: 28 Client/Server Logging One server design (can be process pair) Well known log server in the net. Client sends a BATCH of log records to the server. Gets back a LSN Uses "local" LSNs for his objects. Log servers can be N-plexed processes. Multi-server design Client forms a quorum (majority of servers). Client sends log batch to all, gets back N-LSNs. If less than majority, client must poll ALL N servers Servers synchronize their "logical" logs as "sum" of physical logs (need a majority).

29
Gray & Reuter Log 10a: 29 Summary Log is a sequential file Contains entire history of DB Many tricks to write it efficiently and carefully Many tricks to archive and recover it

About project

Feedback

To ensure the functioning of the site, we use cookies. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy &amp Terms.
Your consent to our cookies if you continue to use this website.