mnesia

Merging records for Mnesia

Hi.. I am trying to refactor some code I have for software that collects current status of agents in a call queue. Currently, for each of the 6 or so events that I listen to, I check in a mnesia table if an agent exists and change some values in the row depending on the event or add it as new if the agent doesn't exist. Currently I have...

Mnesia table replication/sharing

Assume that we have N erlang nodes, running same application. I want to share an mnesia table T1 with all N nodes, which I see no problem. However, I want to share another mnesia table T2 with pairs of nodes. I mean the contents of T2 will be identical and replicated to/with only sharing pair. In another words, I want N/2 different conte...

Mnesia write fails

I defined a record named log. I want to create an mnesia table with name log_table. When I try to write a record to table, I get bad_type error as follows: (node1@kitt)4> mnesia:create_table(log_table, [{ram_copies, [node()]}, {attributes, record_info(fields, log)}]). {atomic,ok} (node1@k...

Is it possible to develop a Powerful WEB Search Engine using Erlang, Mnesia & YAWS???

I am thinking of developing A Web search Engine using Erlang, Mnesia & YAWS. Is it possible to make powerful & fastest WEB SEARCH ENGINE using these???? What will it need to accomplish this & HOW to start with???? If you have any suggestions, I'll be greatful to you. ...

Suitable data storage backend for Erlang application when data doesn't fit memory

I'm researching possible options how to organize data storage for an Erlang application. The data it supposed to use is basically a huge collection of binary blobs indexed by short string ids. Each blob is under 10 Kb but there are many of them. I'd expect that in total they would have size up to 200 Gb so obviously it cannot fit into me...

Preserving relational integrity with Mnesia

I've been diving into Erlang recently, and I decided to use Mnesia to do my database work given it can store any kind of Erlang data structure without a problem, scale with ease, be used with list comprehensions, etc. Coming from standard SQL databases, most rows can and should be identified by a primary key, usually an auto-incrementin...

How to ensure fast startup times of mnesia

Erlang with mnesia/dets is famous for it slow startup times after a crash. Basically the same issue as with fsck on older filesystems. But I also experience slow startup times after regular shutdowns: about 8 Minutes for 250 MB on-disk data on a beefy machine. So I have to do something special on shutdown besides typing "q()."? Is ther...

What is the storage capacity of a Mnesia database?

Some places state 2GB period. Some places state it depends up the number of nodes. ...

How to rename the Node running a mnesia Database

I created a Mnesia database / Schema on machine1. The node was named mypl@machine1. I then moved all files to machine2, because machine1 broke down. Everything runs fine as long as the code is running with the name "mypl@machine1". Obviously this is somewhat confugsing, because it is now running on machine2. If I start Erlang with the n...

Mnesia transactions

hello accidentally some code that I'm writing is slowly turning into a DB system on its own, with incremental indexing, freeform "documents" (aka CouchDB kind) which can have arbitrary properties... annyyywaay... I decided to keep evolving it, mainly for educational purposes, and also to really tightly customize it just for my needs and ...

How do you design a schema to efficiently query nested items in a key-value database?

I'm using Mnesia with Erlang, but this question applies to any key-value db like couchdb, etc. I'm trying to break free of the RDBMS thought process, but I can't wrap my head around how to efficiently implement this kind of schema. Say I have a User record, and he has many SubItemA records, which has many SubItem B records, so: User -...

Online mnesia recovery from network partition

Is it possible to recover from a network partition in an mnesia cluster without restarting any of the nodes involved? If so, how does one go about it? I'm interested specifically in knowing: How this can be done with the standard OTP mnesia (v4.4.7) What custom code if any one needs to write to make this happen (e.g. subscribe to mnes...

mnesia delete_object exception?

I don't see what's wrong here, but I may just misunderstand the syntax. I'm trying to delete a "user" record from my "user" mnesia table who have the first name of "ryan" (there are multiples of them). Here is what I do: Delete=#user{first_name = "ryan", _ = '_'}, mnesia:dirty_delete_object(Delete) Here is my record definition: -reco...

Safe, Sequential And Scalable Counters In Mnesia

I am writing an application in Erlang/OTP and want to use sequential counters on a version recording system. I first implemented them with mnesia:dirty_update_counter but the experience of using it drove out these hard requirements: The counters must have the following properties: be strictly sequential - 1 followed by 2 followed by ...

In a mnesia cluster, which node is queried?

Let's say you have a mnesia table replicated on nodes A and B. If on node C, which does not contain a copy of the table, I do mnesia:change_config(extra_db_nodes, [NodeA, NodeB]), and then on node C I do mnesia:dirty_read(user, bob) how does node C choose which node's copy of the table to execute a query on? ...

What's the best way to prevent adding a record whose primary key is already present in mnesia?

Suppose I've got a simple record definition: -record(data, {primary_key = '_', more_stuff = '_'}). I want a simple function that adds one of these records to a mnesia database. But I want it to fail if there's already an entry with the same primary key. (In the following examples, assume I've already defined db_get_data(Key)-> ...

How to add a node to an mnesia cluster?

Hello, I'm an erlang and mnesia newbie.. How do I add a new disc_only_copies node to an mnesia database that already has a schema? Thanks ...

how do I remove an extra node

I have a group of erlang nodes that are replicating their data through Mnesia's "extra_db_nodes"... I need to upgrade hardware and software so I have to detach some nodes as I make my way from node to node. How does one remove a node and still preserve the data that was inserted? [update] removing nodes is as important as adding them....

detecting data/node partition errors

The last time I saw a data/partition node error it was because I launched the erlang shell which connected to the node on the same CPU via cookies etc. Immediately after startup the shell dumped the partition error on the screen. This is terribly bothersome.... how do I trap this exception? how do I repair the exception programatically...

Differences between set and ordered_set in Mnesia?

What are the differences between a table of type set, and a table of type ordered_set? I'm interested in the differences in read/write performance, what the ordering is based on, the effects across distributed nodes, and such. ...