Skip to content

Conversation

@aaron-steinfeld
Copy link
Contributor

Description

Switching from a RW lock to mutual exclusion since adding updates is also not thread safe.

@codecov
Copy link

codecov bot commented Jul 21, 2021

Codecov Report

Merging #114 (7cc0def) into main (2cbcbc0) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #114      +/-   ##
============================================
- Coverage     59.78%   59.77%   -0.02%     
  Complexity      295      295              
============================================
  Files            39       39              
  Lines          2979     2978       -1     
  Branches        368      368              
============================================
- Hits           1781     1780       -1     
  Misses         1026     1026              
  Partials        172      172              
Flag Coverage Δ
integration 59.77% <100.00%> (-0.02%) ⬇️
unit 39.92% <100.00%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
...data/service/rxclient/EntityDataCachingClient.java 96.77% <100.00%> (-0.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cbcbc0...7cc0def. Read the comment docs.

@github-actions

This comment has been minimized.

// Acquire write lock to ensure no more modification of this update
Lock lock = pendingUpdateStripedLock.get(entityKey).writeLock();
// Make sure no current additions
Lock lock = pendingUpdateStripedLock.get(entityKey);

Choose a reason for hiding this comment

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

L133 seems redundant since cache update is already done within L132. Can be removed.

Copy link
Contributor Author

@aaron-steinfeld aaron-steinfeld Jul 21, 2021

Choose a reason for hiding this comment

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

two different uses of the word cache.

Single<Entity> updateResult =
          EntityDataCachingClient.this.createOrUpdateEntity(entityKey, condition).cache();

Caches in the Single - that is, all subscribers will share a result rather than re-executing
( http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#cache-- )

EntityDataCachingClient.this.cache.put(entityKey, updateResult);

puts the single itself into the guava cache for future callers

Choose a reason for hiding this comment

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

Yes, but if we go inside:

private Single<Entity> createOrUpdateEntity(
      EntityKey entityKey, UpsertCondition upsertCondition) {
    Single<Entity> updateResult =
        this.upsertEntityWithoutCaching(entityKey, upsertCondition).cache();
    EntityDataCachingClient.this.cache.put(entityKey, updateResult);
    return updateResult;
  }

that is already adding the single within the guava cache, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for following up on this, my mind is clearly all over the place 🙁 - addressed.

@github-actions

This comment has been minimized.

@aaron-steinfeld aaron-steinfeld merged commit 1b2fe7a into main Jul 21, 2021
@aaron-steinfeld aaron-steinfeld deleted the more-threadz branch July 21, 2021 12:55
@github-actions
Copy link

Unit Test Results

  30 files  ±0    30 suites  ±0   21s ⏱️ ±0s
141 tests ±0  141 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 1b2fe7a. ± Comparison against base commit 2cbcbc0.

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.

4 participants