Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

swarm/chunk: add tags#1341

Merged
acud merged 17 commits intoswarm-rather-stablefrom
add-tags-struct
Apr 30, 2019
Merged

swarm/chunk: add tags#1341
acud merged 17 commits intoswarm-rather-stablefrom
add-tags-struct

Conversation

@acud
Copy link
Copy Markdown
Contributor

@acud acud commented Apr 12, 2019

This PR adds the tag data structure to the chunk package.
This is necessary for implementing push sync tags.

https://hackmd.io/9eWxJ_MJS8i04onWg49UBA?both

closes #1019

@acud acud added the push-sync label Apr 12, 2019
@acud acud requested review from janos and zelig April 12, 2019 08:33
@acud acud self-assigned this Apr 12, 2019
Copy link
Copy Markdown
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

It is a nice start Elad. I have a few concerns about data consistency in SetTotal and WaitTill functions and other things are minor.

Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
@zelig zelig mentioned this pull request Apr 15, 2019
20 tasks
@acud acud force-pushed the add-tags-struct branch from 63c9be8 to 3d4f925 Compare April 16, 2019 09:41
@acud acud requested a review from zelig April 16, 2019 09:51
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/chunk/tags.go Outdated
@acud acud removed their assignment Apr 17, 2019
@acud acud force-pushed the add-tags-struct branch from 1a32f3c to 842a0d4 Compare April 23, 2019 06:52
@acud acud force-pushed the add-tags-struct branch from 842a0d4 to 1ca671e Compare April 23, 2019 07:21
Comment thread swarm/chunk/tag.go Outdated
Comment thread swarm/chunk/tag.go Outdated
@acud
Copy link
Copy Markdown
Contributor Author

acud commented Apr 27, 2019

@zelig addressed your PR comments. That linter error for some reason won't go away. tried linting and gofmt but it won't fix.

@acud acud requested review from janos and zelig April 29, 2019 13:31
Copy link
Copy Markdown
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

some minor points LGTM

Comment thread swarm/chunk/tags.go Outdated
Comment thread swarm/sctx/sctx.go
Comment thread swarm/chunk/tag_test.go
Comment thread swarm/chunk/tag_test.go
Copy link
Copy Markdown
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

I have only one concern about DoneSplit function.

Comment thread swarm/chunk/tag.go
type State = uint32

const (
SPLIT State = iota // chunk has been processed by filehasher/swarm safe call
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you considered maybe to call this constants StateSplit, StateStored, etc? Something like http.StatusOK, http.StatusNotFound...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a good idea Janos. I'll do that in the integration PR as I'd just like to get this merged more or less as-is so I can continue work on a rebased rc

Comment thread swarm/chunk/tag.go
// DoneSplit sets total count to SPLIT count and sets the associated swarm hash for this tag
// is meant to be called when splitter finishes for input streams of unknown size
func (t *Tag) DoneSplit(address Address) int {
total := atomic.LoadUint32(&t.split)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a data consistency problem since DoneSplit is reading and writing two related values. Two calls to DoneSplit function at the same time can be scheduled in between two atomic calls in that function, resulting incorrect value stored into t.total.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

well it is supposed to be called only once, should be commented

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the data consistency problem here, IMO, is a non-issue as @zelig says it should be called only once. I'll comment that in the integration PR. There is, however, another problem which has to do with serializing the struct. There are multiple fields being read and we should have some synchronization around that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool, thanks for explanations.

@acud acud merged commit 910b3a1 into swarm-rather-stable Apr 30, 2019
@acud acud deleted the add-tags-struct branch May 5, 2019 18:35
nonsense pushed a commit that referenced this pull request May 10, 2019
* swarm/chunk: add tags backend to chunk package
nonsense pushed a commit that referenced this pull request May 10, 2019
* swarm/chunk: add tags backend to chunk package
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants