Repository navigation
refactor: rework the download ingestion pipeline - #2132
Merged
Merged
Conversation
This was referenced Sep 2, 2026
netomi
force-pushed
the
split/ingestion-rework
branch
from
September 2, 2026 16:09
0c8bab2 to
9ee95f2
Compare
netomi
force-pushed
the
split/ingestion-rework
branch
from
September 3, 2026 14:46
d7e2400 to
3bb6f2d
Compare
netomi
force-pushed
the
split/ingestion-rework
branch
2 times, most recently
from
September 13, 2026 08:18
a5fec88 to
e63e301
Compare
Reworks the log-based download ingestion that PR #2027 needs, with no analytics behaviour attached, so that the restructuring of live download counting can be reviewed on its own. A log handler per storage backend becomes a DownloadRecordSource that yields RawDownloadRecords, and DownloadCountProcessor becomes DownloadIngestionProcessor, which resolves records to extensions (with a Caffeine cache), aggregates them and applies the download counts. Scheduling moves out of the handlers into DownloadIngestionRunner and the jobs package. AwsDownloadCountHandler splits into AwsDownloadRecordSource plus the CloudFront and Fastly parsers, and LogRecord becomes AccessLogRecord. StorageUtilService no longer asks a DownloadCountService whether a resource is covered; it asks the sources themselves. DownloadCountServiceAspect goes with the service it wrapped. DownloadCountProcessedItem is renamed to DownloadIngestion, keeping its table name, so there is no migration. Its repository gains countFailedDownloadIngestions. The analytics seam is present but inert: DownloadAnalyticsRepository is an interface with no implementation in this change, so the ObjectProvider the processor holds is never satisfied and only the download counts are written. The implementation, and the findSeries half of that interface, come with the analytics work. The test datasource pool is capped at 4. The new processor test adds another cached Spring context, and each one holds an idle pool of 10 against the single shared container, which exhausts its max_connections mid-suite - it surfaced as unrelated failures in RepositoryServiceSmokeTest and the recovery-lock test. Co-Authored-By: gnugomez <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The DownloadCountProcessedItem -> DownloadIngestion rename kept @table(name = "download_count_processed_item"), so the schema still carried a name that only makes sense against a class that no longer exists. V1_75 completes it. Everything in the migration is a catalog-only rename - the table, its primary key constraint, both indexes and the sequence. No data is copied and no column changes type, so there is no table rewrite; the ACCESS EXCLUSIVE lock is held only for as long as it takes to update the catalog rows. The indexes, the constraint and the sequence are renamed explicitly because renaming a table leaves them behind under their original names, which is precisely the half-renamed schema the migration exists to avoid. The sequence keeps its OWNED BY link across the rename, and its INCREMENT 50 still matches the entity's default allocationSize. src/main/jooq-gen is regenerated, which is where the rest of the diff comes from. Nothing referenced the generated table: it is reached only through JPA, via DownloadIngestionRepository and JPQL naming the entity. What this is not safe against is an older server instance still running after the migration - its queries name the old table and will fail until it is replaced. The failure is loud and confined to the hourly ingestion job, and this table is a ledger of which log files have been processed, so a failed run neither loses nor double-counts downloads, it retries on the next tick. Deployments running more than one server instance should expect errors in that window. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two call sites each scanned the ingestion sources to answer "which source, if any, handles this storage type": StorageUtilService sources.stream().anyMatch(source -> source.covers(resource)) LogIngestionJob sources.stream().filter(s -> s.getStorageType().equals(t) && s.isEnabled()) Both now share a DownloadRecordSourceIndex, built once per holder in a @PostConstruct and keyed by storage type. It is a plain object rather than a bean so that neither constructor signature changes, which keeps the six test configurations that wire StorageUtilService untouched. The scan mattered most in StorageUtilService, which runs on every download: ObjectProvider.stream() resolves matching beans from the bean factory on each call, so the registry's hottest endpoint paid a bean lookup plus a covers() call per source to answer a question with two possible answers. It is now a map lookup. Asking isEnabled() once at startup is safe - every input to it is a configuration property, fixed once the bean is initialized - and it fixes a logging bug. AzureDownloadRecordSource warns from inside isEnabled() when its logs endpoint is set but its storage endpoint is not, and covers() called isEnabled(), so a half-configured Azure deployment emitted that warning on every single download. Enablement is no longer part of the covers() contract. Both implementations ended with "&& isEnabled()", which was correct but left every future source one forgotten conjunct away from suppressing downloads that nothing ingests - the request path would skip them and the disabled job would never pick them up. A source that is not enabled is now absent from the index altogether, so covers() answers coverage only, as its name says, and the guarantee holds for implementations that have not been written yet. Two enabled sources for one storage type would each claim the same downloads, with bean ordering deciding which answered. LogIngestionJob previously took the first via findFirst(); that now fails at startup instead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
netomi
force-pushed
the
split/ingestion-rework
branch
from
September 13, 2026 09:18
1d4903e to
d712802
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stack: 3 of 6. Split out of #2027. Base: #2131 (
split/ingestion-move).This is the highest-risk part of #2027, isolated so it can be reviewed for what it actually is: a rewrite of live download counting.
Why this needed separating
#2027 presents itself as opt-in (
ovsx.analytics.enabled, default false). The analytics are. This rework is not — it replaces the download-count pipeline for every deployment regardless of that flag. That is not visible from the PR description, and it is the regression risk in the whole change.So this PR carries the restructuring with no analytics behaviour attached.
What changes
DownloadRecordSourceyieldingRawDownloadRecordsDownloadCountProcessorbecomesDownloadIngestionProcessor: resolves records to extensions (Caffeine-cached), aggregates, applies the countsDownloadIngestionRunnerand thejobspackageAwsDownloadCountHandlersplits intoAwsDownloadRecordSource+ the CloudFront and Fastly parsers;LogRecordbecomesAccessLogRecordStorageUtilServiceno longer asks aDownloadCountServicewhether a resource is covered, it asks the sources themselves;DownloadCountServiceAspectgoes with the service it wrappedDownloadCountProcessedItem->DownloadIngestion, andV1_75renames the table to match; its repository gainscountFailedDownloadIngestionsThe analytics seam is present but inert
DownloadAnalyticsRepositoryis here as an interface with no implementation, so theObjectProviderthe processor holds is never satisfied and only download counts are written. The single implementation anywhere in the tree is a test fake.That is what makes "did download counting regress?" an answerable question in this PR.
Two deliberate deviations from #2027 for this purpose:
save(List<DownloadEvent>). ItsfindSerieshalf drags in the whole query model (DownloadSeriesRequest,DownloadSeriesRow, and their enums), so it is added back with the Timescale implementation rather than carried here as five unused files.captureDownloadstays in the processor, guarded byanalyticsRepository.ifAvailable, rather than being removed and re-added. It does nothing until the implementation lands. Its call site on the download-serving path is worth a look when it becomes live — it is a synchronous write on the registry's hottest endpoint.The table rename
The second commit renames the table, so the schema stops carrying a name that only makes sense against a class that no longer exists. It is worth reviewing on its own terms, because it is the one part of this PR that is not backward compatible.
Everything in
V1_75is a catalog-only rename — the table, its primary key constraint, both indexes and the sequence. No data is copied and no column changes type, so there is no table rewrite and theACCESS EXCLUSIVElock is held only for as long as it takes to update the catalog rows. The indexes, constraint and sequence are renamed explicitly because renaming a table leaves them behind under their original names, which is exactly the half-renamed schema the migration exists to avoid. The sequence keeps itsOWNED BYlink, and itsINCREMENT 50still matches the entity's defaultallocationSize.src/main/jooq-genis regenerated, which is where most of that commit's diff comes from. Nothing referenced the generated table — it is reached only through JPA, viaDownloadIngestionRepositoryand JPQL naming the entity.What it is not safe against is an older server instance still running after the migration: its queries name the old table and will fail until it is replaced. The failure is loud rather than silent, and confined to the hourly ingestion job — this table is a ledger of which log files have been processed, so a failed run neither loses nor double-counts downloads, it retries on the next tick. Deployments running more than one server instance should expect errors in that window, and anyone with queries or dashboards against
download_count_processed_itemneeds to know.This corrects an earlier note on this PR, which said the entity rename carried no schema change. That was true of #2027, which has no migration at all; it is no longer true here.
Resolving the ingestion sources
The third commit. Two call sites each scanned the sources to answer "which source, if any, handles this storage type" —
StorageUtilService.increaseDownloadCountviaanyMatch(covers), andLogIngestionJobviafilter(getStorageType().equals(t) && isEnabled()). They now share aDownloadRecordSourceIndex, built once per holder in a@PostConstructand keyed by storage type. It is a plain object rather than a bean so that neither constructor signature changes, which keeps the six test configurations that wireStorageUtilServiceuntouched.The scan mattered most in
StorageUtilService, which runs on every download:ObjectProvider.stream()resolves matching beans from the bean factory on each call, so the hottest endpoint in the registry paid a bean lookup plus acovers()call per source to answer a question with two possible answers.Asking
isEnabled()once at startup is safe — every input to it is a configuration property, fixed once the bean is initialized — and it fixes a logging bug worth calling out on its own:AzureDownloadRecordSourcewarns from insideisEnabled()when its logs endpoint is set but its storage endpoint is not, andcovers()calledisEnabled(). A half-configured Azure deployment was emitting that warning on every single download.Enablement also leaves the
covers()contract. Both implementations ended with&& isEnabled()— correct, but it left every future source one forgotten conjunct away from suppressing downloads that nothing ingests, since the request path would skip them and the disabled job would never pick them up. A source that is not enabled is now absent from the index, socovers()answers coverage only and the guarantee holds for implementations not yet written. To be clear about what this is: a robustness and performance change, not a bug fix — the&& isEnabled()conjuncts meant downloads were never actually lost.Two enabled sources for one storage type would each claim the same downloads, with bean ordering deciding which answered;
LogIngestionJobtook the first viafindFirst(). That now fails at startup instead.The test pool cap
spring.datasource.hikari.maximum-pool-size: 4in the test config, taken from #2027's own35e5126e3.The new processor test adds another cached Spring context, and each context holds an idle pool of 10 against the one shared container, exhausting its
max_connectionsmid-suite. It surfaced as two failures with no apparent connection to this change —RepositoryServiceSmokeTest.testExecuteQueriesand the recovery-lock test — both of which pass in isolation.Worth noting for the Timescale PR that follows: this is a test-infra symptom of an unanswered production question. A second datasource means two pools per deployment, and the combined connection budget against the deployed
max_connectionshas not been stated anywhere.Verification
Full server suite: 1315 tests passing, with Flyway reporting
Successfully applied 76 migrations, soV1_75is exercised by every integration test rather than only applied in isolation. All pre-commit hooks pass.The migration was also applied from scratch against a clean Postgres 16.2 to confirm it leaves no object — table, constraint, index or sequence — still carrying the old name.
Refs #2027, #2025