Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell concurrency and persistence

I've been reading the Beautiful Concurrency article about Haskell and STM.

The example given is a bank-account transfer.

Its a noddy bank transfer - its between two numbers sitting in heap memory.

The questions this immediately raises in my head are:

  1. how that transfer atomically hits disk. Until a bank transaction is recorded in a persistent - ACID - manner, it hasn't happened in my book. How do people using languages like Haskell - which won't let you do any IO inside an STM - actually really do atomic changes in data that isn't only in volatile memory?

  2. how to distribute this over many machines; how can you have distributed transactions and a scaling sideways application (without IO inside the STM)?

like image 653
Will Avatar asked Apr 04 '13 07:04

Will


1 Answers

STM is intended for thread synchronisation and communication, not for persistent storage of data. In other words, STM is designed to let threads share data between themselves without deadlocks or race conditions. Or for threads to send signals to each other. Or basically to coordinate thread activities.

If you want persistent data stored on disk, use a database. MySQL, PostgreSQL, Oracle, etc. There's a million to choose from. This is not the problem that STM is designed to solve.

For distributed processing... we're still working on that. I don't follow these things closely enough to comment on how close this is to being a reality.

like image 109
MathematicalOrchid Avatar answered Oct 13 '22 22:10

MathematicalOrchid