2 + 2 can be 22

I recently found this well-made short film, Alternative Math, https://www.youtube.com/watch?v=Zh3Yz3PiXZw. It's popular again after University of Carlifornia decides to stop using ACT/SAT. I am a father of two young children. And I think everyone, including the teacher in the film, can do better.…

API for Assigning Timestamp

This is a follow-up post of my previous one about Spanner. There I talked about how Spanner uses TrueTime API to achieve external consistency at global scale and hide sharding and replication from users. In this post, I want to discuss different options of assigning timestamps and their usefulness to…

Notes on the Google Spanner Paper

This is my notes on the paper: Spanner: Google’s Globally-Distributed Database. I will first summarize the paper and try to explain how it works. At the end, I will list my opinion and questions about Spanner. What is Spanner It's a globally replicated database that hides sharding and replication.…

Unary Plus

A few times I ran into the following issue uint8_t a = 0; std::cout << "a = " << a << std::endl; Guess what would it print? a = What happened here is that it printed NULL (0) in ASCII. uint8_t is just a typedef…

Stack overflow

I recently ran into a program crash. There were some mysteries at the beginning of the debugging process. Mysteries Signal handler not called The program crashed with a coredump, according to which, it crashed with SIGSEGV. The mystery is that the code has registered a signal handler, which should get…

Re-entrant vs. Thread-safe

These two are very different concepts but can be confusing. re-entrant is used to describe a function in a single-threaded environment, thread-safe in multi-threaded environment on the other hand. A function can be both re-entrant and thread-safe, either re-entrant or thread-safe, or neither. A function is re-entrant, if it can…

Discover Paxos via 2pc

2pc and Paxos are solving the same problem Two Phase Commit, a.k.a 2pc, is a very well-known and intuitive algorithm, often used for coordinating transactions. Paxos is a well-known consensus algorithm, often used for replication on a stateful service. Paxos is less intuitive and harder to grasp. Atomic…

Compare Small Versions that Wrap Around

Why use small versions Almost all stateful services (data store, cache, etc.) have versions stored along with each piece of data. The version can be in the form of a timestamp, version (a.k.a logical clock), or even better -- Hybrid Logical Clock. If it's a data store, HLC…

Notes on the Amazon Aurora Paper

This is my notes on the paper: Amazon Aurora: Design Considerations for High Throughput Cloud-Native Relational Databases. What's Amazon Aurora Functionally speaking, an instance of Aurora is same as an instance of MySQL. The differences are Aurora decouples compute from storage and it's fault-tolerant. It supports all ANSI isolation levels…