Why Is Atomicity Not Enough?

When we study transactions in relational databases, one of the first things we learn are the guarantees that a transaction must provide. ACID(Atomicity, Consistency, Isolation, Durability) are the properties that we desire. Here, I will discuss the Isolation level in more detail and show that atomicity alone is not enough when handling concurrency.

One classic example of the importance of atomicity is moving money between accounts. So, imagine that we have two accounts and we would like to transfer the total amount from one account to another one. In a relational database, what we need to do is three steps:

[Read More]

Quicksort

The Quicksort algorithm was created by Tony Hoare in 1961 and it is a very powerful algorithm to sort an array in memory until today. Here, I will describe the Quicksort algorithm, show an implementation in Python, and analyze the time complexity of this algorithm in the worst and best scenarios.

The idea behind the Quicksort is so simple: to sort an array \(V\) of \(n\) elements, it is easier to sort smaller sub-arrays of \(V\). We can think of this approach as divide-and-conquer, where we break a problem into smaller sub-problems and combine their solutions to form the solution to the original problem.

[Read More]

Designing Data-Intensive Applications: Review

Disclaimer: Don’t read this review, go ahead and read the book, it will be much better for you. The only reason that I wrote this is for my future reference.

First of all, I love to read books and I do not believe that a review should influence someone to read or not a book. However, as a researcher, one of the most important things that I learned during my years at the university was the importance to write a review of papers. After reading a paper, we should write a review. Not to publish, but to describe in our words what we read and also to future references. So, do not expect here a complete resume of the book or the concepts present in it. Also, do not think that this is a replacement or a complement of the book, it is not. This book is fantastic and you should read it if you like this subject.

[Read More]

Chrome with selenium, python and docker

Sometimes, when I execute the Chrome inside a docker container I receive the error below:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed

It is caused because Chrome uses the /dev/shm to share memory and the docker, by default, set 64MB for this partition.

Here, I will describe how to reproduce this error and how to resolve it.

How to reproduce

To reproduce this error, we need to create a docker image with chrome and python. Then, I created this Dockerfile which uses a multi-stage build to install the chrome and the python.

[Read More]