Merge ~cjwatson/launchpad:db-kafka-offset into launchpad:db-devel

Proposed by Colin Watson
Status: Needs review
Proposed branch: ~cjwatson/launchpad:db-kafka-offset
Merge into: launchpad:db-devel
Diff against target: 22 lines (+16/-0)
1 file modified
database/schema/patch-2211-18-0.sql (+16/-0)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
William Grant db Pending
Launchpad code reviewers db Pending
Review via email: mp+438771@code.launchpad.net

Commit message

Add KafkaOffset table

Description of the change

In order to consume events from Kafka, we'll need a way to keep track of our position in any given event stream. This is tracked by topic name and partition (with the number of partitions depending on the number of parallel consumers of any given topic). Updating a table of (topic, partition, offset) in the same transaction as we handle whatever else we need to do for that event gives us exactly-once event delivery, and seems to integrate quite nicely into the rest of Launchpad.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

LGTM

review: Approve

Unmerged commits

ee8a49c... by Colin Watson

Add KafkaOffset table

In order to consume events from Kafka, we'll need a way to keep track of
our position in any given event stream. This is tracked by topic name
and partition (with the number of partitions depending on the number of
parallel consumers of any given topic). Updating a table of (topic,
partition, offset) in the same transaction as we handle whatever else we
need to do for that event gives us exactly-once event delivery, and
seems to integrate quite nicely into the rest of Launchpad.

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/database/schema/patch-2211-18-0.sql b/database/schema/patch-2211-18-0.sql
0new file mode 1006440new file mode 100644
index 0000000..c0c5e5d
--- /dev/null
+++ b/database/schema/patch-2211-18-0.sql
@@ -0,0 +1,16 @@
1-- Copyright 2023 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6CREATE TABLE KafkaOffset (
7 id serial PRIMARY KEY,
8 topic text NOT NULL,
9 partition integer NOT NULL,
10 stored_offset integer NOT NULL
11);
12
13CREATE UNIQUE INDEX kafkaoffset__topic__partition__key
14 ON KafkaOffset (topic, partition);
15
16INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 18, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: