Mnesia
   HOME

TheInfoList



OR:

Mnesia is a
distributed Distribution may refer to: Mathematics *Distribution (mathematics), generalized functions used to formulate solutions of partial differential equations *Probability distribution, the probability of a particular value or value range of a varia ...
, soft real-time database management system written in the
Erlang programming language Erlang ( ) is a general-purpose, concurrent, functional programming language, and a garbage-collected runtime system. The term Erlang is used interchangeably with Erlang/OTP, or Open Telecom Platform (OTP), which consists of the Erlang run ...
. It is distributed as part of the
Open Telecom Platform OTP is a collection of useful middleware, libraries, and tools written in the Erlang programming language. It is an integral part of the open-source distribution of Erlang. The name OTP was originally an acronym for Open Telecom Platform, which w ...
.


Description

As with Erlang, Mnesia was developed by
Ericsson (lit. "Telephone Stock Company of LM Ericsson"), commonly known as Ericsson, is a Swedish multinational networking and telecommunications company headquartered in Stockholm. The company sells infrastructure, software, and services in informa ...
for soft real-time
distributed Distribution may refer to: Mathematics *Distribution (mathematics), generalized functions used to formulate solutions of partial differential equations *Probability distribution, the probability of a particular value or value range of a varia ...
and
high-availability High availability (HA) is a characteristic of a system which aims to ensure an agreed level of operational performance, usually uptime, for a higher than normal period. Modernization has resulted in an increased reliance on these systems. Fo ...
computing work related to
telecoms Telecommunication is the transmission of information by various types of technologies over wire, radio, optical, or other electromagnetic systems. It has its origin in the desire of humans for communication over a distance greater than that fe ...
. It was not intended as a general office-based data processing database management system, nor to replace SQL-based systems. Instead Mnesia exists to support Erlang, where DBMS-like persistence is required. It has more in common with embeddable DBMS such as
Berkeley DB Berkeley DB (BDB) is an unmaintained embedded database software library for key/value data, historically significant in open source software. Berkeley DB is written in C with API bindings for many other programming languages. BDB stores arbitr ...
than with any SQL database server.


Database model

"Rows" in tables are represented as records that contain a key value and a data field. This data field may in turn be a
tuple In mathematics, a tuple is a finite ordered list (sequence) of elements. An -tuple is a sequence (or ordered list) of elements, where is a non-negative integer. There is only one 0-tuple, referred to as ''the empty tuple''. An -tuple is defi ...
containing an Erlang data structure of any complexity.


Backend types

Mnesia has three inbuilt table types: ram_copies, disc_copies and disc_only_copies.


Ram_copies

Data resides in memory and table size is limited by available memory and are backed b
ETS
(erlang term storage) table.


Disc_copies

Data resides in memory but is also persisted on disk backed by disk_log. Disc_copies were backed b

tables until 30th September 2001 with the release of Erlang R7B-4.


Disc_only_copies

Data resides only on disc and are backed b

(disk version of ETS)

file format uses signed 32-bit integers for file offsets and has a limit of 2GB so do disc_only_copies.


Backend plugins

Due to limits imposed b

support for other backend plugins was suggested b
Ulf Wiger
and these were added to Mnesia.
Klarna Klarna Bank AB, commonly referred to as Klarna, is a Swedish fintech company that provides online financial services such as payments for online storefronts and direct payments along with post-purchase payments. The company has more than 4,000 ...
added the
LevelDB LevelDB is an open-source on-disk key-value store written by Google fellows Jeffrey Dean and Sanjay Ghemawat. Inspired by Bigtable, LevelDB is hosted on GitHub under the New BSD License and has been ported to a variety of Unix-based systems, ma ...
backend plugin whil
Aeternity
added the
RocksDB RocksDB is a high performance embedded database for Key-value database, key-value data. It is a fork of Google's LevelDB optimized to exploit many multi-core processor, CPU cores, and make efficient use of fast storage, such as solid-state drives ...
backend plugin.


Relational features

The database model is relational, but isn't what someone familiar with SQL might expect. A database contains tables. Relationships between them are modelled as other tables. A key feature of Mnesia's high-availability approach is that tables can be reconfigured within a schema and relocated between nodes, not only while the database is still running, but even while write operations are still going on.


Coding

