Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
db1de29
SQL: Filter already reserved chunks from `Chunk` selection
ReinierMaas Jul 13, 2026
a6664b3
Add failing PreferDistinct fairness test
jerbaroo Aug 6, 2026
ada8709
PreferDistinct sorts submissions by metadata
jerbaroo Aug 6, 2026
b40b106
fixup! PreferDistinct sorts submissions by metadata
jerbaroo Aug 6, 2026
31cf874
fixup! PreferDistinct sorts submissions by metadata
jerbaroo Aug 6, 2026
7c1d688
fixup! PreferDistinct sorts submissions by metadata
jerbaroo Aug 6, 2026
c903fb1
SQL: Prevent duplicated binds
ReinierMaas Jul 13, 2026
7dfef50
fixup! SQL: Filter already reserved chunks from `Chunk` selection
jerbaroo Aug 6, 2026
b48dd48
SQL: Add metadata count FFI function
ReinierMaas Jul 15, 2026
573b2d6
fixup! SQL: Add metadata count FFI function
jerbaroo Aug 6, 2026
1d2f36a
Flatten PreferDistinct into a single query level
jerbaroo Aug 6, 2026
02fc44d
fixup! Flatten PreferDistinct into a single query level
jerbaroo Aug 6, 2026
98f022d
SQL: Deduplicate FFI calls per distinct metadata value
jerbaroo Aug 6, 2026
efe45e2
SQL: Single FFI call
jerbaroo Aug 6, 2026
3d9f2c3
Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 10, 2026
4887d3d
fixup! SQL: Add metadata count FFI function
jerbaroo Aug 10, 2026
7903f8b
fixup! fixup! PreferDistinct sorts submissions by metadata
jerbaroo Aug 10, 2026
d644aa5
fixup! fixup! fixup! PreferDistinct sorts submissions by metadata
jerbaroo Aug 11, 2026
630434c
fixup! Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 17, 2026
a5c3220
fixup! Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 17, 2026
5c0aec1
fixup! Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 17, 2026
35d1b0f
fixup! Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 17, 2026
85a2c2e
fixup! Break ties of PreferDistinct submissions with equal counts
jerbaroo Aug 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ http = { version = "1.4.0" }
humantime = { version = "2.1.0" }
insta = { version = "1.47.2" }
itertools = { version = "0.15.0" }
libsqlite3-sys = { version = "0.30.1" }
moka = { version = "0.12.15", features = ["sync"] }
moro-local = { version = "0.4.0" }
object_store = { version = "0.14.0", features = ["gcp", "http"] }
Expand Down
29 changes: 29 additions & 0 deletions libs/opsqueue_python/tests/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,32 @@ def test_lookup_too_many_submission_ids_by_strategic_metadata() -> None:
)
assert exc.type is TooManyMatchingSubmissionsError
assert exc.value.max_submissions == max_


def test_prefer_distinct_strategy_fairness(opsqueue: OpsqueueProcess) -> None:
"""Test the PreferDistinct strategy fairly interleaves chunks from different
submissions based on their strategic metadata.

"""
url = "file:///tmp/opsqueue/test_prefer_distinct_fairness"
producer_client = ProducerClient(f"localhost:{opsqueue.port}", url)
consumer_client = ConsumerClient(f"localhost:{opsqueue.port}", url)
company_ids = [1, 2, 3]
chunks_per_company = 4
company_id_per_submission = {}
for company_id in company_ids:
sub_id = producer_client.insert_submission(
[company_id] * chunks_per_company,
chunk_size=1,
strategic_metadata={"company_id": company_id},
)
company_id_per_submission[sub_id] = company_id
strategy = strategy_from_description(("PreferDistinct", "company_id", "Oldest"))
reserved_company_order = []
# Fetch 1 chunk at a time. Because we don't complete chunks, opsqueue's
# metastate tracks them as reserved, increasing the busy count for that
# company.
for _ in range(len(company_ids) * chunks_per_company):
[chunk] = consumer_client.reserve_chunks(strategy=strategy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking, does our new strategy selection retain randomness if a client reserves multiple chunks in one go? Do we care for that or would documenting the multi-chunk reservation behaviour be enough?

reserved_company_order.append(company_id_per_submission[chunk.submission_id])
assert reserved_company_order == [1, 2, 3] * chunks_per_company
3 changes: 2 additions & 1 deletion opsqueue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ux.workspace = true
anyhow.workspace = true
# Database:
sqlx = { workspace = true, optional = true }
libsqlite3-sys = { workspace = true, optional = true }
# Serialization:
serde.workspace = true
serde_json.workspace = true
Expand Down Expand Up @@ -69,7 +70,6 @@ clap.workspace = true
humantime.workspace = true

dashmap.workspace = true
crossbeam-skiplist.workspace = true
sqlformat.workspace = true
workspace-hack.workspace = true

Expand All @@ -90,6 +90,7 @@ required-features = ["server-logic"]
# Dependencies only in use by the server-logic:
server-logic = [
"dep:sqlx",
"dep:libsqlite3-sys",
"dep:opentelemetry-otlp",
"dep:opentelemetry-semantic-conventions",
"dep:moka",
Expand Down
Loading
Loading