Your SSD lies but that's ok .. I think | Postgres fsync

Опубликовано: 24 Май 2023
на канале: Hussein Nasser
20,050
607

fsync is a linux system call that flushes all pages and metadata for a given file to the disk. It is indeed an expensive operation but required for durability especially for database systems. Regular writes that make it to the disk controller are often placed in the SSD local cache to accumulate more writes before getting flushed to the NAND cells.
However when the disk controller receives this flush command it is required to immediately persist all of the data to the NAND cells.

Some SSDs however don't do that because they don't trust the host and no-op the fsync, in some cases SSD buffers it for few microseconds to receive more writes and hope it doesn't crash in this microsecond. Others battery powered SSDs can completely ignore host flushes because it can survive a crash. In this video I explain this in details and go through details on how postgres provide so many options to fine tune fsync

0:00 Intro
1:00 A Write doesn’t write
2:00 File System Page Cache
6:00 Fsync
7:30 SSD Cache
9:20 SSD ignores the flush
9:30 15 Year old Firefox fsync bug
12:30 What happens if SSD loses power
15:00 What options does Postgres exposes?
15:30 open_sync (O_SYNC)
16:15 open_datasync (O_DSYNC)
17:10 O_DIRECT
19:00 fsync
20:50 fdatasync
21:13 fsync = off
23:30 Don’t make your API simple
26:00 Database on metal?

Fundamentals of Backend Engineering Design patterns udemy course (link redirects to udemy with coupon)
https://backend.husseinnasser.com

Fundamentals of Networking for Effective Backends udemy course (link redirects to udemy with coupon)
https://network.husseinnasser.com

Fundamentals of Database Engineering udemy course (link redirects to udemy with coupon)
https://database.husseinnasser.com

Follow me on Medium
  / membership  


Introduction to NGINX (link redirects to udemy with coupon)
https://nginx.husseinnasser.com

Python on the Backend (link redirects to udemy with coupon)
https://python.husseinnasser.com

Become a Member on YouTube
   / @hnasr  

Buy me a coffee if you liked this
https://www.buymeacoffee.com/hnasr

Arabic Software Engineering Channel
   / @husseinnasser  

🔥 Members Only Content
   • Members-only videos  



🏭 Backend Engineering Videos in Order
https://backend.husseinnasser.com

💾 Database Engineering Videos
   • Database Engineering  

🎙️Listen to the Backend Engineering Podcast
https://husseinnasser.com/podcast

Gears and tools used on the Channel (affiliates)

🖼️ Slides and Thumbnail Design
Canva
https://partner.canva.com/c/2766475/6...


Stay Awesome,
Hussein


Смотрите видео Your SSD lies but that's ok .. I think | Postgres fsync онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Hussein Nasser 24 Май 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 20,050 раз и оно понравилось 607 людям.