Skip to content

Commit a2cb5f1

Browse files
committed
Merge #4: Latest internal updates
Approved-by: Qqwy Priority: Normal Auto-deploy: false
2 parents c3f99ce + 6b177d6 commit a2cb5f1

10 files changed

+278
-110
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/opsqueue_python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "opsqueue_python"
3-
version = "0.30.2"
3+
version = "0.30.4"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

libs/opsqueue_python/opsqueue_python.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ buildPythonPackage rec {
3030
".toml"
3131
".lock"
3232
".db"
33+
".md"
3334
];
3435
};
3536

opsqueue/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "opsqueue"
3-
version = "0.30.1"
3+
version = "0.30.4"
44
edition = "2021"
55
description = "lightweight batch processing queue for heavy loads"
66
repository = "https://github.com/channable/opsqueue"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE submissions DROP COLUMN chunk_size;
2+
ALTER TABLE submissions_completed DROP COLUMN chunk_size;
3+
ALTER TABLE submissions_failed DROP COLUMN chunk_size;

opsqueue/migrations/20250416081453_track_chunk_size.sql renamed to opsqueue/migrations/20250416081453_track_chunk_size.up.sql

File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- 1. Drop all indexes and finally the column itself
2+
DROP INDEX random_chunks_order;
3+
DROP INDEX random_chunks_metadata_order;
4+
DROP INDEX random_chunks_metadata_order2;
5+
ALTER TABLE chunks DROP COLUMN random_order;
6+
ALTER TABLE chunks_metadata DROP COLUMN random_order;
7+
8+
-- 2. Recreate the column with its **old, bad** definition
9+
ALTER TABLE chunks ADD COLUMN random_order INTEGER NOT NULL GENERATED ALWAYS AS (
10+
(((submission_id + chunk_index) % 65536) * 40503) % 65536
11+
) VIRTUAL;
12+
ALTER TABLE chunks_metadata ADD COLUMN random_order INTEGER NOT NULL GENERATED ALWAYS AS (
13+
(((submission_id + chunk_index) % 65536) * 40503) % 65536
14+
) VIRTUAL;
15+
16+
17+
-- 3. Recreate all dropped indexes
18+
CREATE INDEX random_chunks_order ON chunks (
19+
random_order
20+
, submission_id
21+
, chunk_index
22+
);
23+
24+
CREATE INDEX random_chunks_metadata_order ON chunks_metadata (
25+
metadata_key
26+
, metadata_value
27+
, random_order
28+
, submission_id
29+
, chunk_index
30+
);
31+
32+
CREATE INDEX random_chunks_metadata_order2 ON chunks_metadata (
33+
metadata_key
34+
, random_order
35+
, metadata_value
36+
, submission_id
37+
, chunk_index
38+
);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- 1. Drop all indexes and finally the column itself
2+
DROP INDEX random_chunks_order;
3+
DROP INDEX random_chunks_metadata_order;
4+
DROP INDEX random_chunks_metadata_order2;
5+
ALTER TABLE chunks DROP COLUMN random_order;
6+
ALTER TABLE chunks_metadata DROP COLUMN random_order;
7+
8+
-- 2. Recreate the column with its new, proper definition
9+
--
10+
-- Compared to the OG definition, we ensure that the top 42 bits of `submission_id`
11+
-- which contain the timestamp part of the snowflake,
12+
-- always participate in the `random_order`,
13+
-- since the lower 22 bits are likely to be `0` except when under peak load.
14+
ALTER TABLE chunks ADD COLUMN random_order INTEGER NOT NULL GENERATED ALWAYS AS (
15+
(((submission_id + (submission_id >> 22) + chunk_index) % 65536) * 40503) % 65536
16+
) VIRTUAL;
17+
ALTER TABLE chunks_metadata ADD COLUMN random_order INTEGER NOT NULL GENERATED ALWAYS AS (
18+
(((submission_id + (submission_id >> 22) + chunk_index) % 65536) * 40503) % 65536
19+
) VIRTUAL;
20+
21+
22+
-- 3. Recreate all dropped indexes
23+
CREATE INDEX random_chunks_order ON chunks (
24+
random_order
25+
, submission_id
26+
, chunk_index
27+
);
28+
29+
CREATE INDEX random_chunks_metadata_order ON chunks_metadata (
30+
metadata_key
31+
, metadata_value
32+
, random_order
33+
, submission_id
34+
, chunk_index
35+
);
36+
37+
CREATE INDEX random_chunks_metadata_order2 ON chunks_metadata (
38+
metadata_key
39+
, random_order
40+
, metadata_value
41+
, submission_id
42+
, chunk_index
43+
);
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)