PDB 2 Session Persistence
PDB 2 Session Persistence
Practical DBMS
Prof. Joseph G. Vella ©
Dept. of Computer Information Systems
JOSEPH.G.VELLA@UM.EDU.MT
Data Persistence
Devices, Aggregate Devices , and Techniques
1
Prof Joseph G Vella © - PDBMS Data Persistence
Hard disks
2
Prof Joseph G Vella © - PDBMS Data Persistence
Physical
files
3
Prof Joseph G Vella © - PDBMS Data Persistence
4
Prof Joseph G Vella © - PDBMS Data Persistence
10
5
Prof Joseph G Vella © - PDBMS Data Persistence
11
12
6
Prof Joseph G Vella © - PDBMS Data Persistence
13
14
7
Prof Joseph G Vella © - PDBMS Data Persistence
15
Not all
sectors,
tracks,
platters are
available for
storage!?
16
8
Prof Joseph G Vella © - PDBMS Data Persistence
17
18
9
Prof Joseph G Vella © - PDBMS Data Persistence
19
1. Move
Head
2. Wait for
sector
RAM 3. Move
Transfer Time sector’s data
20
10
Prof Joseph G Vella © - PDBMS Data Persistence
𝑆𝑖𝑧𝑒𝐷𝑎𝑡𝑎𝐵𝑙𝑜𝑐𝑘𝑠
𝑅𝐼𝑂 =
𝑇𝐼𝑂
21
22
11
Prof Joseph G Vella © - PDBMS Data Persistence
• It is expected that:
time for accessing two blocks in succession is faster for two
neighboring blocks than distant blocks.
23
10 2
9 3
8 4
7 5
6
24
12
Prof Joseph G Vella © - PDBMS Data Persistence
10 2
0
7 5
9 3
2 10
8 4
9 3
7 5
6
4 8
11 1
• Interleaving – jump should be long 6
enough to be just greater than
transfer time required.
– This has become rare in the
presence of track buffering!
25
• It holds disk blocks read from the drive and blocks to be written to the it.
• Other than holding a queue of blocks the disk drive might read a cluster
of sectors into it, rather than a single sector, to anticipate forthcoming
requests.
– What about writing back a cluster (i.e. sector at a time) can the cache
help?
• It depends what is needed?
If writer requires confirmation of write (write through) then ‘Not
much’.
If writer does not require write notice (write back / immediate
reporting) then ‘Yes’.
– (if un-aided this cluster write is in peril on drive failure.)
26
13
Prof Joseph G Vella © - PDBMS Data Persistence
to
0 1 2 3 4 5 6 7 8
from 0 0 1 2 3 4 5 6 7 8
1 1 0 1 2 3 4 5 6 7
2 2 1 0 1 2 3 4 5 6
3 3 2 1 0 1 2 3 4 5
4 4 3 2 1 0 1 2 3 4
5 5 4 3 2 1 0 1 2 3
6 6 5 4 3 2 1 0 1 2
7 7 6 5 4 3 2 1 0 1
8 8 7 6 5 4 3 2 1 0
27
28
14
Prof Joseph G Vella © - PDBMS Data Persistence
29
• Data Server:
– High RPM
– Lowest seek times
– High transfer band width
• Personal Computers
– Capacity & lowest cost per unit storage
• Laptops
– Sturdy
– Lowest power consumption (low RPM, few platters, etc)
• Home entertainment
– Low mechanical noise!
30
15
Prof Joseph G Vella © - PDBMS Data Persistence
31
Platter 4 4
32
16
Prof Joseph G Vella © - PDBMS Data Persistence
33
34
17
Prof Joseph G Vella © - PDBMS Data Persistence
35
36
18
Prof Joseph G Vella © - PDBMS Data Persistence
37
38
19
Prof Joseph G Vella © - PDBMS Data Persistence
39
40
20
Prof Joseph G Vella © - PDBMS Data Persistence
41
42
21
Prof Joseph G Vella © - PDBMS Data Persistence
Journey of a Byte
write(textfile, ch, 1); -- ch is assigned ‘P’
43
Journey of a Byte
44
22
Prof Joseph G Vella © - PDBMS Data Persistence
Journey of a Byte
45
Journey of a Byte
46
23
Prof Joseph G Vella © - PDBMS Data Persistence
Journey of a Byte
47
The DBMS
has direct
User
Application access to
Interface
HD … by-
DBMS
passing
OS & FS.
OS & FS
H/W e.g HD
48
24
Prof Joseph G Vella © - PDBMS Data Persistence
(External) Fragmentation
• External Fragmentation happens!?
• The file’s spanning might not be
contiguous.
• How does it affect:
– Sequential reads
• It interrupts flow by
introducing a seek access …
– Direct Access
• Superficially none.
• BUT!
– It can break the locality
advantage …
– Allocation
• Although space is available
it’s not contiguous –
consequently increasing the
problem.
49
50
25
Prof Joseph G Vella © - PDBMS Data Persistence
(Internal) Fragmentation
• Any data file needs to be spanned into a list of disk blocks (i.e.
sectors).
– Data files can't share any sector!
• Consider a data file of 6K (i.e. 6,000) bytes.
– The following table shows sector space utilisation.
Sectors in 1 2 4 8 16 32 64
Cluster
Clusters needed 12 6 3 2 1 1 1
File size on disk 6144 6144 6144 8192 8192 16384 32768
51
52
26
Prof Joseph G Vella © - PDBMS Data Persistence
53
Aggregate Systems
54
27
Prof Joseph G Vella © - PDBMS Data Persistence
Requirements
• To the F/S the RAID unit is a big, fast, and reliable (single) disk.
– When a F/S issues a logical I/O request to the RAID, it internally
must calculate which disks to access in order to complete the
request, and then issue one or more physical I/Os to do so.
55
Reliability:
Remember Disks Fail Badly!?
– Assuming:
• Units is in its first year of use;
• Tests results are in terms of arbitrary usage.
56
28
Prof Joseph G Vella © - PDBMS Data Persistence
Some Definitions
• Disk Shadowing
– Making two or more copies of data written to a disk drive.
• Disk Duplexing
– A method of storing data whereby the data from one hard disk
is duplicated onto another, with each using its own hard disk
controller.
• In contrast to Disk Mirroring
• Disk Mirroring
– A method of storing data whereby the data from one hard disk
is duplicated on another, with both hard disks sharing a single
hard disk controller
• In contrast to Disk Duplexing
57
58
29
Prof Joseph G Vella © - PDBMS Data Persistence
59
60
30
Prof Joseph G Vella © - PDBMS Data Persistence
61
A Reliability Indicator
62
31
Prof Joseph G Vella © - PDBMS Data Persistence
63
• Although stated as a
primary cause of faults,
Google’s study suggests
there is more to it:
– Failures do not co-relate
with increase in
temperature.
– But failure co-relate with
low temperatures.
• Failure rates pick-up at
higher temperatures.
64
32
Prof Joseph G Vella © - PDBMS Data Persistence
65
66
33
Prof Joseph G Vella © - PDBMS Data Persistence
• Capacity
– Is the aggregate of N drives, what portion of these are used for
storage?
• For full redundancy we have N/2.
• Reliability
– What type of faults can a system withstand?
– How many faults can a system tolerate?
• Performance
– Different workloads are expected to have different measures.
67
68
34
Prof Joseph G Vella © - PDBMS Data Persistence
Chunk Sizes
• Observation: it’s hard to work out an ideal chunk size, one way
to address the problem is by building a workload profile.
– A workload is a mix of direct and sequential writes.
69
RAID1
• This level uses "mirroring" to copy data onto
two disk drives simultaneously.
– Possible twice the Read transaction rate
of single disks, same Write transaction
rate as single disks.
• RAID 1 provides failure tolerance.
– If one disk fails, then other maintains the
data.
• Reestablishing RAID1 requires straight
copying from live drive to new drive.
• Storage cost doubles as duplicating all data
means only half the total disk capacity is able
for storage.
70
35
Prof Joseph G Vella © - PDBMS Data Persistence
RAID0+1
• RAID 0+1 is implemented as a
mirrored array whose segments
are RAID 0 arrays
• Use two set-ups in one array.
– Both data duplication and
improved access speed are
possible.
• High I/O rates are achieved
thanks to multiple stripe
segments.
• Four drives are the minimum.
71
RAID5
• Uses a technique that avoids the
concentration of I/O on a dedicated parity
disk by writing it separately across multiple
disks.
– Three drives are required as a minimum.
• “Write penalty” still occurs as existing data
must be pre-read before update and parity
data has to be updated after the data is
written.
• RAID 5 enables multiple write orders to be
implemented concurrently because updated
parity data is dispersed across the multiple
disks.
• Highest Read data transaction rate.
• Medium Write data transaction rate.
• Difficult to rebuilt once a unit faults; when
compared to RAID1,
• Widely applicable: database and web servers
72
36
Prof Joseph G Vella © - PDBMS Data Persistence
RAID10
• Not exactly like RAID0+1, as in RAID10 first
we mirror and then strip.
• RAID 10 is implemented as a striped array
whose segments are RAID 1 arrays.
– Requires a minimum of four drives.
• RAID 10 has the same fault tolerance as
RAID level 1
• RAID 10 has the same overhead for fault-
tolerance as mirroring alone
73
RAID
Capacity, Reliability & Performance Comparison
74
37
Prof Joseph G Vella © - PDBMS Data Persistence
Persistent Memory
The wedge between the CPU stores
and persistent storage
75
https://www.snia.org/education/what-is-persistent-memory
76
38
Prof Joseph G Vella © - PDBMS Data Persistence
What is NVRAM?
• NVRAM is a type of Random Access Memory (RAM) that retains its data
even when the main power is not available.
– Read access latency is quoted at: 100ns to 1000ns.
• Types of NVRAM:
– Uses SRAM that is made non-volatile by connecting it to an additional
power source, e.g., battery.
– Uses EEPROM (Electrically Erasable Programmable Read-Only Memory)
to save its data when power is not available. NVRAM has a combination
of SRAM and EEPROM semiconductors incorporated into one chip.
• Advantages
– NVRAM’s support high-speed data read/write operations for parallel
processing and DBMS cache.
– NVRAM can act as in-unit caches for HDD, SDD.
– NVRAM semiconductors are light on power consumption and backup
power exhaustion is unlikely to happen for a long time.
• Disadvantages
– Write to Read speed ratio is an issue (for performance).
– Still very iffy, production wise.
– Chips fail!
77
Read
at your
leisure! An Example Package
• IP-NVRAM-1M Greenspring
Non-Volatile Memory Industry Pack Module
• Features:
• Single-Wide IndustryPack
• IndustryPack Wait State
• Lithium Battery
• The Greenspring IP-NVRAM Non-Volatile Memory IndustryPack
Module provides a convenient and reliable way to implement
non-volatile memory up to one megabyte in a single-high
IndustryPack.
Eight TSOP 128K x 8-bit low power SRAM chips and a lithium
battery provide 10 years (at room temperature) of maintenance-
free operation.
The IP-NVRAM powers-up ready to go. No software initialization
is required.
Four memory configurations were manufactured: 256 KB, 512 KB,
768 KB, and 1 MB. The one megabyte configuration and the 256
KB configuration are standard.
Access to the IP-NVRAM occurs in the IndustryPack memory
space.
A unique ID PROMS identifies the IP-NVRAM. Users or systems
integrators may add information to the ID PROMs to indicate
user-specific information.
• https://www.artisantg.com/TestMeasurement/59561-1/Abaco-Systems-SBS-Greenspring-IP-
NVRAM-1M-Non-Volatile-Memory-IndustryPack-Module
78
39
Prof Joseph G Vella © - PDBMS Data Persistence
79
80
40
Prof Joseph G Vella © - PDBMS Data Persistence
81
82
41
Prof Joseph G Vella © - PDBMS Data Persistence
83
84
42
Prof Joseph G Vella © - PDBMS Data Persistence
85
86
43