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

Bitswap Getblocks: CancelWant on ctx cancel #1995

Closed
wants to merge 73 commits into from

Conversation

rht
Copy link
Contributor

@rht rht commented Nov 22, 2015

Though ipfs get cancel works only after the close notify issue has been fixed.

daviddias and others added 30 commits November 11, 2015 10:04
License: MIT
Signed-off-by: David Dias <[email protected]>
This used to lead to large refcount numbers, causing Flush to create a
lot of IPFS objects, and merkledag to consume tens of gigabytes of
RAM.

License: MIT
Signed-off-by: Jeromy <[email protected]>
OS X sed is documented as "-i SUFFIX", GNU sed as "-iSUFFIX". The one
consistent case seems to be "-iSUFFIX", where suffix cannot empty (or
OS X will parse the next argument as the suffix).

This used to leave around files named `refsout=` on Linux, and was
just confusing.

License: MIT
Signed-off-by: Jeromy <[email protected]>
These secondary copies were never actually queried, and didn't contain
the indirect refcounts so they couldn't become the authoritative
source anyway as is. New goal is to move pinning into IPFS objects.

A migration will be needed to remove the old data from the datastore.
This can happen at any time after this commit.

License: MIT
Signed-off-by: Jeromy <[email protected]>
Pinner had method GetManual that returned a ManualPinner, so every
Pinner had to implement ManualPinner anyway.

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
Platform-dependent behavior is not nice, and negative refcounts are
not very useful.

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>

sharness: Don't assume we know all things that can create garbage

License: MIT
Signed-off-by: Jeromy <[email protected]>
WARNING: No migration performed! That needs to come in a separate
commit, perhaps amended into this one.

This is the minimal rewrite, only changing the storage from
JSON(+extra keys) in Datastore to IPFS objects. All of the pinning
state is still loaded in memory, and written from scratch on Flush. To
do more would require API changes, e.g. adding error returns.

Set/Multiset is not cleanly separated into a library, yet, as it's API
is expected to change radically.

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
There was doublewrapping with an unneeded msgio. given that we
use a stream muxer now, msgio is only needed by secureConn -- to
signal the boundaries of an encrypted / mac-ed ciphertext.

Side note: i think including the varint length in the clear is
actually a bad idea that can be exploited by an attacker. it should
be encrypted, too. (TODO)

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
* ID service stream
* make the relay service use msmux
* fix nc tests

Note from jbenet: Maybe we should remove the old protocol/muxer
and see what breaks. It shouldn't be used by anything now.

License: MIT
Signed-off-by: Jeromy <[email protected]>
Signed-off-by: Juan Batiz-Benet <[email protected]>
The addition of a locking interface to the blockstore allows us to
perform atomic operations on the underlying datastore without having to
worry about different operations happening in the background, such as
garbage collection.

License: MIT
Signed-off-by: Jeromy <[email protected]>
This commit improves (fixes) the FetchGraph call for recursively
fetching every descendant node of a given merkledag node. This operation
should be the simplest way of ensuring that you have replicated a dag
locally.

This commit also implements a method in the merkledag package called
EnumerateChildren, this method is used to get a set of the keys of every
descendant node of the given node. All keys found are noted in the
passed in KeySet, which may in the future be implemented on disk to
avoid excessive memory consumption.

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Juan Batiz-Benet <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>

dont GC blocks used by pinner

License: MIT
Signed-off-by: Jeromy <[email protected]>

comment GC algo

License: MIT
Signed-off-by: Jeromy <[email protected]>

add lock to blockstore to prevent GC from eating wanted blocks

License: MIT
Signed-off-by: Jeromy <[email protected]>

improve FetchGraph

License: MIT
Signed-off-by: Jeromy <[email protected]>

separate interfaces for blockstore and GCBlockstore

License: MIT
Signed-off-by: Jeromy <[email protected]>

reintroduce indirect pinning, add enumerateChildren dag method

License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
rht and others added 13 commits November 11, 2015 10:04
Implements a solution for #1908

This PR replaces #1909

License: MIT
Signed-off-by: Andrew Chin <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
License: MIT
Signed-off-by: Jeromy <[email protected]>
Add a --no-pin option to `ipfs add`
License: MIT
Signed-off-by: Jeromy <[email protected]>
if bucket doesnt have enough peers, grab more elsewhere
add closenotify and large timeout to gateway
Add config option for flatfs no-sync
@jbenet jbenet added the status/in-progress In progress label Nov 22, 2015
@rht rht force-pushed the wire/ctx-bitswap-cancelwant branch from 5717463 to ad84e8b Compare November 22, 2015 16:24
@@ -208,6 +208,12 @@ func (bs *Bitswap) GetBlocks(ctx context.Context, keys []key.Key) (<-chan *block
log.Event(ctx, "Bitswap.GetBlockRequest.Start", &k)
}

go func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although it would be better to write something that is like ctx, cancel := ContextCancelWants(ctx)

Copy link
Member

Choose a reason for hiding this comment

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

if its just a single case, you dont need the select.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about adding a default timeout (~time.Hour*24)?

Copy link
Member

Choose a reason for hiding this comment

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

mmm... i don't know about that. maybe ask @jbenet

Copy link
Member

Choose a reason for hiding this comment

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

i'm generally against timeouts in places where they should be implemented higher up by a caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lines later have <-ctx.Done(), if this is to moved here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the timeout is meant for the commands in general, not specific to bitswap. ctx.Done() already includes timeout case if it is specified.

Copy link
Member

Choose a reason for hiding this comment

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

callers of blockservice.GetBlock can set timeouts as they see necessary.

Copy link
Member

Choose a reason for hiding this comment

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

(or rather, callers of the dagservice.Get)

Copy link
Member

Choose a reason for hiding this comment

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

+1 to having callers always give the proper timeouts. we really should remove remaining context.TODO and context.Background to make sure everything has a proper reason for existing.

i believe the http server stuff has ways of detecting that the client has gone away and is no longer expecting a response. it may be tricky to get the wiring to the context right, if it's not yet there.

we may want to hunt into some google http server code that uses contexts, or look in the golang-nuts mailing list.

@rht rht added the RFCR label Nov 22, 2015
License: MIT
Signed-off-by: rht <[email protected]>
@jbenet
Copy link
Member

jbenet commented Dec 1, 2015

this change in general LGTM. but the test failures are bad news :( -- need to get that fixed.

also, i think we should make sure everything that feeds into callers of bitswap (and their calllers) do so with properly cancelled contexts, all the way back to the requests causing them.


that said, there is a behavior we may want to allow, a sort of like "detached request", where we have a set of "currently being downloaded" dags that continue to be requested until the user shuts down ipfs or cancels them explicitly. Think of this like a torrent client. we could make that an explicit option in a get request or whatever, and have a facility for listing those ongoing long-term requests. (or if we do this for all requests, have a facility for manually canceling the whole dag get, not unwanting hash by hash.)

@jbenet
Copy link
Member

jbenet commented Jan 24, 2016

@rht why close this PR? no longer needed? or needs a rebase?

@Kubuxu Kubuxu deleted the wire/ctx-bitswap-cancelwant branch February 27, 2017 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants