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

Network Security

1. Definition of security confidentiality: only sender, intended receiver should “understand” message contents sender encrypts message receiver decrypts message authentication: sender, receiver want to confirm identity of each other message integrity: sender, receiver want to ensure message not altered (in transit, or afterwards) without detection access and availability: services must be accessible and available to users. Access is the basis of availability. Without network security, the intruder can eavesdrop, insert messages, impersonation, hijacking(taking over ongoing connection), denial of service and so on. ...

Jan 06, 2022 · 5 min · Chasing1020

AKF Availability Cube

AKF Availability Cube 随着业务规模增长,拆解单体应用(monolith),设计成为面向服务架构(Service-oriented architectutre),做成一个个微服务(Micro-service)已经是如今的大趋势。 ...

Jan 03, 2022 · 3 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

Concurrency Programming

1. Implements volatile:声明后所有线程看到的改变量的值是一样的。写操作时,会添加Lock前缀的汇编。 保证了1. 保证缓存行的数据写回内存;2. 写回的操作会使其他缓存失效。 ...

Dec 05, 2021 · 7 min · Chasing1020