Skip to content

(m)TLS to PG - #627

Draft
shortishly wants to merge 217 commits into
623-support-postgresql-mtls-client-authentication-for-backend-connectionsfrom
main
Draft

(m)TLS to PG#627
shortishly wants to merge 217 commits into
623-support-postgresql-mtls-client-authentication-for-backend-connectionsfrom
main

Conversation

@shortishly

Copy link
Copy Markdown
Contributor

work in progress

shortishly and others added 30 commits September 23, 2024 16:14
This change refactors the consumer protocol types (like MemberMetadata,
MemberAssignment) from the broker crate into the sans-io crate. These
are protocol-level types that belong with the other protocol
serialization code.

The sans-io crate now handles all encoding/decoding of the consumer
protocol types independent of IO concerns.
The commit adds support for consumer groups including: - Client-side
Group data structure - Range partition assignor implementation -
Consumer protocol (de)serialization - Consumer group assignor trait and
types
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
dependabot Bot and others added 12 commits July 29, 2026 13:46
Bumps [fake](https://github.com/cksac/fake-rs) from 4.4.0 to 5.1.0.
- [Release notes](https://github.com/cksac/fake-rs/releases)
- [Commits](https://github.com/cksac/fake-rs/commits)

---
updated-dependencies:
- dependency-name: fake
  dependency-version: 5.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.44.0 to 1.48.0.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](crate-ci/typos@v1.44.0...v1.48.0)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-version: 1.48.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 7.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@v5...v7)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…softprops/action-gh-release-3

build(deps): bump softprops/action-gh-release from 2 to 3
build(deps): bump fake from 4.4.0 to 5.1.0
…extractions/setup-just-4

build(deps): bump extractions/setup-just from 3 to 4
added née Tansu when referencing the new name Nisshi
dependabot Bot and others added 3 commits July 30, 2026 11:19
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
shortishly and others added 13 commits July 31, 2026 12:44
…/actions/checkout-7

build(deps): bump actions/checkout from 4 to 7
- abort transactions whose transaction_timeout_ms has elapsed via the
  existing end_in_tx path, releasing the last stable offset they pin
- guard end_in_tx with a status SELECT ... FOR UPDATE against a racing
  or retried EndTxn
- let txn_detail's timer reset on a resolved (COMMITTED/ABORTED) row,
  not just an untouched one
- txn_detail.started_at becomes timestamptz
- treat PREPARE_COMMIT/PREPARE_ABORT as finalization in progress: a
  matching retry no-ops without writing a second control marker, a
  conflicting outcome returns InvalidTxnState instead of acking success
- tie txn_detail to the producer epoch in the two delete_by_txn queries,
  which deleted bookkeeping for every epoch of the producer
- order txn_select_produced_topitions deterministically so concurrent
  finalizations acquire watermark row locks in the same order
- never expire a transaction_timeout_ms of 0; cast the sweep's $2 to
  timestamptz
- maintain_transactions now aborts through abort_timed_out, which bumps the
  producer's epoch: without it a still-alive producer keeps writing under its
  old epoch into a transaction the broker already finalized, and that data
  reaches read_committed consumers as ordinary committed data
- end_in_tx validates the request's epoch before touching transaction state,
  returning ProducerFenced for a stale epoch and UnknownProducerId for an
  unknown producer
…nicking

init_producer had a todo!() for anything that was not literally (-1, -1): API
versions 2 and below omit producer_id/epoch entirely and decode as (None, None),
and v3+ epoch-bump recovery carries a real id and epoch. The (-1, -1) logic moves
to bump_or_create_producer; recovery requests are validated against the current
epoch (ProducerFenced when stale), and malformed partial requests get
InvalidRequest.
Re-adding a partition already in the transaction violated txn_topition's
unique (txn_detail, topition) constraint, surfacing to the client as a
broken connection mid-transaction; Kafka treats the repeat add as a no-op.
feat(storage): abort timed-out transactions in postgres
…ions

record_fetch withheld any row whose inserting transaction was not older
than the global transaction horizon (pg_snapshot_xmin), so a single open
transaction anywhere in the database made committed records temporarily
invisible to fetch; produce already serializes offsets per partition
through the watermark row lock held to commit, so every visible row
below the committed high watermark is final and the guard is unneeded.
…-txn

fix(storage): stop postgres fetch stalling on unrelated open transactions
topic_delete_by.sql narrowed the delete on topic.cluster rather than
topic.id, so the subquery only established that the named topic existed
and the delete then matched every topic in the cluster. topition
references topic on delete cascade, and record and header cascade from
topition, so a single DeleteTopics wiped every topic and every record in
the cluster.

Caught by librdkafka 0033_regex_subscribe against postgres, which deletes
two topics at teardown: the first delete succeeded and took the second
with it, so the second returned UNKNOWN_TOPIC_OR_PARTITION.

Narrow the delete on topic.id, matching every sibling delete_by_topic
statement. The SQL is shared, so this covers the pg, lite and limbo
backends.
fix(storage): scope topic delete to the named topic
Kafka record headers are an ordered list that may repeat a key. The
header table keyed on (topition, offset_id, k) and header_fetch.sql had
no order by, so postgres served headers from that primary key index in
key order rather than produce order, and a repeated key could not be
stored at all.

Caught by librdkafka 0073_headers and 0085_headers against postgres.
0073 produces msgid, static, multi, multi, multi, null, empty and
validates by index; sorted by key that starts with "empty", which is
what it reported at index 0. 0085 produces header_0..header_260 and got
header_10 back at index 2, the byte-sorted position.

The existing round-trip coverage in nisshi-broker/tests/fetch.rs
compares headers as a BTreeSet, so it could not see either ordering or
duplicates -- only the compat suite caught this.

Add an ordinal column recording the position of each header within its
record, key the table on (topition, offset_id, ordinal) so repeated keys
are storable, and order the fetch by it. The DDL and SQL are shared, so
this covers the pg, lite and limbo backends.

The header table changes shape: an existing database needs to be
recreated, or migrated by adding the column and replacing the primary
key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants