Skip to content

BE-1254: Store a relay's outbox cursor and lock - #10702

Draft
TimDiekmann wants to merge 1 commit into
t/be-1253-add-the-hash-graph-relay-cratefrom
t/be-1254-store-a-relays-outbox-cursor-and-lock
Draft

TimDiekmann wants to merge 1 commit into
t/be-1253-add-the-hash-graph-relay-cratefrom
t/be-1254-store-a-relays-outbox-cursor-and-lock

Conversation

@TimDiekmann

Copy link
Copy Markdown
Member

🌟 Purpose

The relay has to remember up to where it has published the entity outbox, and only one process may publish under a relay's name at a time.

🔍 Changes

  • entity_outbox_cursor and store_entity_outbox_cursor read and store a relay's cursor in the entity_outbox_cursor table.
  • try_lock_entity_outbox_relay takes a session-level advisory lock for a relay. The database releases it when the connection closes, also when the process holding it dies.

⚠️ Known issues

  • Nothing calls these functions yet. The relay follows.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Dec 3, 2026 11:08am UTC
petrinaut Ready Ready Preview Dec 3, 2026 11:08am UTC
petrinaut-docs Ready Ready Preview Dec 3, 2026 11:08am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Dec 3, 2026 11:08am UTC

Request Review

@TimDiekmann TimDiekmann self-assigned this Dec 3, 2026
@github-actions github-actions Bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.37%. Comparing base (e0f0e83) to head (8f68767).

Files with missing lines Patch % Lines
...tore/src/store/postgres/knowledge/entity/outbox.rs 0.00% 22 Missing ⚠️
Additional details and impacted files
@@                             Coverage Diff                              @@
##           t/be-1253-add-the-hash-graph-relay-crate   #10702      +/-   ##
============================================================================
- Coverage                                     70.38%   70.37%   -0.02%     
============================================================================
  Files                                          2142     2142              
  Lines                                        226437   226459      +22     
  Branches                                       9820     9820              
