Rust Learning Note


Explore Rust

Chapter 3 Types

Arrays

不支持动态开数组:

// an array of 100 int32 elements, all set to 1
let mut arr1 = [1;100]; // correct
let n = 100;
let mur arr2 = [1;c]; // error

Vectors

let mut arr = vec![0,6,4,8,1];
arr.sort() // increasing order
arr.sort_by(|a,b| b.cmp(a)) // decreasing order

If you know the number of elements a vector will need in advance, instead of Vec::new you can call Vec::with_capacity to create a vector with a buffer large enough to hold them all, right from the start.

Read more ⟶

Paper Note: Towards Transaction as a Service


Background

Database systems have evolved to be with a cloud-native architecture,i.e., disaggregation of compute and storage architecture, which decouples the storage from the compute nodes, then connects the compute nodes to shared storage through a high-speed network.

Read more ⟶

A Piece Of: Go Tests


最近在写毕设项目时,总是发现有些单元测试在 VSCode 的 Testing Panel 连续运行测试时无法通过,但是单独运行时能正常通过,困扰了我好长一段时间。

有一次我发现了一个盲点:

在我写的框架中,有一个 config.go 文件:

Read more ⟶

Paper Note: Scalable Distributed Transactions across Heterogeneous Stores


FAQ

What is the difference between rolling backward and rolling forward in database transactions?

“Rolling backward” and “rolling forward” in the context of database transactions refer to two distinct phases of the recovery process that helps maintain the integrity and consistency of the database after a system crash or failure. These concepts are tied to the idea of transaction logs that record the changes made to the database. Below are the key differences between rolling backward and rolling forward:

Read more ⟶

Paper Note: GRIT: Consistent Distributed Transactions across Polyglot Microservices with Multiple Databases


FAQ

What is a deterministic database?

A deterministic database is a system where the outcomes of any database operations are guaranteed to be the same every time they are executed, provided that the operations are started from the same database state. This concept implies a level of reliability and predictability in the behavior of the database system.

Read more ⟶

Paper Note: How to Read a Paper


The Three-Pass Approach

Each pass accomplishes specific goals and builds upon the previous pass:

Read more ⟶

Talk about Postgres Visibility Check Rules


Background

最近在看分布式事务相关的论文,很多论文设计的系统中都实现的是快照隔离这一层次的机制,其中 Epoxy 最为典型,直接把 Postgres 的快照隔离机制在中间层重新实现了一遍。

之前看关于 Postgres 快照隔离机制的文章,找到了这个:PostgreSQL并发控制,讲得非常好,逻辑非常清晰,理论和实际例子相结合。

这篇文章中关于 Visibility Check Rules 的部分讲的非常详细,但是没啥规律,可归纳性不强,我时不时就会回来看看这一段,但每次看的时候好像都要从头再重新理解一遍,于是最近我整理了一下这十条规则,力求达到清晰有序。

Read more ⟶

Paper Note: Ad Hoc Transactions in Web Applications: The Good, the Bad, and the Ugly


这篇文章讲道理不应该写这么长的,但讲的东西比较“好玩”,于是就多记录了一些。

FAQ

What is an ad hoc transaction?

It refers to database operations coordinated by application code. Specifically, developers might explicitly use locking primitives and validation procedures to implement concurrency control amid the application code to coordinate critical database operations.

Read more ⟶

A Piece Of: ThreadLocal


原理

img

ThreadLocal 是一种线程局部变量,它为每个线程提供了一个独立的变量副本,所以每个线程都可以拥有自己的局部变量,互不影响。

ThreadLocal 可以做到线程隔离的原因在于,每次创建 ThreadLocal 的时候,都会创建一个新的线程局部存储区,这个存储区只存在于当前线程中,其他线程无法访问到。这样就实现了线程之间的隔离,每个线程都可以在自己的线程局部存储区中保存自己的数据,互不影响。

使用方法

管理 Connection

ThreadLocal 的相关知识我查过多次,一直不理解为什么使用 ThreadLocal 可以起到“管理 Connection”的作用,我之前的疑问是这样的:

Read more ⟶

Note: WSL2 Mirrored 网络模式下异常情况总结


Background

前段时间看到了 Windows Subsystem for Linux September 2023 update - Windows Command Line 这篇文章后,发现了 WSL 2 的新网络模式挺有意思的:

Read more ⟶