Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

name / image / info -data in Profile is broken, with high probability that it is because of stopping the node. #261

Open
chhsiao1981 opened this issue Apr 10, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@chhsiao1981
Copy link
Collaborator

Version information:

Gptt
Version: 0.2.0
Git Commit: 6ffbb92
Architecture: amd64
Go Version: go1.11.1
Operating System: linux

Type:

Bug

Description:

Sometimes the data of name / image / info in Profile is broken and unavailable to access.
Need to check:

  1. What happened to the underlying raw data in db.
  2. Is it because of not correct implementation in graceful shutdown?
  3. Or something went wrong when syncing?~
  4. Or how to know that some data is broken?~ (able to get data, but unable to unmarshal)
  5. How to do resync when data is broken?

#240

@chhsiao1981 chhsiao1981 added the bug Something isn't working label Apr 12, 2019
@chhsiao1981
Copy link
Collaborator Author

chhsiao1981 commented May 3, 2019

  1. Found the following anomaly record:

key: b'.urig\xed\xf1\xf8r\x11\r\xf5\x96\xb8\xa7\x00\xde\xb35\xe3\x92\x07\x92\xeb\xc1 \xe9\xaa\xfb\x95\xc1\x93$\xe8[ )9G\x80\xa21:\xdf\x8e\xd05\xfev,>i\xbfzs\xc4\x16\x16\xd3fc\xa1k\x9cY"\xc8\xe9\xc6\x02\x88\x1d\xe3=\x9fj\xcc*.b8\xc9\K\x1b'

val: b'QMT/F7NeOCmJq6SQN9lX891EuO"],"UT":{"T":1551919303,"NT":863591202}}\x01-.umdb\xcc\x9cF)|\xa5F\o\xf3\x9a\x93k\xca]d7\x106\xbc\x04\x0cO\xf1{5\xe3\x82\x98\x9a\xbaI\x03}\x95\x7f=\xd4K\x8e\xf5\x03{"b":{"V":2,"ID":"BAfNMz9ioVj1Kq87CuUk83HG2qiAc9Wk8ts5LFVxSHAbQwHme'

The data is corrupted.

Strangely only the account-data is corrupted.
It's possible that it's due to that the account information is excessively accessed and some race condition happened when shutting-down the node.

  1. Found that DBUserNodeInfoPrefix is assigned incorrectly, conflict with DBUserImgPrefix.

TODO:

  1. fix DBUserNodeInfoPrefix.
  2. change the setup and do not close the DB in stop.

@chhsiao1981
Copy link
Collaborator Author

Found more fundamental issue about pttdb:

We use LDBBatch for most of db-operation, but it looks like Batch is not threadsafe (Batch.Put and Batch.Reset)

Need to fix the db-operation first:

For LDBBatch.PutAllWithKeyIndex, LDBBatch.PutAll, LDBBatch.TryPutAll, LDBBatch.TryPutAllSameUT, LDBBatch.ForcePutAll: have new leveldb.Batch in every call of the functions.

https://github.com/ailabstw/go-pttai/blob/master/pttdb/ldb_database.go

https://github.com/syndtr/goleveldb/blob/master/leveldb/batch.go#L163

@chhsiao1981
Copy link
Collaborator Author

Confirmed that unable to send packet over 64k.

The max size of our packet may lead to 10M.
We need to segment the packets before sending the data.

https://github.com/pion/sctp/blob/master/stream.go#L146
(from https://github.com/pion/datachannel/blob/master/datachannel.go#L262)
(from https://github.com/ailabstw/go-pttai/blob/master/p2p/webrtc/webrtc_conn.go#L91)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant