Skip to content

Commit bf396e0

Browse files
authored
Bump version to 0.8.0-prerelease-1, merge DB migrations for 0.8.0. (#3478)
Also, fix taskprov_peer_aggregators.role help text. (Previously, the code & the schema disagreed on whether this was our or our peer's role; go with the code's conception that this is our peer's role.)
1 parent a941244 commit bf396e0

17 files changed

+68
-91
lines changed

Cargo.lock

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ homepage = "https://divviup.org"
2020
license = "MPL-2.0"
2121
repository = "https://github.com/divviup/janus"
2222
rust-version = "1.77.0"
23-
version = "0.7.41"
23+
version = "0.8.0-prerelease-1"
2424

2525
[workspace.dependencies]
2626
anyhow = "1"
@@ -50,14 +50,14 @@ hpke-dispatch = "0.7.0"
5050
http = "1.1"
5151
http-api-problem = "0.58.0"
5252
itertools = "0.13"
53-
janus_aggregator = { version = "0.7.41", path = "aggregator" }
54-
janus_aggregator_api = { version = "0.7.41", path = "aggregator_api" }
55-
janus_aggregator_core = { version = "0.7.41", path = "aggregator_core" }
56-
janus_client = { version = "0.7.41", path = "client" }
57-
janus_collector = { version = "0.7.41", path = "collector" }
58-
janus_core = { version = "0.7.41", path = "core" }
59-
janus_interop_binaries = { version = "0.7.41", path = "interop_binaries" }
60-
janus_messages = { version = "0.7.41", path = "messages" }
53+
janus_aggregator = { version = "0.8.0-prerelease-1", path = "aggregator" }
54+
janus_aggregator_api = { version = "0.8.0-prerelease-1", path = "aggregator_api" }
55+
janus_aggregator_core = { version = "0.8.0-prerelease-1", path = "aggregator_core" }
56+
janus_client = { version = "0.8.0-prerelease-1", path = "client" }
57+
janus_collector = { version = "0.8.0-prerelease-1", path = "collector" }
58+
janus_core = { version = "0.8.0-prerelease-1", path = "core" }
59+
janus_interop_binaries = { version = "0.8.0-prerelease-1", path = "interop_binaries" }
60+
janus_messages = { version = "0.8.0-prerelease-1", path = "messages" }
6161
k8s-openapi = { version = "0.22.0", features = ["v1_26"] } # keep this version in sync with what is referenced by the indirect dependency via `kube`
6262
kube = { version = "0.94.2", default-features = false, features = ["client", "rustls-tls"] }
6363
mockito = "1.6.0"

aggregator_core/src/datastore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ macro_rules! supported_schema_versions {
103103
// version is seen, [`Datastore::new`] fails.
104104
//
105105
// Note that the latest supported version must be first in the list.
106-
supported_schema_versions!(7);
106+
supported_schema_versions!(1);
107107

108108
/// Datastore represents a datastore for Janus, with support for transactional reads and writes.
109109
/// In practice, Datastore instances are currently backed by a PostgreSQL database.

db/00000000000001_initial_schema.down.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
DROP INDEX outstanding_batches_task_and_time_bucket_index;
1+
DROP INDEX outstanding_batches_task_id_and_time_bucket_start;
22
DROP TABLE outstanding_batches CASCADE;
3+
DROP TYPE OUTSTANDING_BATCH_STATE CASCADE;
34
DROP INDEX aggregate_share_jobs_interval_containment_index CASCADE;
45
DROP TABLE aggregate_share_jobs CASCADE;
56
DROP INDEX collection_jobs_interval_containment_index CASCADE;
67
DROP INDEX collection_jobs_state_and_lease_expiry CASCADE;
78
DROP INDEX collection_jobs_task_id_batch_id CASCADE;
89
DROP TABLE collection_jobs CASCADE;
910
DROP TYPE COLLECTION_JOB_STATE CASCADE;
11+
DROP INDEX batch_aggregations_gc_time CASCADE;
1012
DROP TABLE batch_aggregations CASCADE;
1113
DROP TYPE BATCH_AGGREGATION_STATE;
1214
DROP INDEX report_aggregations_client_report_id_index CASCADE;

db/00000000000001_initial_schema.up.sql

+35-8
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,25 @@ CREATE TABLE global_hpke_keys(
3131

3232
-- These columns are mutable.
3333
state HPKE_KEY_STATE NOT NULL DEFAULT 'PENDING', -- state of the key
34-
updated_at TIMESTAMP NOT NULL, -- when the key state was last changed
34+
last_state_change_at TIMESTAMP NOT NULL, -- when the key state was last changed. Used for key rotation logic.
3535

3636
-- creation/update records
3737
created_at TIMESTAMP NOT NULL, -- when the row was created
38+
updated_at TIMESTAMP NOT NULL, -- when the row was last changed
3839
updated_by TEXT NOT NULL -- the name of the transaction that last updated the row
3940
);
4041

4142
-- Another DAP aggregator who we've partnered with to use the taskprov extension.
4243
CREATE TABLE taskprov_peer_aggregators(
4344
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- artificial ID, internal only.
44-
endpoint TEXT NOT NULL, -- peer aggregator HTTPS endpoint
45-
role AGGREGATOR_ROLE NOT NULL, -- the role of this aggregator relative to the peer
46-
verify_key_init BYTEA NOT NULL, -- the preshared key used for VDAF verify key derivation.
45+
endpoint TEXT NOT NULL, -- peer aggregator HTTPS endpoint
46+
role AGGREGATOR_ROLE NOT NULL, -- the role of this peer aggregator
47+
verify_key_init BYTEA NOT NULL, -- the preshared key used for VDAF verify key derivation.
4748

4849
-- Parameters applied to every task created with this peer aggregator.
49-
tolerable_clock_skew BIGINT NOT NULL, -- the maximum acceptable clock skew to allow between client and aggregator, in seconds
50-
report_expiry_age BIGINT, -- the maximum age of a report before it is considered expired (and acceptable for garbage collection), in seconds. NULL means that GC is disabled.
51-
collector_hpke_config BYTEA NOT NULL, -- the HPKE config of the collector (encoded HpkeConfig message)
50+
tolerable_clock_skew BIGINT NOT NULL, -- the maximum acceptable clock skew to allow between client and aggregator, in seconds
51+
report_expiry_age BIGINT, -- the maximum age of a report before it is considered expired (and acceptable for garbage collection), in seconds. NULL means that GC is disabled.
52+
collector_hpke_config BYTEA NOT NULL, -- the HPKE config of the collector (encoded HpkeConfig message)
5253

5354
-- creation/update records
5455
created_at TIMESTAMP NOT NULL, -- when the row was created
@@ -165,6 +166,21 @@ CREATE TABLE task_upload_counters(
165166
CONSTRAINT task_upload_counters_unique UNIQUE(task_id, ord)
166167
) WITH (fillfactor = 50);
167168

169+
-- Per-task report aggregation counters, used for metrics.
170+
--
171+
-- Fillfactor is lowered to improve the likelihood of heap-only tuple optimizations. See the
172+
-- discussion around this setting for the task_upload_counters table.
173+
CREATE TABLE task_aggregation_counters(
174+
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- artificial ID, internal only
175+
task_id BIGINT NOT NULL, -- task ID the counter is associated with
176+
ord BIGINT NOT NULL, -- the ordinal index of the task aggregation counter
177+
178+
success BIGINT NOT NULL DEFAULT 0, -- reports successfully aggregated
179+
180+
CONSTRAINT task_aggregation_counters_unique_id UNIQUE(task_id, ord),
181+
CONSTRAINT fk_task_id FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
182+
) WITH (fillfactor = 50);
183+
168184
-- The HPKE public keys (aka configs) and private keys used by a given task.
169185
CREATE TABLE task_hpke_keys(
170186
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- artificial ID, internal-only
@@ -321,6 +337,7 @@ CREATE TABLE batch_aggregations(
321337
CONSTRAINT batch_aggregations_unique_task_id_batch_id_aggregation_param UNIQUE(task_id, batch_identifier, aggregation_param, ord),
322338
CONSTRAINT fk_task_id FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
323339
);
340+
CREATE INDEX batch_aggregations_gc_time ON batch_aggregations(task_id, UPPER(COALESCE(batch_interval, client_timestamp_interval)));
324341

325342
-- Specifies the possible state of a collection job.
326343
CREATE TYPE COLLECTION_JOB_STATE AS ENUM(
@@ -345,6 +362,8 @@ CREATE TABLE collection_jobs(
345362
helper_aggregate_share BYTEA, -- the helper's encrypted aggregate share (HpkeCiphertext, only if in state FINISHED)
346363
leader_aggregate_share BYTEA, -- the leader's unencrypted aggregate share (opaque VDAF message, only if in state FINISHED)
347364

365+
step_attempts BIGINT NOT NULL DEFAULT 0, -- the number of attempts to step the collection job without making progress, regardless of whether the lease was successfully released or not
366+
348367
lease_expiry TIMESTAMP NOT NULL DEFAULT TIMESTAMP '-infinity', -- when lease on this collection job expires; -infinity implies no current lease
349368
lease_token BYTEA, -- a value identifying the current leaseholder; NULL implies no current lease
350369
lease_attempts BIGINT NOT NULL DEFAULT 0, -- the number of lease acquiries since the last successful lease release
@@ -382,6 +401,12 @@ CREATE TABLE aggregate_share_jobs(
382401
);
383402
CREATE INDEX aggregate_share_jobs_interval_containment_index ON aggregate_share_jobs USING gist (task_id, batch_interval);
384403

404+
-- Specifies the possible state of an outstanding batch.
405+
CREATE TYPE OUTSTANDING_BATCH_STATE AS ENUM(
406+
'FILLING', -- this outstanding batch is still being considered for additional reports
407+
'FILLED' -- this outstanding batch has received enough reports, no more are necessary
408+
);
409+
385410
-- The leader's view of outstanding batches, which are batches which have not yet started
386411
-- collection. Used for fixed-size tasks only.
387412
CREATE TABLE outstanding_batches(
@@ -390,11 +415,13 @@ CREATE TABLE outstanding_batches(
390415
batch_id BYTEA NOT NULL, -- 32-byte BatchID as defined by the DAP specification.
391416
time_bucket_start TIMESTAMP,
392417

418+
state OUTSTANDING_BATCH_STATE NOT NULL DEFAULT 'FILLING', -- the current state of this outstanding batch
419+
393420
-- creation/update records
394421
created_at TIMESTAMP NOT NULL, -- when the row was created
395422
updated_by TEXT NOT NULL, -- the name of the transaction that last updated the row
396423

397424
CONSTRAINT outstanding_batches_unique_task_id_batch_id UNIQUE(task_id, batch_id),
398425
CONSTRAINT fk_task_id FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
399426
);
400-
CREATE INDEX outstanding_batches_task_and_time_bucket_index ON outstanding_batches (task_id, time_bucket_start);
427+
CREATE INDEX outstanding_batches_task_id_and_time_bucket_start ON outstanding_batches(task_id, time_bucket_start) WHERE state = 'FILLING';

db/00000000000002_collection_job_step_attempts.down.sql

-1
This file was deleted.

db/00000000000002_collection_job_step_attempts.up.sql

-3
This file was deleted.

db/00000000000003_outstanding_batch_state.down.sql

-4
This file was deleted.

db/00000000000003_outstanding_batch_state.up.sql

-8
This file was deleted.

db/00000000000004_batch_aggregation_gc.down.sql

-1
This file was deleted.

db/00000000000004_batch_aggregation_gc.up.sql

-2
This file was deleted.

db/00000000000005_global_hpke_keys_last_state_change_at.down.sql

-1
This file was deleted.

db/00000000000005_global_hpke_keys_last_state_change_at.up.sql

-11
This file was deleted.

db/00000000000006_global_hpke_keys_last_state_change_at_drop_default.down.sql

-3
This file was deleted.

db/00000000000006_global_hpke_keys_last_state_change_at_drop_default.up.sql

-3
This file was deleted.

db/00000000000007_task_aggregation_counters.down.sql

-1
This file was deleted.

0 commit comments

Comments
 (0)