Mnesia Internals

MNESIA Internals

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

The Mnesia application family Mnesia Session

Xmnesia prototype

Mnesia SQL prototype

Mnemosyne

Orber

Mnesia Engine

Erlang/OTP Håkan Mattsson , 13th October 1999

Erltk

Mnesia Internals

Xmnesia

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Connectivity LAN database Backups in remote archive

Session Client

Mnesia Session (IDL) Mnesia SQL?

Remote archive

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Distributed DBMS engine Replication

erl

Location transparency

Mnesia

Ram and/or disk storage Fragmentation

erl Mnesia erl Mnesia

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Evaluation contexts mnesia: ets(Fun, Args) mnesia: async_dirty(Fun, Args) mnesia: sync_dirty(Fun, Args) mnesia: transaction(Fun, Args) -record(employee, {name, phone, salary}). Fun = fun(Who, Raise) -> [Emp] = mnesia:read({employee, Who}), Salary = Emp#employee.salary + Raise, mnesia:write(Emp#employee{salary = Salary}) end. Args = [Who, Raise]. mnesia_access callback module Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Dirty commit protocols Commit work is performed in the application process + remote TM’s ets, async_dirty and sync_dirty

committed data

Appl process

Remote TM

Remote TM

Remote TM TM = transaction manager Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Storage of transaction data start trans Appl process

Local TM ref to store updates

create transactionstore in ets

committed data

Remote TM Remote RemoteTM TM Updates are only visible in the appl process Commit work is performed in the application process + remote TM’s Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Commit work needed on each node Optionally append to transaction log - disk_log Optionally update memory resident B-tree for SNMP Optionally store old values in checkpoint retainer - (d)ets Optionally send messages to subscribing processes Optionally update secondary indecies - (d)ets Mandatory update of the main table - (d)ets Optionally send message to locker to release locks

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Dump of transaction log

Thresholds, startup Dual log files

disk_log

dets

Move records to dets Ensure atomicity

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Lock acquisition write / sticky / read Appl process

Local locker granted / deadlock

write lock

Remote locker Remote locker

Local locks requires local replica Sticky locks Multi-granular locks on records or tables

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Lock conflicts

Young

Middle age

