thảo luận Hội Dev 35 đi phỏng vấn tìm việc.

  • Người tạo chủ đề Người tạo chủ đề Kaiser2013
  • Ngày bắt đầu Ngày bắt đầu
Ý bác là doublewrite buffer? Nếu vậy thì mình nghĩ cái này không đúng. WAL là tận dụng tốc độ sequential write để tăng tốc độ write ( commit) của DB. Tuy vậy không phải vì doublewrite buffer nên phải có WAL, vì WAL xảy ra trước.
Doublewrite buffer xảy ra sau này, khi cần flush dirty innodb pages xuống disk, ở đây dirty pages được gom lại vào một buffer -> ghi xuống disk sequentially -> sau đó mới write tiếp đến đúng vị trí page trên disk. Doublewrite buffer lúc này dùng để recovery torn page, những chỗ "sau đó mới write tiếp đến đúng vị trí page trên disk" mà lỗi.
Ai da.

Bạn có thể đọc thêm về WAL tại đây

Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after WAL records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the WAL records. (This is roll-forward recovery, also known as REDO.)

PS, à hình như mình hiểu ý bạn rồi. Đúng WAL enable senquential writes, nhưng mà enable gián tiếp, nghĩa là sử dụng WAL cho phép bạn sử dụng buffer writes (cái này mới là trực tiếp) mà không lo lắng về việc mất dữ liệu trong trường hợp xảy ra crash.
 
Sửa lần cuối:
Ai da.

Bạn có thể đọc thêm về WAL tại đây

Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after WAL records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the WAL records. (This is roll-forward recovery, also known as REDO.)
Mình không hiểu ý bác gửi link này nghĩa là gì? mình hiểu WAL, và cái link này nó không phản biện gì những điều mình nói ở trên.

Ở link trên
after WAL records describing the changes have been flushed to permanent storage.
Cái quan trọng là permanent storage -> ở đây chính là sequential block ở trên disk.

we do not need to flush data pages to disk on every transaction commit
Cái này nghĩa là không phải flush data pages ( đa số là innodb pages) NGAY lúc commit, mà làm sau hay như mình nói ở trên "sau đó mới write tiếp đến đúng vị trí page trên disk". Chính là lúc mà doublewrite buffer xuất hiện để tối ưu việc data pages k bị half written, và dùng để recover ở data page level.
 
Mình không hiểu ý bác gửi link này nghĩa là gì? mình hiểu WAL, và cái link này nó không phản biện gì những điều mình nói ở trên.

Ở link trên

Cái quan trọng là permanent storage -> ở đây chính là sequential block ở trên disk.


Cái này nghĩa là không phải flush data pages ( đa số là innodb pages) NGAY lúc commit, mà làm sau hay như mình nói ở trên "sau đó mới write tiếp đến đúng vị trí page trên disk". Chính là lúc mà doublewrite buffer xuất hiện để tối ưu việc data pages k bị half written, và dùng để recover ở data page level.
Ý mình là Buffer Writes là một trong những lý do cho sự ra đời của WAL. Bạn buffer một tập hợp các writes trước khi thực sự ghi nó vào đĩa.
 
Ý mình là Buffer Writes là một trong những lý do cho sự ra đời của WAL.
Một lần nữa mình muốn confirm lại: ý bác là Buffer Writes hay DoubleWrite Buffer?

Mà dù là cái nào đi nữa, thì nó cũng không liên quan đến WAL, 2 cái phục vụ mục đích khác nhau.

DoubleWrites buffer trong DB giải quyết vấn đề khác, thậm chí, nếu nói lai rai ra thì chính vì do ông WAL ghi sequential khi commit, nên ông doublewrites mới phải đi sau để dọn rác của ông WAL, đặt data pages về đúng chỗ.
 
Một lần nữa mình muốn confirm lại: ý bác là Buffer Writes hay DoubleWrite Buffer?

Mà dù là cái nào đi nữa, thì nó cũng không liên quan đến WAL, 2 cái phục vụ mục đích khác nhau.

DoubleWrites buffer trong DB giải quyết vấn đề khác, thậm chí, nếu nói lai rai ra thì chính vì do ông WAL ghi sequential khi commit, nên ông doublewrites mới phải đi sau để dọn rác của ông WAL, đặt data pages về đúng chỗ
Ok thống nhất nói về DoubleWrites buffer đi.


The doublewrite buffer is a storage area where InnoDB writes pages flushed from the buffer pool before writing the pages to their proper positions in the InnoDB data files. If there is an operating system, storage subsystem, or unexpected mysqld process exit in the middle of a page write, InnoDB can find a good copy of the page from the doublewrite buffer during crash recovery.

Vậy là doublewrites buffer giúp thực hiện sequential writes.

Còn WAL (mysql là redo log)


