Posts

Showing posts with the label concurrency

Golang Practice Series

Image
Introduction Golang (or Go) is an open-source programming language developed by Google in 2007 and officially launched in 2009 by leading engineers including Robert Griesemer, Rob Pike and Ken Thompson . Go was designed to solve problems regarding performance, source code complexity and system scalability in the Cloud Native era. Advantages High performance ( Compiled Language ): Go compiles directly into machine code without going through an intermediate execution environment like JVM , resulting in extremely fast execution speeds and very low hardware resource consumption. Superior asynchronous processing (Concurrency): Go possesses a super-lightweight Goroutine mechanism (costing only about 2KB of initial memory compared to several MB for traditional Threads ) combined with Channels , allowing for easy handling of millions of concurrent connections. Simple syntax, easy to learn: Go syntax is simplified, eliminating complex concepts (such as class inheritance, funct...

Row-level Locks

Image
Introduction Row-level locks are used to protect specific rows when data is being modified. Unlike table locks, Postgres does any row lock storage outside of RAM, writing them directly into the tuples (data rows) on the hard disk to avoid memory overflow. Differences Table-level Lock (8 modes): Protects the table schema and controls broad behaviors, such as full-table reads, table writes, or column alterations. You can imagine these 8 modes as "admission tickets" that control who can enter the building and what they can do inside. Row-level Lock (4 modes): Protects the actual data values inside specific rows to prevent two people from modifying the same record simultaneously. It is like locking individual small rooms inside the building. Connections Although Table-level Lock and Row-level Lock are two distinct sets of lock modes, they always run in parallel and support each other. When you act on a row, Postgres automatically assigns both a table lock and a row lock under...