TinySQL Implementation

本次实现是关于 PingCap Talenet Plan 2022 TinySQL 学习营相关的实验解题思路。本次实验可以作为 CMU 15-445 的补充,主要内容为每周的讲座+通过Lab的所有测评 Case ,总体实现难度并不高,以下是每个 Project 实现的具体思路细节。 ...

Aug 13, 2022 · 7 min · Chasing1020

Distributed Transaction

The Eight Fallacies of Distributed Computing by Peter Deutsch. Essentially everyone, when they first build a distributed application, makes the following eight assumptions. All prove to be false in the long run and all cause big trouble and painful learning experiences. The network is reliable Latency is zero Bandwidth is infinite The network is secure Topology doesn’t change There is one administrator Transport cost is zero The network is homogeneous 1. 2PC XA规范中定义的分布式事务模型包括四个组成部分: ...

Jan 08, 2022 · 5 min · Chasing1020

Gorm Source Code

Gorm Source Code 1. sql.DB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // driverConn wraps a driver.Conn with a mutex, to // be held during all calls into the Conn. (including any calls onto // interfaces returned via that Conn, such as calls on Tx, Stmt, // Result, Rows) type driverConn struct { db *DB createdAt time.Time sync.Mutex // guards following ci driver.Conn needReset bool // The connection session should be reset before use if true. closed bool finalClosed bool // ci.Close has been called openStmt map[*driverStmt]bool // guarded by db.mu inUse bool returnedAt time.Time // Time the connection was created or returned. onPut []func() // code (with db.mu held) run when conn is next returned dbmuClosed bool // same as closed, but guarded by db.mu, for removeClosedStmtLocked } sql.DB数据结构对数据库做了一层简单的抽象,但是需要明确的是:sql.DB不是一个连接,也不是映射到任何DataBase或者是Schema的概念。 ...

Dec 22, 2021 · 5 min · Chasing1020

Database Systems

Reference Book: Database System Concepts Seventh Edition 1. Relational Model Readings: Chapters 1-2, 6 Definition DataBase: Organized collection of inter-related data that models some aspect of the real-world. Databases are the core component of most computer applications. A database management system (DBMS) is software that allows applications to store and analyze information in a database. A general-purpose DBMS is designed to allow the definition, creation, querying, update, and administration of databases. Data Model: is a collection of concepts for describing the data in a database. Schema: is a description of a particular collection of data, using a given data model. ...

Nov 25, 2021 · 66 min · Chasing1020