The redo log is a disk-based data structure used during crash recovery to correct data written by incomplete transactions. During normal operations, the redo log encodes requests to change table data that result from SQL statements or low-level API calls. Modifications that did not finish updating data files before an unexpected shutdown are replayed automatically during initialization and before connections are accepted. For information about the role of the redo log in crash recovery, see Section 17.18.2, “InnoDB Recovery”.

WAL đảm bảo data integrity.
 
Ý mình là Buffer Writes là một trong những lý do cho sự ra đời của WAL. Bạn buffer một tập hợp các writes trước khi thực sự ghi nó vào đĩa.
quote thêm phần bác ghi.

WAL ra đời để nhằm mục đích tận dụng tối đa hiệu năng sequential write của ổ cứng, việc bác buffer hay không, không "quá quan trọng". Và để WAL đáng tin cậy sau mỗi commit, thì phải flush xuống permanent storage ngay khi commit, việc này đi ngược lại mục đích của buffer ở mem rồi flush xuống disk.

Còn doublewrite buffer là câu chuyện khác.
 
Ok thống nhất nói về DoubleWrites buffer đi.


The doublewrite buffer is a storage area where InnoDB writes pages flushed from the buffer pool before writing the pages to their proper positions in the InnoDB data files. If there is an operating system, storage subsystem, or unexpected mysqld process exit in the middle of a page write, InnoDB can find a good copy of the page from the doublewrite buffer during crash recovery.

Vậy là doublewrites buffer giúp thực hiện sequential writes.

Còn WAL (mysql là redo log)


The redo log is a disk-based data structure used during crash recovery to correct data written by incomplete transactions. During normal operations, the redo log encodes requests to change table data that result from SQL statements or low-level API calls. Modifications that did not finish updating data files before an unexpected shutdown are replayed automatically during initialization and before connections are accepted. For information about the role of the redo log in crash recovery, see Section 17.18.2, “InnoDB Recovery”.

WAL đảm bảo data integrity.

Vậy mình đưa cho bác 1 case để bác hiểu tại sao cần doublewrite buffer. Ví dụ trên innodb page có page corrupt, hoặc checksum mismatch, thì bác duyệt lại toàn bộ WAL hay đọc lại ở doublewrite buffer ( ở disk) để sửa lại phần đó?
 
Vậy mình đưa cho bác 1 case để bác hiểu tại sao cần doublewrite buffer. Ví dụ trên innodb page có page corrupt, hoặc checksum mismatch, thì bác duyệt lại toàn bộ WAL hay đọc lại ở doublewrite buffer ( ở disk) để sửa lại phần đó
Thôi mình sai, nhưng WAL không phải mục đích là enable sequential writes.
 
mấy bạn làm ơn đừng xl dăm ba cái DB internals nữa được không, mình nói thẳng là mình đéo thấy có gì lq tới cái topic hết
Thì sao đâu, ai chả có nhu cầu được var chạm :sexy_girl:

Hình như box LT cũng chưa có thớt nào cho các Data Engineering vào giao lưu kết hợp. Nên tiện đâu thì chém đó thôi có gì mà khó khăn.
 
IMG_4465.jpeg
 
side project mà thuê hẳn VPS $50/m có lãng phí quá không :ops:

Tôi cũng làm cái web app mà còn đang lăn tăn con vps ~$8/m liệu có thừa thãi quá không đây. Lúc đầu cũng xác định làm gì có users đâu mà.
8$ sợ không cài nổi 1 con docker nhét frontend, backend, DB, Redis, Kafka cùng chạy
 
thấy bạn đưa được số liệu của web mình tháy cũng ý nghĩa, đang định nghiên cứu golang, thấy nó ngon chứ bạn nhỉ, C++ mình ko làm ,nhưng thấy hệ thống lớn đưa c++ vào chắc ko tuyển đủ dev mất
Golang ngon chứ, performance, cộng đồng lớn, job nhiều. Trừ khi bạn làm mảng liên quan HFT hoặc có background làm C++ trước đó thì có thể dùng C++ cho backend, chứ Golang đáp ứng được hết.
 
Golang ngon chứ, performance, cộng đồng lớn, job nhiều. Trừ khi bạn làm mảng liên quan HFT hoặc có background làm C++ trước đó thì có thể dùng C++ cho backend, chứ Golang đáp ứng được hết.
Vì sao Golang performance nó tốt? Bởi vì nó tối giản toàn bộ các component để dễ chạy, để làm việc :| Thằng Java + Spring nó chạy chậm vì nó load quá nhiều các component vào để việc dev được nhanh chóng hơn. Đến một ngày, framework của Go cũng nhúng nhiều thứ vào cho tiện thì nó cũng sẽ bắt đầu chậm dần đều =)))
 

Thống kê chủ đề

Ngày tạo
Kaiser2013,
Người trả lời cuối
JyRAICK,
Trả lời
352
Lượt xem
41.100
Quay lại
Lên đầu trang