Repository navigation
feat(events): persist events to disk so they survive the process (tier 3) #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abelonogov-ld
wants to merge
184
commits into
andrey/event-durability-tier2-bounded-flush
Choose a base branch
from
andrey/event-durability-tier3-persistence
base: andrey/event-durability-tier2-bounded-flush
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13,157
−2,050
Open
Changes from all commits
Commits
Show all changes
184 commits
Select commit
Hold shift + click to select a range
845a595
feat(events): persist recorded events to an append-only log (tier 3)
abelonogov-ld 0c5c675
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 1307ed4
test: point the unserializable-event specs at the event store
abelonogov-ld 7df86a3
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 87d3926
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 183ee21
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 312dbb6
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld a952a9b
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 95b56af
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld ebc8aef
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld b5a88dd
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 2c46b87
Encode held events only where they are persisted; record evaluations …
abelonogov-ld 126db1c
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 87ec45b
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 4bac993
tier 3 fixes
abelonogov-ld e995b26
fixes
abelonogov-ld 7f803e4
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 3fcd1f5
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 6406d5d
fix(events): Keep stored events whose read failed, and deliver what a…
abelonogov-ld 0c8ea66
fix(events): Report a flush false when an event the SDK accepted coul…
abelonogov-ld 6a310fa
test(events): Match Android's coverage of the recoverable failures
abelonogov-ld f767a89
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld ca5078e
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld fe918c6
format
abelonogov-ld 2b892df
Assert lock ownership instead of encoding it in method names
abelonogov-ld af218b1
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld fd73b60
tests
abelonogov-ld 2b25a35
fix(events): Answer every flush off the caller's thread
abelonogov-ld e5a4e43
fix(events): Give each process a log of its own
abelonogov-ld 61ba495
Lock the open event log on a Mac, where instances share a process name
abelonogov-ld 12cb3e2
split
abelonogov-ld a76eda9
rename to recordLock
abelonogov-ld a901782
use withLock
abelonogov-ld 8bffc83
Keep the batch paths off the disk, and out of ioLock, when persistenc…
abelonogov-ld 81a7856
Answer a flush for the batch another delivery is holding
abelonogov-ld 425aefb
simplify
abelonogov-ld 12cc8f0
Take the frames a failed write left back off the log, so they are not…
abelonogov-ld a65b8fe
Rename OpenEventLog to DiskEventLog, and make EventLogFile the open f…
abelonogov-ld ea815e2
Count an evaluation through the default subscript, so a context is lo…
abelonogov-ld 35ae12e
Move NullEventStore into a file of its own
abelonogov-ld 4fcc3e0
Group the EventReporter fields by the lock or queue that guards them
abelonogov-ld d32c669
Look a context up once even at the limit, through its index there
abelonogov-ld 40ab485
Go back to looking a context up through its index, which reads more p…
abelonogov-ld 20203d9
Admit an evaluation's events without building an array for them
abelonogov-ld 4ab5f5d
Rename EventReporter to DirectEventProcessor, as Android names it, wi…
abelonogov-ld 8d9c131
Name the processor's capacity eventCapacity, after the setting it com…
abelonogov-ld 65b2bbf
Move summarizing and encoding into OutboundEventBuffer, as Android ha…
abelonogov-ld 79ddb32
Move posting a batch and reading the response into AnalyticsEventSend…
abelonogov-ld ab53b77
Count a commit's events while they are being written, so a slow write…
abelonogov-ld 1db8cc7
Lay out long tier-3 signatures one parameter per line
abelonogov-ld 3668890
Fix lint warnings in files the event durability tiers touched
abelonogov-ld d6b1e95
Run the process assertion specs only where the platform has assertions
abelonogov-ld f2a8bd6
Take a delivered batch out of the store before telling observers abou…
abelonogov-ld 6a6afc8
Make the unit tests build and pass on watchOS
abelonogov-ld 50ebcd0
Keep the closed-batch count equal to the batches it counts
abelonogov-ld 8ef1c2a
Document that the event capacity counts an earlier launch's events on…
abelonogov-ld f289900
Give the processor specs' waits room for a loaded CI simulator
abelonogov-ld d95893a
Fix compiler warnings in tests the event durability tiers added
abelonogov-ld 2f180e4
Say which lock guards the outbound buffer's encoder
abelonogov-ld 409b076
List the no-directory store's batches oldest first
abelonogov-ld b85328d
Stop counting a batch against capacity while its request is out
abelonogov-ld b71a6cb
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 7c3aab6
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 53af9ee
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 35453a8
disabled unit testd
abelonogov-ld 8bf63c6
don't touch disk in disabled
abelonogov-ld 7dbc8ea
EventDirectory
abelonogov-ld 1ae965d
Keep events counted while a held batch is being assembled
abelonogov-ld 60c1965
Stop re-sending a delivered batch whose file will not delete
abelonogov-ld eaa67a4
Raise the default event capacity to 2000
abelonogov-ld 8d59683
Write on flush at .deferred too
abelonogov-ld d4f6e06
Leave scheduling writes to the event processor
abelonogov-ld 109372d
Count a batch's events in its file name
abelonogov-ld 3aaa3b8
unreadable batch
abelonogov-ld 9d0b789
Write on entering the background at .deferred too
abelonogov-ld ea0b069
Read the summarizer under its lock in tests
abelonogov-ld 49a4c56
Do not take a payload id ending in zero-led digits for a count
abelonogov-ld 1baabd6
Say what a dropped event-publish completion costs now
abelonogov-ld 35163da
Wait for the after-identify hooks in the hook forwarding specs
abelonogov-ld 19192a3
Go online before staging the batch the unreadable-batch spec damages
abelonogov-ld 51edd86
Make the summary-count spec commit during recording however it is sch…
abelonogov-ld 690f52e
Merge branch 'v11' into andrey/event-durability-tier3-persistence
abelonogov-ld 188bb59
Bound stored events by bytes and by age
abelonogov-ld 4be95a8
Checksum every frame of the event log
abelonogov-ld a8362df
Move the in-memory CRC advance out of the vendored compression file
abelonogov-ld 8a6af04
experimental
abelonogov-ld 067e676
Name each event log by a UUID and recover every log no live process h…
abelonogov-ld 1cdd573
Stop handing the process name to the event store
abelonogov-ld 4d33b28
Name an event log pending- rather than open-
abelonogov-ld e29e9e2
Log events from a previous run as prepared, not recovered
abelonogov-ld 82322ad
Rename recoverInterruptedLog to preparePayloadsFromInterruptedLogs
abelonogov-ld 0533f11
Send a batch's events no more than once when a failed write stays on …
abelonogov-ld 5ad00a1
Log when events from a previous run cannot be moved for delivery
abelonogov-ld b21ef40
Keep every batch within 2 MiB, so no request is too large to accept
abelonogov-ld 95957b9
Hold a batch being delivered twice at most, and stop copying every frame
abelonogov-ld edb95e7
Tell the next flush about a batch lost where nobody was waiting
abelonogov-ld 91a301a
Say when a read that failed is tried again
abelonogov-ld e3c64b8
Leave a batch out of the count only while it is still counted
abelonogov-ld 2fa7afc
Assemble a batch's payload in the bytes its file was read into
abelonogov-ld 1e7616c
Name batches ready-<payloadId>.<count>, read by position
abelonogov-ld 8004c28
Test that a flush of more than a batch sends no request over the batc…
abelonogov-ld d4f35f3
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 2a7cf5b
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 0586bdf
Report a flush as failed when the stored events cannot be listed
abelonogov-ld f4adfaf
Keep a log whose rename failed open, and report the flush as failed
abelonogov-ld 2b1e380
Report events a damaged batch could not send as lost
abelonogov-ld cc200a6
Read the logs a previous run left without holding the store's I/O lock
abelonogov-ld 4c30257
Describe the pending threshold as a trigger, not a ceiling
abelonogov-ld 1b0a80d
Keep the disk out of flushAndWait's caller thread
abelonogov-ld 4e049fd
Keep expiry away from batches any live store or process is sending
abelonogov-ld d506d34
Close no batch behind one that is blocked
abelonogov-ld 5d04131
Bound summaries by bytes where events stay off the disk
abelonogov-ld 051ff2b
Leave summaries out of the event count
abelonogov-ld 288a27b
Back off failed event deliveries per RETRY instead of dropping and go…
abelonogov-ld b55c839
Drop a batch after two 400s in a row so it cannot block the rest
abelonogov-ld 0124fc8
Deliver one batch at a time
abelonogov-ld 307eaa7
Pin that a delivery's own loss is told to its caller
abelonogov-ld d5ca597
Remove a log whose first write failed and could not be cut back
abelonogov-ld 6506c92
Count a batch deleted unsent as lost where no other process shares th…
abelonogov-ld 5c1e5b8
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 6093548
Pin context redaction in the payload the processor posts
abelonogov-ld bd3b796
Count the events of an open log deleted unsent as lost
abelonogov-ld b94ce8e
Put each frame's checksum after its payload
abelonogov-ld c438c9e
fix(events): let the delivery at close post through the backoff
abelonogov-ld 455028b
fix(events): drop a batch after two 413, 415 or 422 refusals, as for 400
abelonogov-ld 68ce4c4
Name and list every file in the event directory in EventDirectory
abelonogov-ld 24ba5b2
test: pace the lister so closes are not starved of the store's lock
abelonogov-ld 8319688
Drop the part of EventDirectory's comment about EventStore's concerns
abelonogov-ld 5028134
fix: count a batch read to count it by the bytes that were read
abelonogov-ld 0083526
fix: never read a stored file larger than this version writes
abelonogov-ld 8676b9f
feat: tell the event processor when a flag request starts and settles
abelonogov-ld 874c11a
feat: give flag requests the network ahead of a backlog of events
abelonogov-ld 8b6e2d6
feat: share the byte capacity equally across the configured environments
abelonogov-ld 07ed8c5
fix: count the wait for a flag request from when it started, so the l…
abelonogov-ld e6514b9
fix: count the wait for a flag request from when it started, so no pa…
abelonogov-ld bc29c3d
fix: going offline stops a delivery before its next post, its retry's…
abelonogov-ld 2887cd3
fix: leave flag requests untracked and FlagTraffic unbuilt where even…
abelonogov-ld b1a7ed1
feat: version batch names, leaving a batch another version named to e…
abelonogov-ld a015c89
refactor: give way to flag values by time alone, without tracking fla…
abelonogov-ld cedff6a
refactor: move recording and commits out of DirectEventProcessor into…
abelonogov-ld 53eb687
Move delivery queueing and pacing out of DirectEventProcessor
abelonogov-ld f2b515e
Rename DeliveryScheduler to EventDeliveryScheduler
abelonogov-ld 9e629b6
Rename DeliveryRun to EventDeliveryRun
abelonogov-ld 9913306
Hold the report timer's deliveries until the launch gate opens
abelonogov-ld 8a8a670
fix: flushAndWait posts through the backoff's wait, as close does
abelonogov-ld bcd41ae
fix: a post that gets no response leaves the run of payload refusals …
abelonogov-ld 0d4e4a4
fix: bound full events by bytes where events are kept off the disk
abelonogov-ld fdaf882
fix: count an uncounted batch this version cannot read as lost rather…
abelonogov-ld 8d97c41
fix: count an uncounted batch damaged from its first frame as one eve…
abelonogov-ld af90a9c
fix: pass by a stored batch whose read fails, and drop it after three…
abelonogov-ld f059653
fix: give each event directory its own BatchLocks lock
abelonogov-ld 6877ac1
fix: split a summary too large for a log frame rather than dropping it
abelonogov-ld 2a1d1a8
Stop .deferred track and identify from scheduling a commit each (ATR3…
abelonogov-ld 5ea2749
Group concurrent .immediate commit points into one commit, as Android…
abelonogov-ld 9bda454
Commit at close off the caller's thread within a budget, as Android does
abelonogov-ld 18e73a6
A failed post through the backoff leaves the wait as it was
abelonogov-ld 7117c2f
Space the read failures that drop a batch a flush interval apart
abelonogov-ld 013d2b7
Stop splitting a summary that is mostly context
abelonogov-ld 8e6abfa
Pack an oversized summary's flags into parts that fit beside the context
abelonogov-ld d62cd58
Measure a summary's flags with a writer of their own, so its parts re…
abelonogov-ld 93f6ed5
Split an oversized summary on the commit queue rather than the caller…
abelonogov-ld 4ae9292
Split an oversized summary on the flushing thread again, so a flush w…
abelonogov-ld 5c61258
Write only its own event for a track or identify at immediate persist…
abelonogov-ld 9173f03
Write only its own frame for a track at immediate persistence, from a…
abelonogov-ld d0ee14b
Drop a summary larger than a frame rather than splitting it
abelonogov-ld 9721730
Commit everything held at a track or identify at immediate persistenc…
abelonogov-ld 739a951
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld e3684a8
Mark the experimental persistence levels with a warning callout
abelonogov-ld 98ad649
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld 635daf1
Build the event persistence test helpers in every configuration, not …
abelonogov-ld f2793c1
Keep the lock ownership check to Debug builds
abelonogov-ld 6c68152
Guard the diagnostic cache mock with a lock, as the SDK calls it from…
abelonogov-ld 6d6875c
Make the event delivery delay configurable, and hold the diagnostic i…
abelonogov-ld b55af5d
Log undelivered events at suspension at info where nothing persists, …
abelonogov-ld 5711315
Gather the platform differences in backgrounding into SystemCapabilit…
abelonogov-ld 7bebd16
Merge branch 'andrey/event-durability-tier2-bounded-flush' into andre…
abelonogov-ld b5e81ef
Build the event pipeline's test accessors in Debug only
abelonogov-ld 7fa137c
One background observer for the events of every environment
abelonogov-ld d052e1c
One way to flush several environments and collect their outcomes
abelonogov-ld 793c3b9
Give up on an environment's answer after the background assertion's cap
abelonogov-ld bcbde8a
Drop the long-timeout log from flushAndWait
abelonogov-ld 5a04c20
fix: pace the delivery a backoff's wait sets when it ends (R3-3)
abelonogov-ld b3c9ff3
Recover a previous run's events at utility
abelonogov-ld 3f8bab5
Close the clients outside instancesQueue
abelonogov-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import Foundation | ||
|
|
||
| extension Crc32 { | ||
| /// Advance the current checksum with bytes already in memory, without wrapping them in `Data` first. | ||
| /// - parameter bytes: bytes to advance the checksum | ||
| mutating func advance(withBytes bytes: UnsafeRawBufferPointer) { | ||
| guard let base = bytes.baseAddress?.assumingMemoryBound(to: UInt8.self) | ||
| else { return } | ||
| if let fastCrc32 = Crc32.zLibCrc32 { | ||
| checksum = fastCrc32(checksum, base, UInt32(bytes.count)) | ||
| } else { | ||
| checksum = slowCrc32(start: checksum, data: Data(bytes)) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close overlaps a concurrent client start
Medium Severity
close()now clearsinstancesbeforeinternalClose()runs, so another thread can observeget()as nil and callstart()while the old clients are still committing and delivering. TwoEventStores then share one directory: the new client can recover and send a batch the closing client is still posting, duplicating events. Previouslystart()waited oninstancesQueueuntil teardown finished, so this overlap could not happen.Reviewed by Cursor Bugbot for commit 3f8bab5. Configure here.