Difference between Cassandra’s Consistency Level ANY and ONE

Just a short note this time. I’ve noticed that there’s a thing that some of the people miss when trying to understand Cassandra’s data model and the two “weakest” Consistency Levels for writes: ANY and ONE. What’s the difference? For CL.ONE it’s required that at least one replica responssible for a specific key, pointed by Partitioner, is able to receive a request and write the data. For CL.ANY it’s required that request is received by any node, including the node that is not responssible for a key. In this case Hinted Handoff will be used and data will by send to proper replicas when they’re available. However, keep in mind that it may happen, that a node that received such query will crash before any of the replica nodes will be able to receive a HH request. In this case, if you fail to recover that node (i.e. because of hardware failure) these data will be lost forever. You have been warned.

Removing Cassandra snapshots from all the nodes at once

Sometimest you might want to clean your nodes by removing some snapshots that you don’t need. Even if you did not create them, they might be there – Cassandra makes them before scrub or before truncate. However, removing them one by one from the whole cluster might be a pain, so I wrote a short script that does it.

Continue reading

Safe Cassandra shutdown and restart

If you are a Cassandra user you’re probably experienced enough to know how to stop or restart Linux services – that’s an obvious thing. However in some cases it might be a problem if a service you turned off goes down, especially if other services have been using it. While Cassandra is very robust and crash-safe (pkill -9 cassandra works fine ;-) ), it’s never a bad idea to do things in a way that minimizes the risk of something going wrong. The other advantage of clean Cassandra restart procedure is saving some startup time. Here is how to do it.

Continue reading

Make SimpleAuthority work with Cassandra 1.1.6 permissions

A few days ago I was about to upgrade Cassandra cluster from 1.1.0 (+ Authentication patch I wrote) to 1.1.6, but – a bit surprisingly – I realized that something is wrong with new Cassandra. I had no problems with creating keyspaces before, as I set proper modify-keyspaces property in access.properties, but after the upgrade it stopped to work. After a short investigation I found out that there were some significant changes in Cassandra’s Permission system which broke SimpleAuthenticator. This article is about how to make it work again.

Continue reading

More on Cassandra’s SimpleAuthority permissions

Few days ago I had some doubts on how Cassandra’s SimpleAuthenticator and SimpleAuthority really work. I mean – I was not sure of the way I should configure them to get the expected results. It may seem obvious now, but I had to look at source code to find out what is possible and what is not. So, to save your time, here’s a brief description of this.

Continue reading

My first Cassandra contribution

A bit surprisingly and somehow accidentally, today I became a Cassandra contributor. I had a problem with the project I do for work, which made us unable to make our bulkloading script work together with Cassandra authentication (which I described in one of the previous articles on this blog), so we decided to try solving this issue on our own.

The solution was quite simple, but gave me a bit more of Cassandra knowledge and understanding. If you are interested in contributing to Cassandra I think you can take a look at this problem and the solution or even try to reproduce this problem (on Cassandra 1.1.0-rc1 or earlier) and then try to solve it on your own. As I said it was simple, so you won’t get frustrated with the problems you will face, but I think it’s good start for something more. Here is the link to Cassandra’s bug tracker issue:

https://issues.apache.org/jira/browse/CASSANDRA-4155

Working on interesting things, being nicely paid for this and contributing to remarkable Open Source projects in the same time – could it be any better? ;)

Adding simple authentication to Cassandra

Today I was asked to set up user authentication in Cassandra, so we could stop using the “default” user with unrestricted access only. I have to say that I was really surprised when I noticed that there’s NO out-of-the-box authentication and authorization framework in it. Luckily, it can be easily enabled in a few steps which I’m going to show you.

One important thing – SimpleAuthenticator we’re going to use is in the “examples” directory of Cassandra package. It’s because it is considered to be very simple and not very safe (it was even called a “toy” in one of Cassandra’s Jira tasks), so DO NOT rely on it as on a serious protection tool for your system. However it still fits many requirements (i.e. you don’t want user to make a mess in a Column Family he doesn’t need to work on) so you may find it useful. You have been warned.

Continue reading