Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The primary query resets the minimum-batch allowance after standby results exhaust fetchMaxBytes, allowing the combined response to exceed the requested byte budget.
1 open issue
What changed in this PR
Adds opt-in PostgreSQL standby protection to Inkless’s control plane to reduce false offset errors and protect consolidation from stale offset lookups.
Changes:
- Adds a primary-read pool, configuration validation, and runtime connection-string updates.
- Confirms above-watermark standby errors on primary with bounded concurrency and retriable errors when confirmation fails.
- Adds protection metrics, regression tests, and generated configuration and metrics documentation.
| File | Description |
|---|---|
storage/inkless/src/test/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneStandbyProtectionTest.java |
Tests lagging reads, primary routing, confirmation failures, and concurrency limits. |
storage/inkless/src/test/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneMetricsTest.java |
Tests protection metrics and their documentation registration. |
storage/inkless/src/test/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneConfigureTest.java |
Tests primary-read connection-string requirements. |
storage/inkless/src/test/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneConfigTest.java |
Tests pool configuration isolation and concurrency defaults. |
storage/inkless/src/test/java/io/aiven/inkless/control_plane/FindBatchResponseTest.java |
Tests the storage-error response factory. |
storage/inkless/src/test/java/io/aiven/inkless/config/InklessControlPlaneConfigsConsistencyTest.java |
Checks consistency of the new reconfigurable key. |
storage/inkless/src/main/java/io/aiven/inkless/doc/ConfigsDocs.java |
Generates primary-read pool documentation. |
storage/inkless/src/main/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneMetrics.java |
Defines confirmation, override, failure, timing, and rejection metrics. |
storage/inkless/src/main/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlaneConfig.java |
Adds primary-read settings and the confirmation concurrency cap. |
storage/inkless/src/main/java/io/aiven/inkless/control_plane/postgres/PostgresControlPlane.java |
Implements primary routing, standby confirmation, and pool lifecycle management. |
storage/inkless/src/main/java/io/aiven/inkless/control_plane/FindBatchResponse.java |
Adds a retriable storage-error response factory. |
server-common/src/main/java/org/apache/kafka/server/config/InklessControlPlaneConfigs.java |
Registers the primary-read connection string for reconfiguration. |
docs/inkless/metrics.rst |
Documents standby-protection metrics. |
docs/inkless/configs.rst |
Documents primary-read settings and concurrency limits. |
core/src/test/scala/unit/kafka/server/InklessControlPlaneConnectionStringValidatorTest.scala |
Tests runtime scope and credential restrictions. |
core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala |
Tests reconfiguration registration and empty-string takedown. |
core/src/test/scala/io/aiven/inkless/consolidation/ConsolidationFetcherThreadTest.scala |
Tests log and watermark preservation during error recovery. |
core/src/main/scala/kafka/server/InklessControlPlaneConnectionStringValidator.scala |
Updates comments describing runtime configuration restrictions. |
core/src/main/scala/kafka/server/DynamicBrokerConfig.scala |
Extends takedown handling to the primary-read connection string. |
Review effort: Balanced
jeqo
force-pushed
the
jeqo/kc-859
branch
3 times, most recently
from
November 27, 2026 11:26
3812dd0 to
025f228
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The merge can retain an extra batch for a zero-limit partition after another partition returns data, violating fetch byte limits and requiring a shared request-wide minimum-batch allowance with regression coverage for both query orderings.
1 open issue
1 resolved since last review
Review effort: Balanced
…ads [KC-859] When `PostgresControlPlane` routes reads to a PostgreSQL standby, a restarted or lagging standby can serve an older snapshot during node replacement or switchover. Consumers fetching an offset valid on the primary receive a false `OFFSET_OUT_OF_RANGE` and reset their offsets, and consolidating fetchers call `listOffsets(LATEST)` against the same stale standby and truncate their local log and high watermark backward. Add an optional `inkless.control.plane.read.primary.*` pool and activate standby protection when both `read.*` and `read.primary.*` are configured: - Route `listOffsets`, `getCrossTierLogStart`, and `getProducerState` directly to `readPrimaryDataSource` so staleness that `list_offsets_v1` can't signal never reaches callers. Keep `jobsDataSource` isolated when `read.primary.*` is absent. - When `findBatches` receives above-high-watermark `OFFSET_OUT_OF_RANGE` from the standby, re-run the fetch against `readPrimaryDataSource` behind a fail-fast concurrency limiter (`standby.fallback.max.concurrent`, defaulting to 90% of `read.primary.max.connections`, at least 1) so confirmation and fallback bursts don't starve `listOffsets`, `getCrossTierLogStart`, and `getProducerState` sharing the same pool. Re-running the full fetch on primary lets `find_batches_v2` enforce `fetchMaxBytes`, per-partition limits, and the request-wide minimum-batch allowance in one pass with fresh watermarks. Skip below-LSO errors, which are monotonically expired, and return retriable `KAFKA_STORAGE_ERROR` for only the unconfirmed partitions when the limiter rejects or primary fails while preserving healthy standby responses for other partitions in the same fetch. - Add `inkless.control.plane.read.primary.connection.string` to `InklessControlPlaneConfigs.RECONFIGURABLE_CONFIGS` and `DynamicInklessControlPlaneConfig` with the same runtime takedown semantics as the existing connection strings. - Publish `FindBatchesPrimaryQueryTime`, `FindBatchesPrimaryConfirmRate`, `FindBatchesPrimaryOverrideRate`, `FindBatchesPrimaryConfirmFailureRate`, and `PrimaryReadLimitRejectedRate` on `PostgresControlPlaneMetrics`, and regenerate the config and metrics reference docs. Testing - `PostgresControlPlaneStandbyProtectionTest` exercises two PostgreSQL databases where the read database lags behind the primary, covering above-HWM override, genuine out-of-range confirmation, below-LSO skip, request-order `fetchMaxBytes` and zero-limit enforcement across both orderings, mixed-partition concurrency-limit rejection and primary failure, primary routing for `listOffsets`, `getCrossTierLogStart`, and `getProducerState`, and `read.*`-only non-fallback. - `ConsolidationFetcherThreadTest` verifies with a real `UnifiedLog` that consolidation doesn't truncate or regress local `highWatermark` on `KAFKA_STORAGE_ERROR` or when `listOffsets` reads ahead from primary. - Unit tests cover `read.primary.*` parsing, prefix validation, dynamic reconfiguration, `FindBatchResponse.kafkaStorageError()`, and the new metrics. Assisted-by: Gemini 4 Neon Co-authored-by: Cursor <cursoragent@cursor.com>
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.
When
PostgresControlPlaneroutes reads to a PostgreSQL standby, a restarted or lagging standby can serve an older snapshot during node replacement or switchover. Consumers fetching an offset valid on the primary receive a falseOFFSET_OUT_OF_RANGEand reset their offsets, and consolidating fetchers calllistOffsets(LATEST)against the same stale standby and truncate their local log and high watermark backward.Add an optional
inkless.control.plane.read.primary.*pool and activate standby protection when bothread.*andread.primary.*are configured:listOffsets,getCrossTierLogStart, andgetProducerStatedirectly toreadPrimaryDataSourceso staleness thatlist_offsets_v1can't signal never reaches callers. KeepjobsDataSourceisolated whenread.primary.*is absent.findBatchesreceives above-high-watermarkOFFSET_OUT_OF_RANGEfrom the standby, re-run the fetch againstreadPrimaryDataSourcebehind a fail-fast concurrency limiter (standby.fallback.max.concurrent, defaulting to 90% ofread.primary.max.connections, at least 1) so confirmation and fallback bursts don't starvelistOffsets,getCrossTierLogStart, andgetProducerStatesharing the same pool. Re-running the full fetch on primary letsfind_batches_v2enforcefetchMaxBytes, per-partition limits, and the request-wide minimum-batch allowance in one pass with fresh watermarks. Skip below-LSO errors, which are monotonically expired, and return retriableKAFKA_STORAGE_ERRORfor only the unconfirmed partitions when the limiter rejects or primary fails while preserving healthy standby responses for other partitions in the same fetch.inkless.control.plane.read.primary.connection.stringtoInklessControlPlaneConfigs.RECONFIGURABLE_CONFIGSandDynamicInklessControlPlaneConfigwith the same runtime takedown semantics as the existing connection strings.FindBatchesPrimaryQueryTime,FindBatchesPrimaryConfirmRate,FindBatchesPrimaryOverrideRate,FindBatchesPrimaryConfirmFailureRate, andPrimaryReadLimitRejectedRateonPostgresControlPlaneMetrics, and regenerate the config and metrics reference docs.Testing
PostgresControlPlaneStandbyProtectionTestexercises two PostgreSQL databases where the read database lags behind the primary, covering above-HWM override, genuine out-of-range confirmation, below-LSO skip, request-orderfetchMaxBytesand zero-limit enforcement across both orderings, mixed-partition concurrency-limit rejection and primary failure, primary routing forlistOffsets,getCrossTierLogStart, andgetProducerState, andread.*-only non-fallback.ConsolidationFetcherThreadTestverifies with a realUnifiedLogthat consolidation doesn't truncate or regress localhighWatermarkonKAFKA_STORAGE_ERRORor whenlistOffsetsreads ahead from primary.read.primary.*parsing, prefix validation, dynamic reconfiguration,FindBatchResponse.kafkaStorageError(), and the new metrics.