[rt-users] mysql DB engine ndbdcluster
alex at chmrr.net
Thu Dec 15 03:07:54 EST 2016
On Wed, 14 Dec 2016 09:42:42 -0500
Mike Diehl <mdiehlenator at gmail.com> wrote:
> At the risk of picking a fight, I'd like to understand this a bit better.
Happy to explain more -- and my instinct may have been wrong on one
count; see below.
> As long as the database supports minimum functions, such as transactions,
> joins, datatypes, etc., why should an application care about the underlying
> storage engine?
Because distributed databases have different properties around
atomicity and data locality than single-host databases. Applications
running atop such databases need to be built to accommodate these
correctness and performance properties.
The biggest issue is that of transaction isolation -- not all
transactions are equal. RT assumes that a database transaction gives it
"repeatable read" isolation from other transactions. This isolation
level, the default for InnoDB tables, means that essentially, upon
the first read, a snapshot of the state of the database is taken, and
it provides strong guarantees that regardless how long the transaction
is open, all queries within it will return consistent data.
I believe it likely (though I cannot prove, offhand) that RT assumes
repeatable read isolation semantics -- and NDB only offers "read
committed" isolation, which admits the possibility of different
results for the same query run twice within the same transaction.
However, upon writing this, it occurs to me that Postgres' default
isolation level is _also_ "read committed." Thus any possible race
conditions that might show up under NDB are also possible under
Postgres. I'd need to do some close analysis to determine if this
means that Postgres is open to data corruption, or if both are safe
because the queries RT runs do not care about repeatable-read
So NDB may actually be fine on this front.
The other property concerns data locality, and is purely a performance
constraint. NDB stores data across a cluster of data notes,
optionally with replication, which are queried by other hosts that
serve as SQL nodes. This means that joining data across tables
cannot be done in-memory, but instead may incur network-level
latencies to match up the data between data nodes -- meaning poor
MySQL Cluster 7.2 (equivalent to MySQL 5.5) does provide some tricks to
prevent this performance hit, but it's not clear that those
optimizations will be able to be applied to RT's queries, as not all of
the column types match between tables. It also doesn't get you all
of the way to InnoDB join performance. Finally, the tables may also
need explicit hinting in order to partition the data to give any sort of
locality across the hosts.
On the other hand, if you're deploying an NDB cluster, you may already
have the MySQL DBAs on-hand to attend to those. I've never heard of
an NDB deploy, discovering the correct partitioning scheme would be
all uncharted territory.
NDB clusters also don't support FULLTEXT indexes, though that's
clearly only an optional feature for RT.
Pescoller, consider me curious to hear back if you actually deploy RT
against and NDB cluster in production, and the performance
characteristics you see compared to single-host InnoDB.
 Repeatable read nominally opens up the possibility of "phantom
reads" where range queries can return inconsistent data from one query
to another; however, InnoDB uses some clever locking tricks to prevent
More information about the rt-users