DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > MongoDB & Bitcoin: How NoSQL Design Flaws Brought Down Two Exchanges

MongoDB & Bitcoin: How NoSQL Design Flaws Brought Down Two Exchanges

Alec Noller user avatar by
Alec Noller
·
Apr. 23, 14 · Java Zone · Interview
Like (0)
Save
Tweet
16.73K Views

Join the DZone community and get the full member experience.

Join For Free

On March 3rd, the Bitcoin exchange Flexcoin shut down after being hacked and catastrophically robbed. The hack was made possible, according to Emin Gün Sirer in this recent post on the topic, by a concurrency problem brought on by the use of NoSQL databases. To illustrate the problem, Sirer offers an analogy based on ATM withdrawals:

Now, consider what would happen if I duplicated my debit card, gave it to my best friend, synchronized our watches, and performed withdrawals at two different ATMs at the same time.

What's that I hear you say? Absolutely nothing bizarre would happen. My account would be deducted the right amount. That's because banks employ systems that guard against this kind of elementary error. They are based on transactions with ACID guarantees.

But if our bank was implemented using a first-generation NoSQL datastore, say MongoDB, we'd see something very different.

Hacked websites and flawed code are not necessarily notable events, but this one stands out, not only because of the quantity of the loss (896 BTC, according to Sirer), but because of the simplicity of the problem: These kinds of concurrency issues are well-known and there are numerous ways to get around them. From Sirer's point of view, the big problem is not this individual failure, but that these issues are built into NoSQL solutions:

Yes, yes, the broken-by-design apologists will trot out the usual refrain that goes "there is nothing wrong with MongoDB as long as you always deploy it knowing that it can give you back bogus answers." Yeah well, there is nothing wrong with flammable mattresses either, just make sure there is no source of ignition nearby. It just turns out that we then get charred family tragedies, because people are fallible.

And as it turns out, it wasn't just a fluke issue with Flexcoin. Sirer points to another Bitcoin exchange, Poloniex, which suffered from the same design flaw, and he even points to a possible third example as well. The scary part, Sirer suggests, is the built-in nature of the problem. This wasn't a burglars-picking-your-lock situation, after all; it's more like the door was left open. 

Check out Sirer's full post for more details on the collapse of Flexcoin and Poloniex, and for thoughts on how one might avoid such catastrophes even when using NoSQL databases.

NoSQL Bitcoin MongoDB Design

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Implementing Microservices Architectures
  • Java Microservices: Code Examples, Tutorials, and More
  • How to Build Microservices With Node.js
  • To Shift Right, You Need Observability

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo