Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvs: store data pointed by valref raw and unencoded in content store #1214

Merged
merged 9 commits into from
Sep 28, 2017

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Sep 28, 2017

This series of patches updates the KVS so that treeobj valref objects will read/write data to the content store in raw/unencoded form.

The key work was to ensure the internal KVS cache could handle storing raw data instead of only json. After this work, the remaining work sort of "fell out" of this. On lookup, create cache entries that contain raw data and handle them appropriately for valref objects. On commits, cache entries with raw data will be written out as raw data (instead of everything being assumed json).

Change internal json_t *o field to void *data, so the internally
cached data is not type specific.
Convert cache_entry_create() to not accept any parameters, it now
only creates an empty cache entry.

Create new function cache_entry_create_json(), that takes an optional
json object to hold the cache entry data.  If the user passes in
NULL, it behaves identically to calling cache_entry_create().

Adjust callers of cache_entry_create() appropriately throughout.

Add unit tests and coverage appropriately.
Support type field in cache entries, so different types of data
can be stored in the cache entry.

Add new functions cache_entry_type() and cache_entry_is_type_json()
to retrieve/test type.

Add unit tests appropriately.
Add support for cache entries that support storing raw data.

Included in this patch is new function cache_entry_create_raw(),
cache_entry_is_type_raw(), cache_entry_get_raw(), and
cache_entry_set_raw().

Add unit tests appropriately.
Update internal lookup API to handle valref references pointing to
raw unencoded data in the content store.

Most notably, missing references have an additional boolean indicating
if data is raw, so that on data load it can be handled appropriately.

In addition, when returning data pointed to by a valref, add checks
to ensure the data is raw in the KVS cache.

Adjust lookup unit tests appropriately.
Update internal commit API to handle valref references pointing to
raw unencoded data in the content store.

Most notably, create cache entries with raw data when appropriate,
so it will ultimately get flushed to the content store as raw
unencoded data.
Update lookup, commit, and KVS cache calls to handle potential for
data being raw or json.  The major change being valref treeobj objects
pointing to raw unencoded data in the content store.

Fixes flux-framework#1187
@codecov-io
Copy link

codecov-io commented Sep 28, 2017

Codecov Report

Merging #1214 into master will decrease coverage by <.01%.
The diff coverage is 82.58%.

@@            Coverage Diff             @@
##           master    #1214      +/-   ##
==========================================
- Coverage   78.23%   78.22%   -0.01%     
==========================================
  Files         158      158              
  Lines       29142    29283     +141     
==========================================
+ Hits        22800    22908     +108     
- Misses       6342     6375      +33
Impacted Files Coverage Δ
src/common/libkvs/treeobj.c 82.85% <100%> (-0.56%) ⬇️
src/modules/kvs/commit.c 76.68% <60%> (-1.16%) ⬇️
src/modules/kvs/kvs.c 64% <71.11%> (-0.11%) ⬇️
src/modules/kvs/cache.c 91.84% <92.94%> (+0.61%) ⬆️
src/modules/kvs/lookup.c 83.88% <94.28%> (-1.16%) ⬇️
src/common/libflux/content.c 86.66% <0%> (-3.34%) ⬇️
src/common/libutil/dirwalk.c 93.57% <0%> (-0.72%) ⬇️
src/common/libflux/future.c 88.31% <0%> (-0.47%) ⬇️
... and 8 more

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 78.642% when pulling 9428d33 on chu11:issue1187-7 into 92a797f on flux-framework:master.

@chu11
Copy link
Member Author

chu11 commented Sep 28, 2017

just realized I didn't do one specific test. I should add some tests to try and handle the specific case of putting content into the content store via flux content store and read it back via the flux kvs command (and put a valref object into the kvs along the way).

{
struct cache_entry *hp;

if ((data && len <= 0) || (!data && len)) {
Copy link
Member

Choose a reason for hiding this comment

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

The content cache allows a size = 0 blob to be stored. Probably we should allow it in the KVS and add test coverage. Not sure if it worked before, but this would prevent it I guess.

I'll review more closely tomorrow - just noticed that on a quick skim.

Copy link
Member Author

Choose a reason for hiding this comment

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

the intent was if len == 0, data should == NULL. Would this be ok?

Copy link
Member

Choose a reason for hiding this comment

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

Oh duh, sorry, I guess I didn't look closely enough there!

Copy link
Member

Choose a reason for hiding this comment

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

I'll open a separate bug on ability to store zero length data under a key as there do seem to be some issues there, unrelated to this PR.

@garlick
Copy link
Member

garlick commented Sep 28, 2017

OK, I opened #1215 on zero length values as a test coverage issue, since it seems to work OK actually.

I made a pass through the code and didn't spot anything wrong. Since the test coverage is pretty good, I'd be inclined to give the thumbs up, though I think you're proposed test addition is a good one to add before we merge.

I do apologize that you had to do so much work to accomplish a seemingly simple change. As we discussed earlier, I think the ad-hoc, cache-centric mechanism used in the KVS to implement the reactive idiom is at fault. We most likely don't benefit from caching raw values (as opposed to decoded JSON metadata), but we're forced into it because that's the way we stall/restart message handlers while we wait for content RPC's. I'll try to get a bug open on that work so we can track it in the plan and decide if it's worth doing sooner rather than later. Had we done it before this, I think you would have had an easier time.

Add tests to ensure data written to content store in raw form
via the kvs can be read outside of the KVS.  Also verify that
valref tree objects can be put into the KVS to point to data
already in the content store.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 78.634% when pulling 3e3c6ed on chu11:issue1187-7 into 92a797f on flux-framework:master.

@chu11
Copy link
Member Author

chu11 commented Sep 28, 2017

restarted some builds, write error one and a #1169 one.

@garlick
Copy link
Member

garlick commented Sep 28, 2017

OK, thanks @chu11 this is progress!

@garlick garlick merged commit 19d06f1 into flux-framework:master Sep 28, 2017
@grondo grondo mentioned this pull request May 10, 2018
@chu11 chu11 deleted the issue1187-7 branch June 5, 2021 17:59
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