The
query language Query languages, data query languages or database query languages (DQL) are computer languages used to make queries in databases and information systems. A well known example is the Structured Query Language (SQL). Types Broadly, query language ...
of Mnesia is Erlang itself, rather than SQL. It permits easy representation of transactions as a natural feature of Erlang by allowing developers to utilize a single language throughout an application.


Transactions

Erlang is a
functional language In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that ...
. Mnesia builds on this to obtain ACID transaction support. The functional block which is run as a transaction is a commonplace Erlang construct called a ''Functional Object'' (or ''Fun'') and is called by the single Mnesia statement mnesia:transaction(F). This can lead to clearer source code than the paired BEGIN / COMMIT syntax of SQL, and so avoids its problem of unclosed transactions within a procedure. Again as a result of the functional nature of Erlang, nesting transactions is simple. It's also possible to distribute transactions across multiple nodes (i.e. separate servers). The semantics of using transactions in this way remains consistent, making it easy to write library code that works equally in either context. General coding style for Mnesia will always use transactions. For performance reasons, it also supports deliberate "''dirty operations''" which avoid transactions. These compromise the ''atomicity'' and the ''isolation'' properties of ACID, but offer around 10× more throughput. In addition there are also in-memory alternatives, although these lose the ''durability'' property of ACID.


Efficient execution

Mnesia forms part of the LYME web application stack. This is akin to
LAMP Lamp, Lamps or LAMP may refer to: Lighting * Oil lamp, using an oil-based fuel source * Kerosene lamp, using kerosene as a fuel * Electric lamp, or light bulb, a replaceable component that produces light from electricity * Light fixture, or li ...
, but based on Erlang. Implementation in Erlang confers an efficiency benefit because of the use of a single
virtual machine In computing, a virtual machine (VM) is the virtualization/ emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized h ...
throughout an application. LYME makes use of this, since the
Yaws Yaws is a tropical infection of the skin, bones, and joints caused by the spirochete bacterium ''Treponema pallidum pertenue''. The disease begins with a round, hard swelling of the skin, in diameter. The center may break open and form an ulce ...
web server is also implemented in Erlang. Address space is shared (although safely so, under Erlang) between code and data, including Mnesia's table data.


Origins and licensing

Mnesia and Erlang were developed by the Ericsson Computer Science Laboratory. They have been released as
open source software Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Open ...
. Mnesia is released under a derivative of the
Mozilla Public License The Mozilla Public License (MPL) is a free and open-source weak copyleft license for most Mozilla Foundation software such as Firefox and Thunderbird The MPL license is developed and maintained by Mozilla, which seeks to balance the concerns ...
. Since OTP 18.0 they are published according to the open source Apache License 2.0. Versions before OTP 18.0 were published under the open source ''Erlang Public License''.


ejabberd

Mnesia is also an option embedded within the Erlang-based
Jabber Jabber may refer to: * The original name of the Extensible Messaging and Presence Protocol (XMPP), the open technology for instant messaging and presence. * Jabber.org, the public, free instant messaging and presence service based on XMPP. * Jabber ...
daemon,
ejabberd ejabberd is an Extensible Messaging and Presence Protocol (XMPP) application server and an MQ Telemetry Transport (MQTT) broker, written mainly in the Erlang programming language. It can run under several Unix-like operating systems such as ma ...
.


See also

*
Riak Riak (pronounced "ree-ack" ) is a distributed NoSQL key-value data store based on Amazon's Dynamo paper, including its "tunable AP" approach, that is tunable consistency, to the tradeoffs imposed by the CAP Theorem. Riak offers high availability, ...
*
Apache Cassandra Cassandra is a free and open-source, distributed, wide-column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassand ...
*
Couchbase Couchbase Server, originally known as Membase, is an open-source, distributed ( shared-nothing architecture) multi-model NoSQL document-oriented database software package optimized for interactive applications. These applications may serve many ...
*
CouchDB Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang. CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using ...
*
LYME (software bundle) LYME and LYCE are software stacks composed entirely of free and open-source software to build high-availability heavy duty dynamic web pages. The stacks are composed of: * Linux, the operating system; * Yaws, the web server; * Mnesia or Couc ...


References

{{reflist, 30em Erlang (programming language) Free database management systems Structured storage