disk buffer: reader can be notified before the data file write completes, delaying the sink's send

Đang mở Phù hợp với người mới
#26,523 8 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, stream-processing

Hướng nghiên cứu

Bắt đầu trong lib/vector-buffers/src/variants/disk_v2/writer.rs, tại phương thức flush buffer của TrackingBufWriter. Đọc luồng write_all hiện có và hướng dẫn của Tokio về việc flush File, sau đó xác minh rằng reader chỉ được thông báo sau khi việc ghi tệp dữ liệu hoàn tất. Hoàn thành có nghĩa là việc flush buffer disk_v2 chờ việc ghi hoàn tất mà không thay đổi cách xử lý lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

A note for the community
  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Problem

In disk_v2's buffer flush we don't flush the tokio::fs::File, so there is no guarantee the write has finished before the reader is notified. The tokio docs say to call flush (tokio::fs — Using File); to be sure we wait for the write to finish we don't.

Fix:

--- a/lib/vector-buffers/src/variants/disk_v2/writer.rs
+++ b/lib/vector-buffers/src/variants/disk_v2/writer.rs
@@ -408,7 +408,10 @@ impl<W: AsyncWrite + Unpin> TrackingBufWriter<W> {
         let events_flushed = self.unflushed_events as u64;
         let bytes_flushed = self.buf.len() as u64;
 
-        let result = self.inner.write_all(&self.buf[..]).await;
+        let mut result = self.inner.write_all(&self.buf[..]).await;
+        if result.is_ok() {
+            result = self.inner.flush().await;
+        }
Version

vector 0.58.0

Ngôn ngữ chính
Rust
Star
22.8k
Fork
2.4k
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
264

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vectordotdev/vector

Tất cả issue của vectordotdev/vector

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.