ACID in Database – D for Durability

  • 2024/9/11
  • ACID in Database – D for Durability はコメントを受け付けていません

Durability

Overview

In the world of databases, there are several principles that ensure data integrity and consistency. These principles are collectively known as ACID, which stands for Atomicity, Consistency, Isolation, and Durability. Each of these principles plays a crucial role in maintaining reliable and accurate data.

Atomicity ensures that all parts of a transaction are completed successfully or none at all.

Consistency guarantees that a transaction brings the database from one valid state to another, maintaining all predefined rules and constraints.

Isolation ensures that transactions are executed independently and transparently, without interference from concurrent transactions.

You can check my blogs about these topics by clicking the first word of each above line 😀

 

What is Durability?

Durability refers to the ability of a database to ensure that once a transaction has been committed, it remains so, even in the event of a system failure or crash. This means that once a transaction has been successfully completed and confirmed, its effects are permanent and will not be lost or undone.

Let’s breakdown the key aspects of durability

1/ Atomic Commit

Think of this as the database’s way of making a promise: once a transaction is committed, its changes are set in stone. This means that even if the system crashes or loses power right after the commit, the changes won’t disappear. It’s all about ensuring that once a transaction is completed, it is reliably preserved.

2/ Write-Ahead Logging (WAL)

To keep data safe, most databases use a technique called write-ahead logging. Here’s how it works: before any changes are made to the actual database, they are first recorded in a log file. If something goes wrong, the database can look at this log to either redo or undo the changes, ensuring that no data is lost.

3/ Checkpointing

Imagine taking snapshots of your data at regular intervals. This is essentially what checkpointing does. By periodically saving a consistent snapshot of the database state, the system can recover to this point if there’s a failure. Any changes made after the last checkpoint are then applied from the log, ensuring that you don’t lose recent updates.

4/ Replication

Replication is like having backup copies of your data in multiple places. By writing data to several copies of the database, you protect against data loss. If one copy fails, the others still have the data, so you don’t lose anything important.

5/ Crash Recovery

Even with all the safeguards in place, crashes can still happen. That’s where crash recovery comes into play. Databases use logs to recover committed data after a crash, applying any necessary changes to restore the database to its last known good state.

6/ Data Integrity

Durability isn’t just about keeping data from disappearing; it’s also about maintaining its integrity. This means ensuring that the data remains accurate and consistent, even after unexpected failures. The database’s mechanisms work to ensure that committed transactions are fully and correctly reflected in the database.

7/ Failover Mechanisms

In more complex systems, failover mechanisms are crucial. If the primary server encounters a problem, a backup server can take over seamlessly. This ensures continuity of service and prevents data loss, even when hardware or software issues arise.

Conclusion

It ensures that once data is committed, it remains secure and intact even if the system experiences crashes or failures. Without durability, there is a risk of losing or corrupting data, which can have serious consequences for businesses and users. Techniques like write-ahead logging, replication, and checkpointing help protect data by providing a safety net that ensures consistency and availability. Ultimately, durability is crucial because it keeps data accurate and reliable, allowing organizations to function smoothly and handle unexpected issues with confidence.
Thanks for reading.

関連記事

カテゴリー:

ブログ

情シス求人

  1. チームメンバーで作字やってみた#1

ページ上部へ戻る