Every Computer System is a State Machine – TLA+ series (1)

This is the first post of a series of posts I plan to make about TLA+. This entire series is based on Lamport's TLA+ tutorial. What is a computer First, let's take a look at a very philosophical question -- "what is a computer?". I am writing this post on…

2 + 2 can be 22

I recently found this well-made short film, Alternative Math, https://www.youtube.com/watch?v=Zh3Yz3PiXZw. It became again after the University of Carlifornia decided 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…

API for Assigning Timestamp

This is a follow-up post of my previous one [https://blog.the-pans.com/notes-on-the-spanner/] 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…

Notes on the Google Spanner Paper

This is my notes on the paper: Spanner: Google’s Globally-Distributed Database [https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=2ahUKEwiM8NSx3p_pAhUOpp4KHRwAAoUQFjADegQIBBAB&url=https%3A%2F%2Fresearch.google.com%2Farchive%2Fspanner-osdi2012.pdf&usg=AOvVaw0jTMltcXSUju43NRB29vPi] . I will first…

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 of unsigned char. typedef unsigned char uint8_t;…

Understanding Paxos as a Read-modify-write Transaction

Paxos in one hand is very concise. It fits in a single slide. Paxos algorithm (https://blog.the-pans.com/paxos-explained/)On the other hand, Paxos is notoriously hard to apprehend. In this post, I will explain Paxos as a read-modify-write transaction, which is much more intuitive in my opinion. TL;…

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…