Skip to content

Only accept NamedRefs in REST API#1583

Merged
nastra merged 3 commits intoprojectnessie:mainfrom
nastra:rest-api-named-refs-only
Jul 13, 2021
Merged

Only accept NamedRefs in REST API#1583
nastra merged 3 commits intoprojectnessie:mainfrom
nastra:rest-api-named-refs-only

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jul 12, 2021

This change is Reviewable

@nastra nastra force-pushed the rest-api-named-refs-only branch from 0334ddb to dd61ca2 Compare July 12, 2021 13:49
@nastra nastra linked an issue Jul 12, 2021 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jul 12, 2021

Codecov Report

Merging #1583 (e8622d8) into main (36d426d) will increase coverage by 0.01%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1583      +/-   ##
============================================
+ Coverage     76.13%   76.15%   +0.01%     
- Complexity     2104     2105       +1     
============================================
  Files           283      283              
  Lines         12752    12768      +16     
  Branches       1020     1024       +4     
============================================
+ Hits           9709     9723      +14     
  Misses         2565     2565              
- Partials        478      480       +2     
Flag Coverage Δ
java 75.27% <70.00%> (+<0.01%) ⬆️
python 86.57% <93.33%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
.../java/org/projectnessie/hms/NessieTransaction.java 50.29% <40.00%> (ø)
.../org/projectnessie/services/rest/BaseResource.java 68.18% <40.00%> (-8.29%) ⬇️
python/pynessie/_log.py 95.00% <83.33%> (-5.00%) ⬇️
...n/java/org/projectnessie/hms/TransactionStore.java 58.62% <100.00%> (ø)
python/pynessie/cli.py 85.71% <100.00%> (+0.18%) ⬆️
.../projectnessie/services/rest/ContentsResource.java 75.00% <100.00%> (ø)
.../org/projectnessie/services/rest/TreeResource.java 70.28% <100.00%> (+0.28%) ⬆️
...in/java/org/projectnessie/hms/NessieStoreImpl.java 47.51% <0.00%> (+0.62%) ⬆️

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 36d426d...e8622d8. Read the comment docs.

@nastra nastra force-pushed the rest-api-named-refs-only branch from 7574660 to 1d9a3da Compare July 12, 2021 17:25
Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

Not sure whether I'm too early with my review, but am I missing changes to TreeApi here?
If this is not yet ready, ignore me

@nastra
Copy link
Contributor Author

nastra commented Jul 13, 2021

but am I missing changes to TreeApi here

you were indeed quite early to the review because I didn't have time to review my own code yet ;)

I don't think we need any changes to the TreeApi. Those passed refs will stay as Strings and we're just validating (via a regex) that a ref isn't a hash.

@nastra nastra requested review from rymurr and snazy July 13, 2021 07:48
Copy link
Contributor

@rymurr rymurr left a comment

Choose a reason for hiding this comment

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

How do we support time travel? eg how do I read from a past hash?

@nastra
Copy link
Contributor Author

nastra commented Jul 13, 2021

How do we support time travel? eg how do I read from a past hash?

Just for completeness, we talked about this on Slack and decided that we probably need to have an additional hashOnRef query parameter where a user can specify a particular hash on the given Branch/Tag.

I'm working on a follow-up PR that addresses this.

@nastra nastra merged commit f1fefdd into projectnessie:main Jul 13, 2021
@nastra nastra deleted the rest-api-named-refs-only branch July 13, 2021 10:06
snazy added a commit to snazy/iceberg that referenced this pull request Jul 15, 2021
Apply changes to Iceberg required by API changes in Nessie:
* [Re-introduce wrapper classes for query params of CommitLog/Entries](projectnessie/nessie#1595)
* [Server-side commit range filtering](projectnessie/nessie#1596)
* [Add hashOnRef query param to support time travel on a named ref](projectnessie/nessie#1589)
* [Only accept NamedRefs in REST API](projectnessie/nessie#1583)
snazy added a commit to snazy/iceberg that referenced this pull request Jul 15, 2021
Apply changes to Iceberg required by API changes in Nessie:
* [Re-introduce wrapper classes for query params of CommitLog/Entries](projectnessie/nessie#1595)
* [Server-side commit range filtering](projectnessie/nessie#1596)
* [Add hashOnRef query param to support time travel on a named ref](projectnessie/nessie#1589)
* [Only accept NamedRefs in REST API](projectnessie/nessie#1583)
rymurr pushed a commit to apache/iceberg that referenced this pull request Jul 15, 2021
* Bump Nessie to 0.8.2 + replace Gradle plugin with new JUnit extension

More changes in this PR in following commits.

Replace Gradle plugin with new JUnit extension.
See [Add JAX-RS tests and add JUnit/Jupyter extension](projectnessie/nessie#1566)

* Changes required by Nessie-API changes

Apply changes to Iceberg required by API changes in Nessie:
* [Re-introduce wrapper classes for query params of CommitLog/Entries](projectnessie/nessie#1595)
* [Server-side commit range filtering](projectnessie/nessie#1596)
* [Add hashOnRef query param to support time travel on a named ref](projectnessie/nessie#1589)
* [Only accept NamedRefs in REST API](projectnessie/nessie#1583)

* Bugfix: must send the Contents.id of the existing table

Nessie's `Contents.id` is a random ID generated when the `Contents.Key` is first used (think:
CREATE TABLE) and must not be changed. This change addresses a bug in the Iceberg-Nesie code
that caused a new id for every change.

* Throw `CommitStateUnknownException` for `renameTable` as well

Follow-up of #2515

* Fix race-condition & save one roundtrip to Nessie during "commit"

When commiting a change, the Nessie-API now returns the hash of the commit for the change.
This returned hash should then be used as the "expected hash" for the next commit.

The previous approach was to commit the change to Nessie and then do another request to
retrieve the new hash of HEAD.

This old approach is prone to a race condition, namely when another commit happens after
"this" commit but before retrieving the "new HEAD", so "this" instance would wrongly
ignore the other commit's changes during conflict checks.

See [Let VersionStore.create()+commit() return the current hash](projectnessie/nessie#1089)
minchowang pushed a commit to minchowang/iceberg that referenced this pull request Aug 2, 2021
* Bump Nessie to 0.8.2 + replace Gradle plugin with new JUnit extension

More changes in this PR in following commits.

Replace Gradle plugin with new JUnit extension.
See [Add JAX-RS tests and add JUnit/Jupyter extension](projectnessie/nessie#1566)

* Changes required by Nessie-API changes

Apply changes to Iceberg required by API changes in Nessie:
* [Re-introduce wrapper classes for query params of CommitLog/Entries](projectnessie/nessie#1595)
* [Server-side commit range filtering](projectnessie/nessie#1596)
* [Add hashOnRef query param to support time travel on a named ref](projectnessie/nessie#1589)
* [Only accept NamedRefs in REST API](projectnessie/nessie#1583)

* Bugfix: must send the Contents.id of the existing table

Nessie's `Contents.id` is a random ID generated when the `Contents.Key` is first used (think:
CREATE TABLE) and must not be changed. This change addresses a bug in the Iceberg-Nesie code
that caused a new id for every change.

* Throw `CommitStateUnknownException` for `renameTable` as well

Follow-up of apache#2515

* Fix race-condition & save one roundtrip to Nessie during "commit"

When commiting a change, the Nessie-API now returns the hash of the commit for the change.
This returned hash should then be used as the "expected hash" for the next commit.

The previous approach was to commit the change to Nessie and then do another request to
retrieve the new hash of HEAD.

This old approach is prone to a race condition, namely when another commit happens after
"this" commit but before retrieving the "new HEAD", so "this" instance would wrongly
ignore the other commit's changes during conflict checks.

See [Let VersionStore.create()+commit() return the current hash](projectnessie/nessie#1089)
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.

REST API should only accept named References instead of Hashes

3 participants