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

Update to latest go-datastore. Remove thirdparty/datastore2 #4742

Merged
merged 6 commits into from
Mar 28, 2018

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Feb 27, 2018

There are 3 commits here:

  • Bubbling up new go-datastore. It includes some datastores that were extracted from @whyrusleeping repos which means it reduces the dependency tree a bit. The main change here, other than the updated deps, is the ¨go-libp2p-record not signing records anymore.¨ change, which requires some fixes in some tests in namesys.
  • Use delayed datastore in exchange, rather than thirdparty/datastore2. This datastore was added to go-datastore too.
  • Replace ds2.ThreadSafeCloserMapDatastore() with syncds.MutexWrap(datastore.NewMapDatastore()). I am not sure what was the point of the Closer part, but syncds already implements the ThreadSafe part. If I screwed something, it will hopefully show up in the tests (this only affects test code).

@hsanjuan hsanjuan self-assigned this Feb 27, 2018
@ghost ghost added the status/in-progress In progress label Feb 27, 2018
@hsanjuan hsanjuan force-pushed the gx/go-datastore branch 3 times, most recently from ba8c809 to a6a637d Compare February 27, 2018 21:46
@hsanjuan
Copy link
Contributor Author

I think I'm too tired to figure out why this test fails:

--- FAIL: TestRepublish (5.07s)
	repub_test.go:93: Could not resolve name.

I will try again tomorrow but if anyone has a tip in the meantime, it's welcome.

@hsanjuan
Copy link
Contributor Author

I have spent considerable time and haven't found why TestRepublish has started failing. However, in the last commit I have fixed it by re-publishing the already-expired record after creating the republisher (with very short EOL though). It seems then it is able to re-publish.

It would seem that now the expired record goes away from the datastore and cannot be republished once expired. This did not happen before. After looking a lot around I'm not sure where this behavior change comes from, or if it's a feature or a bugfix. @Stebalien any idea? Reverting the datastore2 removal does not help though, so this must probably come from changes in one of the updated deps?

This makes sharness tests fail too.

@whyrusleeping
Copy link
Member

@magik6k could you take a look at this one for @hsanjuan ?

@ghost ghost removed the status/in-progress In progress label Feb 28, 2018
@whyrusleeping whyrusleeping reopened this Feb 28, 2018
@ghost ghost assigned whyrusleeping Feb 28, 2018
@ghost ghost added the status/in-progress In progress label Feb 28, 2018
@magik6k
Copy link
Member

magik6k commented Mar 1, 2018

So the record is being removed by kad-dht when a get message arrives to one of the peers (I assume to the peer who published, it's not easy to check with debugger), it then gets to checking if the record is still valid:

stack trace

Which is this bit of code:

	var recordIsBad bool
	recvtime, err := u.ParseRFC3339(rec.GetTimeReceived())
	if err != nil {
		log.Info("either no receive time set on record, or it was invalid: ", err)
		recordIsBad = true
	}

	if time.Now().Sub(recvtime) > MaxRecordAge {
		log.Debug("old record found, tossing.")
		recordIsBad = true
	}

	// NOTE: We do not verify the record here beyond checking these timestamps.
	// we put the burden of checking the records on the requester as checking a record
	// may be computationally expensive

	if recordIsBad {
		err := dht.datastore.Delete(dskey)
		if err != nil {
			log.Error("Failed to delete bad record from datastore: ", err)
		}

		return nil, nil // can treat this as not having the record at all
	}

The interesting thing is that looking at git blame, it has been there since 2 years. I need to dig a bit deeper to find why/how it did work before.

@magik6k
Copy link
Member

magik6k commented Mar 1, 2018

It's caused by the removal of a check in this commit

The check was in func (dht *IpfsDHT) checkLocalDatastore in go-libp2p-kad-dht

	// if its our record, dont bother checking the times on it
	if peer.ID(rec.GetAuthor()) == dht.self {
		return rec, nil
	}

Without it we will remove our own records if they are expired, which wasn't the case before. (btw, did this check work with keystore keys?)

I think it has to do with the IPRS refactoring, it's not merged yet though, so when the breaking changes got pulled in here, things obviously broke.

cc @dirkmc

@dirkmc
Copy link
Contributor

dirkmc commented Mar 1, 2018

That change was made because we removed the signature and author fields from the record, so it's no longer possible to check who the creator of the record was: #4613

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 1, 2018

Thanks @magik6k !

My question here: is losing our own expired records an unintended behavior or not ? @dirkmc

If unintended: how is this going to be addressed (given that Author field and signature is gone)
If not: I can try to fix/remove sharness tests affected by this.

btw, did this check work with keystore keys?

I don't fully understand (maybe I'm missing context), but the republisher in this check does not carry a keystore (it's nil). Is there anything I can do there?

@dirkmc
Copy link
Contributor

dirkmc commented Mar 1, 2018

It was not my intention when I made this change to lose our own expired records. I'm not really sure what the correct answer is here. @whyrusleeping @vyzo @Stebalien do you have any thoughts?

@vyzo
Copy link
Contributor

vyzo commented Mar 1, 2018

that was certainly not anticipated... we debated deleterious effect of the removal of signatures, but didn't see that one coming!

@whyrusleeping
Copy link
Member

Hrm... yeah. We need to retain expired records for records that belong to keys we own. This is so that the republisher can continue functioning even in the absence of a still valid record (what if your node goes offline for a few days). Maybe we should store them in some other way? like a separate place in the datastore for "things we publish". The code that @dirkmc removed was a pretty gnarly hack in the first place.

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 1, 2018

This seems to overpass the purpose of this PR (and blocks me). Is it ok if I:

a) Open issues for this problem to make sure that it's not forgotten
b) Gx "special" libp2p-kad-dht before the problematic changes (in the 3.x.x line instead of the 4.x.x) but with the new go-datastore dep (which is what interests me).
c) Bubble that up in here so that we can merge this one safely.

?

@whyrusleeping
Copy link
Member

@hsanjuan okay, go for it. Lets work on getting the records issue fixed separately.

@dirkmc
Copy link
Contributor

dirkmc commented Mar 1, 2018

I'm happy to work on fixing the republisher. Let's discuss in the separate issue

@dirkmc
Copy link
Contributor

dirkmc commented Mar 1, 2018

Issue created here: #4749

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 2, 2018

This is ready on my side.

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 9, 2018

Who would be so kind to review this? @whyrusleeping @Stebalien @magik6k 🥇

I guess it will need to sit until stable 0.4.14 is out? Thanks in advance anyway

@Kubuxu
Copy link
Member

Kubuxu commented Mar 9, 2018

@hsanjuan it will for sure wait until 0.4.15 dev cycle starts. Merge window for 0.4.14 is closed AFAIK.

@ghost ghost added the status/in-progress In progress label Mar 9, 2018
@Kubuxu Kubuxu removed the status/in-progress In progress label Mar 9, 2018
@Kubuxu Kubuxu added this to the go-ipfs 0.4.15 milestone Mar 9, 2018
Copy link
Member

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

go-ipfs-blockstore appears to have wrong hash somewhere - see the CI fail - https://ci.ipfs.team/blue/organizations/jenkins/go-ipfs/detail/PR-4742/13/pipeline

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 9, 2018

I need to rebase

@ghost ghost added the status/in-progress In progress label Mar 9, 2018
@Kubuxu Kubuxu requested a review from magik6k March 9, 2018 20:19
@Kubuxu Kubuxu added RFM and removed status/in-progress In progress need/review Needs a review labels Mar 9, 2018
@djdv djdv mentioned this pull request Mar 23, 2018
@ghost ghost added the status/in-progress In progress label Mar 26, 2018
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This uses a working libp2p-kad-dht and libp2p-record libraries,
reverts the changes that were introduced to support the newer versions

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
@hsanjuan
Copy link
Contributor Author

Rebased. I think things should be good now.

@whyrusleeping whyrusleeping merged commit 3f6519b into master Mar 28, 2018
@whyrusleeping whyrusleeping deleted the gx/go-datastore branch March 28, 2018 05:18
@ghost ghost removed the status/in-progress In progress label Mar 28, 2018
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
Update to latest go-datastore. Remove thirdparty/datastore2

This commit was moved from ipfs/kubo@3f6519b
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.

7 participants