Subscription gap metric reads the end of the same stream once for each subscription
Maintainer thường phản hồi trong vòng 7 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- observability
Hướng nghiên cứu
Start with src/Core/src/Eventuous.Subscriptions/Diagnostics/SubscriptionMetrics.cs, focusing on ObserveGapValues and GetGap, then trace how measures are registered in SubscriptionRegistrationExtensions.cs. Review the SQL and KurrentDB measure implementations listed in the issue to see how they identify an end-of-stream source. Done means each shared source is read once per collection while subscription-id tags and custom implementations without a key retain their stated behavior; linked pull request 615 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
AddEventuousSubscriptions() registers the subscription gap gauges in SubscriptionMetrics. On each metric collection, ObserveGapValues calls the GetSubscriptionEndOfStream delegate of every measured subscription, one after another. Each delegate reads the end of its stream from the store.
When several subscriptions read the same source, every call returns the same value, but the store gets one request for each subscription. This happens in the core SubscriptionMetrics, so it affects every store that supports the gap metric:
| Store | End-of-stream request for an all-stream subscription |
|---|---|
| SQL Server | SELECT MAX(GlobalPosition) FROM <schema>.Messages |
| PostgreSQL | select max(global_position) from <schema>.messages |
| SQLite | SELECT MAX(global_position) FROM <messages table> |
| KurrentDB | ReadAllAsync(Direction.Backwards, Position.End, 1), a gRPC read of the last event in $all |
For example, an application has six all-stream subscriptions on one SQL Server store. Each collection then sends the same query six times. The position column is the clustered primary key, so each SQL query is cheap. For KurrentDB, each call is a network round trip. In all cases, the number of requests grows with the number of subscriptions and with the export frequency:
| Metric export interval | Subscriptions | End-of-stream requests |
|---|---|---|
| 60 seconds | 6 | 6 each minute |
| 200 milliseconds | 6 | about 30 each second |
A second, related problem: GetGap runs each delegate synchronously (GetAwaiter().GetResult()) on the collection thread, with a 500 ms timeout for each subscription. When the store is slow, one collection can block for up to 500 ms multiplied by the number of subscriptions. This also applies to every store.
Observed with Eventuous 0.17.0 (Eventuous.SqlServer, Eventuous.Diagnostics.OpenTelemetry). The other stores are from a reading of the dev branch source.
Describe the solution you'd like
Read each end-of-stream source one time per collection, and share the result between the subscriptions that read that source. Make the change in SubscriptionMetrics, so that it applies to all stores.
A possible shape:
IMeasuredSubscriptionexposes a key for its end-of-stream source in addition to the delegate. Subscriptions that read the same source return the same key. For example, a SQL all-stream subscription returns the store type, the connection, and the schema. A stream subscription adds the stream name. A KurrentDB$allsubscription returns the client and$all.SubscriptionMetricsgroups the measures by key. On each collection, it calls one delegate for each key and uses the result for every subscription in the group. Thesubscription-idtag stays the same, so the exported series do not change.- Optionally,
SubscriptionMetricsruns the remaining calls concurrently, with one overall timeout, rather than one blocking call after another.
The key could be optional. A subscription with no key keeps the current behavior, so custom IMeasuredSubscription implementations continue to work.
Additional context
The relevant code:
src/Core/src/Eventuous.Subscriptions/Diagnostics/SubscriptionMetrics.cs:ObserveGapValuesandGetGap.src/Core/src/Eventuous.Subscriptions/Registrations/SubscriptionRegistrationExtensions.cs: registers oneGetSubscriptionEndOfStreamfor each measured subscription.src/Relational/src/Eventuous.Sql.Base/Subscriptions/SqlSubscriptionBase.cs:GetSubscriptionEndOfStream, which SQL Server, PostgreSQL, and SQLite share.PrepareEndOfStreamCommandin the all-stream and stream subscriptions ofEventuous.SqlServer,Eventuous.Postgresql, andEventuous.Sqlite.src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/:AllStreamSubscriptionMeasure,StreamSubscriptionMeasure, andBaseSubscriptionMeasure.
- Ngôn ngữ chính
- C#
- Star
- 512
- Fork
- 99
- Merge trung bình
- 5 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Eventuous/eventuous
-
MongoDB integration tests fail on newer GitHub Actions runner kernelsCó thể đã có người làm @nmummau đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Eventuous/eventuous#626 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 7 ngày
-
`dotnet format style --verify-no-changes` fails with naming violations and unnecessary importsCó thể đã có người làm @nmummau đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Eventuous/eventuous#624 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 7 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Eventuous/eventuous#627 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 7 ngày
-
SQL Server: `append_events` does not need the `@inserted` table variableCó thể đã có người làm @nmummau đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 20/100
Eventuous/eventuous#619 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 7 ngày
-
SQL Server: stream reads do one key lookup per event, and `IDX_EventsStream` duplicates `UQ_StreamIdAndStreamPosition`Có thể đã có người làm @nmummau đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 18/100
Eventuous/eventuous#618 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 7 ngày
Tất cả issue của Eventuous/eventuous
Issue tương tự
-
dev/release: verify-release-candidate.sh runs 0 Java tests with Debian's MavenCó thể đã có người làm @kou đã nhận hôm nay. Đang mởType: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/arrow-adbc#4947 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:watch: Not Triaged CAC
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/AspNetCore.Docs#38001 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Nimblesite/SharpLsp#468 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
elastic/ecs-dotnet#575 ·
-
V4 alert-rule reads have no scope gate, so any authenticated credential can list alert rulesĐang mởalerts bug effort:S P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
nightscout/nocturne#2511 ·
Maintainer thường phản hồi trong vòng 1 ngày