June 22nd, 2024

Postgres Schema Changes and Locking

Schema changes in Postgres can cause downtime by locking out reads and writes. Migration tools help mitigate issues. Breakages during migrations can affect client apps or lock database objects, leading to unavailability. Long queries with DDL statements can block operations. Setting lock_timeout on DDL statements can prevent queuing. Tools like pgroll offer backoff and retry strategies for lock acquisition failures. Understanding schema changes and DDL impact helps ensure smoother migrations and less downtime.

Read original articleLink Icon
Postgres Schema Changes and Locking

Schema changes in Postgres can lead to downtime by locking out reads and writes, but migration tools can help mitigate this issue. There are two main types of breakage during database migrations: changes that break client applications and changes that lock a database object for an unacceptable amount of time, causing application unavailability. Long-running queries combined with DDL statements can block reads and writes, leading to application downtime. To prevent this, setting a lock_timeout on DDL statements can help avoid queuing behind blocked operations. Tools like pgroll offer features like backoff and retry strategies to handle lock acquisition failures automatically. By understanding how schema changes and DDL statements can impact database operations, developers can ensure smoother migrations and minimize application downtime.

Related

Schema changes and the Postgres lock queue

Schema changes and the Postgres lock queue

Schema changes in Postgres can cause downtime due to locking issues. Tools like pgroll help manage migrations by handling lock acquisition failures, preventing application unavailability. Setting lock_timeout on DDL statements is crucial for smooth schema changes.

Avoiding Emacs Bankruptcy

Avoiding Emacs Bankruptcy

Avoid "Emacs bankruptcy" by choosing efficient packages, deleting unnecessary configurations, and focusing on Emacs's core benefits. Prioritize power-to-weight ratio to prevent slowdowns and maintenance issues. Regularly reassess for a streamlined setup.

Interface Upgrades in Go (2014)

Interface Upgrades in Go (2014)

The article delves into Go's interface upgrades, showcasing their role in encapsulation and decoupling. It emphasizes optimizing performance through wider interface casting, with examples from io and net/http libraries. It warns about complexities and advises cautious usage.

I found an 8 years old bug in Xorg

I found an 8 years old bug in Xorg

An 8-year-old Xorg bug related to epoll misuse was found by a picom developer. The bug caused windows to disappear during server lock, traced to CloseDownClient events. Despite limited impact, the developer seeks alternative window tree updates, emphasizing testing and debugging tools.

Software company plans to pay millions in ransom to hackers

Software company plans to pay millions in ransom to hackers

CDK Global faces a ransomware attack, disrupting operations at 15,000 car dealerships in North America. The company plans to pay hackers millions. The incident exposes the automotive industry's vulnerability to cyber threats.

Link Icon 2 comments
By @kroolik - 5 months
The locking part is often forgotten when discussing zero downtime migrations in postgres. As more and more operations become fast, more engineers will get bitten by this.

Ive telling this to engineers in my org for such a long time, now I also have a nice article to share :)

BTW, you don't need the pg_sleep and hurry with the execution. Simple BEGIN and COMMIT/ROLLBACK will give you infinite wait time :)