Queue of conflicting lock requests Unfair index locks :-( Deadlock prevention Lamport clock

Erlang/OTP Håkan Mattsson , 13th October 1999

Old

Mnesia Internals

Supervision and event handling mnesia sup

mnesia sup

event

event

kernel sup

kernel sup

monitor

Link

monitor

checkpoint sup

checkpoint sup

snmp sup

snmp sup

other ...... other other ...

other ...... other other ...

mnemosyne sup Erlang/OTP Håkan Mattsson , 13th October 1999

mnemosyne sup

Mnesia Internals

Handling of node loss aquire lock Locker Locker Locker

Appl process release locks

Locker mnesia_down

Local TM

Local monitor

Remote monitor

EXIT signal Re-run transaction at node loss or deadlock Log mnesia_down to disk

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Lightweight transaction protocol ask commit

Remote TM Remote RemoteTM TM

Appl process vote yes / mnesia_down

do commit do commit work

do commit work

Non-blocking commit protocol Local TM becomes new coordinator if appl process dies Rely on "recovery by table load" Only used for symmetrically replicated tables Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Recovery by table load 1

Dump transaction log (twice) at startup

2

Presume commit if the "transaction" has been logged

3

Copy table from active replica if there is any

4

Load table from local disk if we have got mnesia_down’s from all other nodes with a replica

5

Select an arbitary loader if no one decided to load

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Heavyweight transaction protocol Non-blocking commit protocol Local TM becomes new coordinator if appl process dies May be used for any tables, but is avoided for performance reasons Currently used for schema and asymmetrically replicated tables

erl

Move replica

Mnesia

Erlang/OTP Håkan Mattsson , 13th October 1999

erl Mnesia

Mnesia Internals

Heavyweight transaction protocol Appl process

ask commit

Remote TM Remote RemoteTM TM

vote yes / mnesia_down prepare and log log unclear

pre commit acc pre commit / mnesia_down

log commit do commit work

log unclear

do commit log commit schema committed / mnesia_down do commit work

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Recovery of heavyweight transactions 1

Dump transaction log (twice) at startup

2

Send local decisions to other nodes at startup

3

Consult decision log about transaction outcome

4

Presume abort if all involved nodes are up, but unclear

5

Wait until we know the outcome, this may in case of double error, be until all involved nodes are up

6

Presume abort after max_wait_for_decision (default infinity)

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Worker processes

monitor subscr

mnesia sup locker event recover kernel sup checkpoint sup checkpoint checkpoint snmp sup

tm controller loader dumper

snmp snmp mnemosyne sup Erlang/OTP Håkan Mattsson , 13th October 1999

schema late loader

Mnesia Internals

Lines Of Code (October 1999) Mnesia Engine ~15.600 LOC Mnemosyne ~4.900 LOC Mnesia SQL prototype ~6.000 LOC (+generated parser ~38.000 LOC) Xmnesia prototype ~3.000 LOC Mnesia Session ~1.400 LOC Test suite (Mnesia Engine) ~14.000 LOC

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Test suite (Mnesia Engine) Acceptance (install) Nice coverage, Evil coverage Examples Configuration parameters Atomicity, Consistency, Isolation, Durability, Recovery Prediction, Fairness, Benchmarks, Resource Consumption, Scalability Light weight test server. Simple to run single test cases in debugger.

Erlang/OTP Håkan Mattsson , 13th October 1999

Mnesia Internals

Documentation roadmap Mnesia Overview, presented at PADL’ 99, written for Erlang novices http://www.ericsson.se/cslab/~hakan/mnesia_overview.pdf Erlang Book Erlang Language Extensions Mnesia User’s Guide Mnesia Reference Manual Erlang/OTP including Mnesia is available as open source at http://www.erlang.org Erlang/OTP Håkan Mattsson , 13th October 1999

mnesia mnesia - Erlang

Storage of transaction data ... Optionally append to transaction log - disk_log .... recover locker subscr loader monitor mnemosyne sup checkpoint checkpoint ...

166KB Sizes 7 Downloads 270 Views

Recommend Documents

Mnesia Database Management System (MNESIA) - Erlang
The management of data in telecommunications system has many aspects whereof some, but .... initialize a database schema, start Mnesia, and create tables.

Mnesia Database Management System (MNESIA) - Erlang
QLC, can be used as a database programming language for Mnesia. ... Mnesia Session enables access to the Mnesia DBMS from foreign programming languages ( ...... -mnesia no table loaders NUMBER specifies the number of parallel table ...

Erlang/OTP and how the PRNGs work - Erlang Factory
Mar 30, 2012 - Kenji Rikitake / Erlang Factory SF Bay 2012. 1 ... R15B can handle IPv6 services. • Address format is ... Network part: 64, Host part: 64. Address ...

Build a data platform over and on the web Erlang ... - Erlang Factory
Build a data platform over and on the web. Erlang User Conference 2013 ... Works with mobile & embedded devices. ○ Partials upload & downloads supported.

How WhatsApp is scaling up - Erlang Factory
Mar 7, 2014 - 1. That's Billion with a B: Scaling to the next level at WhatsApp. Rick Reed .... Downstream services (esp. non-essential) .... Network failures.

Generic Load Regulation Framework for Erlang - GitHub
Erlang'10, September 30, 2010, Baltimore, Maryland, USA. Copyright c 2010 ACM ...... rate on a budget dual-core laptop was 500 requests/s. Using parallel.

TinyMT Pseudo Random Number Generator for Erlang
Sep 14, 2012 - vided as a general library for multiple operating systems, since .... 3 On Kyoto University ACCMS Supercomputer System B cluster; the test.

SFMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
Erlang/OTP [5] has a built-in PRNG library called random mod- ule. ..... RedHat Enterprise Linux AS V4 of x86_64 architecture5. We chose the five SFMT ... WN time [ms] leciel reseaux thin. Figure 5. Total own time of SFMT gen_rand_list32/2 for 10 cal

Extracting the processes structure of Erlang applications - CiteSeerX
design patterns which commonly occur in concurrent distributed software. Ex- amples of ... ture of an Erlang application by analysis of the source code. By “the ...

Erlang/OTP and how the PRNGs work - Kenji Rikitake Professional ...
Sep 23, 2011 - Contents. RNGs implemented in Erlang/OTP. •crypto and random modules and their issues. SIMD-oriented Fast Mersenne Twister. (SFMT) on pure Erlang and with NIFs. •implementation issues. •performance evaluation. Conclusions and fut

TinyMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
Sep 14, 2012 - Statistics]: Random Number Generation. General Terms Algorithms, Performance. Keywords .... Table 1 shows a list of tinymt-erlang major exported functions referred in this paper. Figure 1 shows the ..... hiroshima-u.ac.jp/~m-mat/MT/ART

SSH Distribution Transport on Erlang Concurrent System
Oct 26, 2009 - and the arbitrary port-mapping mechanism, and is prone to security attacks on a wide-area Internet. In this paper, we propose a distributed ...

SFMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
List of sfmt-erlang exported functions referred in this paper. 128-bit shift registers. ..... and does not effectively utilize the concurrent and parallel nature of. Erlang.

Extracting the processes structure of Erlang applications
Department of Information Technology ... an Erlang program is structured according to modules and functions, ... An example of the type of information we.

Extracting the processes structure of Erlang applications - CiteSeerX
tool extracts the process structure from the applications source code, and presents it ..... a nop-behaviour, e.g. cancel timer, disconnect node, get, load module,.

Application Security of Erlang Concurrent System - Kenji Rikitake ...
Contact email: [email protected] ... We then evaluate and propose the possible further enhancements to add the protection ..... 1/books/handbook/jails.html.

TinyMT Pseudo Random Number Generator for Erlang
Sep 2, 2012 - Now default PRNG for Python and R. Kenji Rikitake / Erlang ... A) Generate a 32-bit integer random number R. B) Compute Q which is the ...

Erlang/OTP and how the PRNGs work - Kenji Rikitake Professional ...
Sep 23, 2011 - Extensive use of head-and-tail list. •Making lists for each recursive argument. •list head addition + lists:reverse/1 is 50% faster than using the ++ ...

Shared Nothing Secure Programming in Erlang/OTP
(*1): The word CAP stands for Consistency, Availability, and Partition tolerance. (*2): Disclaimer: the author Kenji Rikitake was a Senior Software Engineer at Basho. Japan KK, a subsidiary of Basho Technologies, Inc., from February to Septem