Skip to content

[python] add lock around SOMAGroup reification#4147

Merged
bkmartinjr merged 4 commits intomainfrom
bkm/group-reify-race
Jun 26, 2025
Merged

[python] add lock around SOMAGroup reification#4147
bkmartinjr merged 4 commits intomainfrom
bkm/group-reify-race

Conversation

@bkmartinjr
Copy link
Copy Markdown
Member

@bkmartinjr bkmartinjr commented Jun 25, 2025

The SOMAGroup / Collection caches reified objects in getitem. This code lacked any concurrency protection, so objects requested concurrently would repeatedly load and overwrite the cache slot in the parent group.

This had a couple of problematic effects if a race to populate the cache occurs:

  • the TileDB group is read multiple times, create multiple SOMA objects, etc. Essentially a performance problem
  • unlike serial invocations, it would return different SOMA objects for the same underlying array, causing object identity tests to fail (we don't normally promise that the identities are eq, but a side effect of the cache is that they are anyway)

Changes:

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.46%. Comparing base (ba60dcd) to head (436dad9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4147       +/-   ##
===========================================
+ Coverage   53.10%   89.46%   +36.35%     
===========================================
  Files         101       60       -41     
  Lines       12702     7158     -5544     
  Branches     1238        0     -1238     
===========================================
- Hits         6746     6404      -342     
+ Misses       5548      754     -4794     
+ Partials      408        0      -408     
Flag Coverage Δ
libtiledbsoma ?
python 89.46% <100.00%> (?)

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

Components Coverage Δ
python_api 89.46% <100.00%> (∅)
libtiledbsoma ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bkmartinjr bkmartinjr marked this pull request as ready for review June 25, 2025 22:09
@bkmartinjr bkmartinjr requested review from jp-dark and ktsitsi June 25, 2025 22:09
@bkmartinjr bkmartinjr merged commit 5262c63 into main Jun 26, 2025
18 checks passed
@bkmartinjr bkmartinjr deleted the bkm/group-reify-race branch June 26, 2025 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants