Replies: 1 comment 7 replies
-
|
Ok I wrote an essay there above. Going to start to answer my own questions until a NuGet dev. chimes in. It does look like each new event is indeed published in chronological order to the last chronological page. When a new page is created, it becomes the "last" chronological page. Thus, if pages are sorted from earliest commitTimestamp to latest commitTimestamp, you are free to iterate all available events in each page and do with them as you like. Any new events which are published at the same time you are iterating will still be "after" the last event in your iteration. So you are not going to "miss" any events. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have read the NuGet Catalog API documentation: catalog-reference and looked at the various use cases and examples. But it seems to me there is a possible race condition when traversing the catalog for new events.
Can someone please bear with me and clear things up for me?
I understand that:
lowercase(packageId)/version/timestampcombination can exist.But I am at a loss how to guarantee that a consumer won't miss/lose any events if the catalog is updated during traversal.
Scenario:
prevMaxTimestampfrom my last processing runprevMaxTimestampnewMaxTimestampwhich will become theprevMaxTimestampin the next processing run.prevMaxTimestamp + 5N(for some arbitrary definition ofN).The Problem:
What guarantees do I have that an event with timestamp
prevMaxTimestamp + 3Nwasn't added to an earlier page (that I've already processed) between the time I processed that page and now?In other words, is there a race condition where:
At time T1: I process Page N - 1
At time T3: I process Page N
But at time T2 (between T1 and T3) two new events are published. First to Page N - 1, then subsequent to that to Page N. Thereby losing the new event on Page N - 1 forever.
Questions:
maxTimestampis guaranteed to avoid a scenario where an event is lost (i.e. no matter what all newer events will always be picked up on the next processing run).commitTimeStampat the Catalog level, there exists a Page Item with thatcommitTimeStamp, and on that page there at exists an event with thatcommitTimeStamp.If all the following is true, then this is the algorithm I can use:
prevMaxTimestamp<Catalog.commitTimeStampthenPageItems and sort by timestamp.prevMaxTimestamp<PageItem.commitTimestamptraverse all events and consume any event whereprevMaxTimestamp<Event.commitTimestamp.prevMaxTimestampnow becomes the latest of all event timestamps.Thank you guys so much. Please advise.
Beta Was this translation helpful? Give feedback.
All reactions