Escolar Documentos
Profissional Documentos
Cultura Documentos
Outline
1. File storage format
2. Shared memory creation
3. Shared buffers
4. Row value access
5. Locking
6. Other structures
FileSystemData
Postgres
/data
Pages
/base /16385
/24692
8k
Postgres
Postgres
8k
8k
8k
Data Pages
Postgres
/data
/base /16385
/24692
8k
8k
8k
8k
Postgres
Postgres
Page Header
Item
Item
Item
8K
Tuple
Tuple
Tuple
Special
FileSystemBlockTuple
Postgres
/data
/base /16385
/24692
8k
8k
8k
8k
Postgres
Page Header
Item
Item
Item
Postgres
8K
Tuple
Tuple
Tuple
Special
Tuple
FileSystemTuple
Martin
int4in(9241)
Tuple
textout()
Header
Value
Value
Value
Value
Value
Value
It is a process which is used to start/stop process for connecting database. Also starts a OS Kernal
called fork(), fork() makes copy of postmaster and creates two new sessions postgres.
SharedMemoryCreation
k()
postmaster
This is the
program which
runs
OS Technique
for
postgres
postgres
SESSION1
SESSION2
Program (Text)
Program (Text)
Program (Text)
Data
Data
Data
Shared Memory
Shared Memory
Shared Memory
Stack
Stack
Stack
All programs/
Data/SM/
Stack
are separate
SharedMemory
PROC
Lightweight Locks
XLOG Buffers
Proc Array
Lock Hashes
CLOG Buffers
LOCK
Subtrans Buffers
PROCLOCK
Auto Vacuum
Btree Vacuum
Background Writer
Synchronized Scan
Buffer Descriptors
Shared Buffers
Semaphores
Shared Invalidation
SharedBuffers
Buffer Descriptors
8k
8k
8k
Shared Buffers
read()
Page Header
Item
Item
Item
write()
Postgres
8K
8k 8k 8k 8k
Tuple
Tuple
Tuple
Special
Postgres
Postgres
14
HeapTuples
8k
8k
8k
Shared Buffers
Page Header
Item
Item
Item
8K
Tuple
Tuple
Tuple
Special
Martin
int4in(9241)
HeapTuple
Tuple
textout()
Header
Value
Value
Value
Value
Value
Postgres
Value
C pointer
OID
xmin
xmax
cmin
cmax
ctid
natts
infomask
tuple flags
hoff
bits
Any users can make modifications, but how do you do that. How to prevent them performing at the same time and accessing sahred memory.
The way is done with locking
0/1
Success
Failure
Was 0 on exchange
Was 1 on exchange
Lock already taken
SpinLock
AlwaysSucceeds
0/1
Success
Failure
Was 0 on exchange
Was 1 on exchange
Lock already taken
Light WeightLocks
Sleep On Lock
PROC
Lightweight Locks
XLOG Buffers
Proc Array
Lock Hashes
CLOG Buffers
LOCK
Subtrans Buffers
PROCLOCK
Auto Vacuum
Btree Vacuum
Background Writer
Synchronized Scan
Shared Invalidation
Buffer Descriptors
Shared Buffers
Semaphores
PROC
PROCLOCK
LOCK
Lock Hashes
Every processor has got proc structure and contains session ID and
info of transaction.
Proc
PROC
empty
used
Proc Array
used
empty
used
empty
Other SharedMemoryStructures
PROC
Lightweight Locks
XLOG Buffers
Proc Array
Lock Hashes
CLOG Buffers
LOCK
Subtrans Buffers
PROCLOCK
Auto Vacuum
Btree Vacuum
Background Writer
Synchronized Scan
Buffer Descriptors
Shared Buffers
Semaphores
Shared Invalidation