============================================================================
- Hits                                         159381   159367      -14     
- Misses                                        65004    65041      +37     
+ Partials                                       2052     2051       -1     
Flag Coverage Δ
hash-graph 21.14% <ø> (ø)
hash-graph-api 48.63% <ø> (ø)
hash-graph-atlas 80.15% <ø> (-0.03%) ⬇️
hash-graph-postgres-store 31.16% <0.00%> (-0.04%) ⬇️
hashql-compiletest 28.62% <ø> (ø)
hashql-eval 81.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$20.4 \mathrm{ms} \pm 188 \mathrm{μs}\left({\color{gray}1.95 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.68 \mathrm{ms} \pm 18.0 \mathrm{μs}\left({\color{gray}-1.211 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$9.64 \mathrm{ms} \pm 85.1 \mathrm{μs}\left({\color{gray}-0.793 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$145 \mathrm{ms} \pm 1.02 \mathrm{ms}\left({\color{red}25.6 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$11.6 \mathrm{ms} \pm 95.8 \mathrm{μs}\left({\color{gray}-0.130 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$19.0 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}-2.008 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2079 $$21.2 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{gray}2.60 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.93 \mathrm{ms} \pm 22.2 \mathrm{μs}\left({\color{gray}-0.687 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1034 $$10.4 \mathrm{ms} \pm 89.6 \mathrm{μs}\left({\color{gray}-0.273 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$2.95 \mathrm{ms} \pm 19.9 \mathrm{μs}\left({\color{gray}-2.026 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.36 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-0.451 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$2.64 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-1.265 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$4.07 \mathrm{ms} \pm 28.1 \mathrm{μs}\left({\color{gray}0.503 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.83 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-1.057 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$3.30 \mathrm{ms} \pm 23.8 \mathrm{μs}\left({\color{gray}-0.156 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 134 $$3.56 \mathrm{ms} \pm 23.8 \mathrm{μs}\left({\color{gray}-0.398 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.75 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}0.316 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 64 $$3.26 \mathrm{ms} \pm 22.2 \mathrm{μs}\left({\color{gray}-0.992 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.16 \mathrm{ms} \pm 13.6 \mathrm{μs}\left({\color{gray}-0.923 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.11 \mathrm{ms} \pm 11.6 \mathrm{μs}\left({\color{gray}-0.426 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.19 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}-0.269 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 9 $$2.45 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-0.687 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.29 \mathrm{ms} \pm 16.9 \mathrm{μs}\left({\color{gray}0.839 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 4 $$2.47 \mathrm{ms} \pm 14.7 \mathrm{μs}\left({\color{gray}-0.861 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.45 \mathrm{ms} \pm 21.5 \mathrm{μs}\left({\color{gray}1.14 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.22 \mathrm{ms} \pm 22.4 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$2.35 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{gray}-0.832 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$2.78 \mathrm{ms} \pm 20.5 \mathrm{μs}\left({\color{gray}0.936 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.43 \mathrm{ms} \pm 14.6 \mathrm{μs}\left({\color{gray}-0.054 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$2.65 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}0.484 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 67 $$2.75 \mathrm{ms} \pm 21.8 \mathrm{μs}\left({\color{gray}0.246 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.42 \mathrm{ms} \pm 18.2 \mathrm{μs}\left({\color{gray}1.08 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 30 $$2.69 \mathrm{ms} \pm 16.9 \mathrm{μs}\left({\color{gray}-0.295 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$27.3 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{gray}-0.334 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$57.3 \mathrm{ms} \pm 457 \mathrm{μs}\left({\color{gray}2.46 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$31.1 \mathrm{ms} \pm 220 \mathrm{μs}\left({\color{gray}-1.090 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$32.0 \mathrm{ms} \pm 175 \mathrm{μs}\left({\color{gray}-0.433 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$38.9 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{gray}-1.328 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$28.3 \mathrm{ms} \pm 195 \mathrm{μs}\left({\color{gray}-0.684 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$321 \mathrm{ms} \pm 1.04 \mathrm{ms}\left({\color{gray}3.59 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$85.3 \mathrm{ms} \pm 708 \mathrm{μs}\left({\color{lightgreen}-5.211 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$58.2 \mathrm{ms} \pm 423 \mathrm{μs}\left({\color{gray}-0.246 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$296 \mathrm{ms} \pm 1.15 \mathrm{ms}\left({\color{red}5.90 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$8.98 \mathrm{ms} \pm 70.0 \mathrm{μs}\left({\color{gray}-0.724 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$9.27 \mathrm{ms} \pm 74.4 \mathrm{μs}\left({\color{gray}-1.502 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$9.21 \mathrm{ms} \pm 66.1 \mathrm{μs}\left({\color{gray}-1.863 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$9.26 \mathrm{ms} \pm 78.5 \mathrm{μs}\left({\color{gray}-0.271 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$9.26 \mathrm{ms} \pm 72.3 \mathrm{μs}\left({\color{gray}0.146 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$9.04 \mathrm{ms} \pm 83.5 \mathrm{μs}\left({\color{gray}-0.346 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$9.04 \mathrm{ms} \pm 73.4 \mathrm{μs}\left({\color{gray}-1.015 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$9.00 \mathrm{ms} \pm 61.4 \mathrm{μs}\left({\color{gray}-0.549 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$9.04 \mathrm{ms} \pm 57.4 \mathrm{μs}\left({\color{gray}0.268 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$9.33 \mathrm{ms} \pm 54.8 \mathrm{μs}\left({\color{gray}2.27 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$10.3 \mathrm{ms} \pm 53.6 \mathrm{μs}\left({\color{gray}-0.906 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$10.4 \mathrm{ms} \pm 64.7 \mathrm{μs}\left({\color{gray}-0.421 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$10.4 \mathrm{ms} \pm 93.3 \mathrm{μs}\left({\color{gray}1.35 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$10.3 \mathrm{ms} \pm 71.6 \mathrm{μs}\left({\color{gray}-0.358 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$10.4 \mathrm{ms} \pm 76.2 \mathrm{μs}\left({\color{gray}-0.127 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$10.4 \mathrm{ms} \pm 74.0 \mathrm{μs}\left({\color{gray}-1.542 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$10.4 \mathrm{ms} \pm 69.4 \mathrm{μs}\left({\color{gray}0.179 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$10.4 \mathrm{ms} \pm 86.9 \mathrm{μs}\left({\color{gray}0.702 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$10.4 \mathrm{ms} \pm 71.6 \mathrm{μs}\left({\color{gray}-0.635 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$6.11 \mathrm{ms} \pm 38.1 \mathrm{μs}\left({\color{gray}-0.323 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$43.7 \mathrm{ms} \pm 349 \mathrm{μs}\left({\color{gray}-0.280 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$84.4 \mathrm{ms} \pm 546 \mathrm{μs}\left({\color{gray}1.04 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$49.7 \mathrm{ms} \pm 414 \mathrm{μs}\left({\color{gray}1.30 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$56.7 \mathrm{ms} \pm 429 \mathrm{μs}\left({\color{gray}0.288 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$63.7 \mathrm{ms} \pm 616 \mathrm{μs}\left({\color{gray}2.47 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$68.5 \mathrm{ms} \pm 523 \mathrm{μs}\left({\color{gray}0.044 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$41.7 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{gray}-0.473 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$63.5 \mathrm{ms} \pm 414 \mathrm{μs}\left({\color{gray}-0.354 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$47.4 \mathrm{ms} \pm 279 \mathrm{μs}\left({\color{gray}0.569 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$54.6 \mathrm{ms} \pm 426 \mathrm{μs}\left({\color{gray}1.63 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$56.1 \mathrm{ms} \pm 533 \mathrm{μs}\left({\color{gray}2.05 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$56.5 \mathrm{ms} \pm 508 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$104 \mathrm{ms} \pm 482 \mathrm{μs}\left({\color{gray}4.05 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$111 \mathrm{ms} \pm 573 \mathrm{μs}\left({\color{gray}2.81 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$23.8 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{gray}-0.105 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$430 \mathrm{ms} \pm 1.06 \mathrm{ms}\left({\color{gray}0.557 \mathrm{\%}}\right) $$ Flame Graph

This branch was successfully deployed

3 active deployments
Preview – hash — 8f68767b Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut-docs — 8f68767b Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut — 8f68767b Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

1 participant