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

distributed-key-value-store example doesn't work as expected #5838

Open
0xBison opened this issue Jan 31, 2025 · 6 comments
Open

distributed-key-value-store example doesn't work as expected #5838

0xBison opened this issue Jan 31, 2025 · 6 comments

Comments

@0xBison
Copy link

0xBison commented Jan 31, 2025

Summary

The code for the example distributed-key-value-store doesnt work. This has been reported in another thread here by @tqwewe but the issue is marked as resolved (it is not): #4194 (comment)

He mentioned it works on linux but not on his mac. I am also on mac (M1 max) so this could be a mac related issue.

Expected behavior

Successfully put record a

Actual behavior

I run 2 nodes, both nodes get the listening logs on different ports but neither allows you to put a record in the dht.

Logs are (from both nodes - just a different port)

Listening in /ip4/127.0.0.1/tcp/61689
Listening in /ip4/192.168.254.121/tcp/61689
Listening in /ip4/192.168.64.1/tcp/61689
PUT a 1
Failed to put record: QuorumFailed { key: Key(b"a"), success: [], quorum: 1 }

Possible Solution

No response

Version

master branch latest commit

Would you like to work on fixing this bug?

No

@kamuik16
Copy link
Contributor

kamuik16 commented Feb 1, 2025

While I tried to reproduce the issue, I got this issue the first time, but on the second time I was able to run the example correctly.

Listening in /ip4/127.0.0.1/tcp/52034
Listening in /ip4/127.0.2.2/tcp/52034
Listening in /ip4/127.0.2.3/tcp/52034
Listening in /ip4/192.168.1.34/tcp/52034
Listening in /ip4/172.16.0.2/tcp/52034
PUT rust awesome
Successfully put record "rust"
Listening in /ip4/127.0.0.1/tcp/52035
Listening in /ip4/127.0.2.2/tcp/52035
Listening in /ip4/127.0.2.3/tcp/52035
Listening in /ip4/192.168.1.34/tcp/52035
Listening in /ip4/172.16.0.2/tcp/52035
GET rust
Got record "rust" "awesome"
Got record "rust" "awesome"

@0xBison
Copy link
Author

0xBison commented Feb 1, 2025

@kamuik16 odd. i get this issue every time without fail. tried many times

@SAMAD101
Copy link

SAMAD101 commented Feb 2, 2025

While I tried to reproduce the issue, I got this issue the first time, but on the second time I was able to run the example correctly.

Listening in /ip4/127.0.0.1/tcp/52034
Listening in /ip4/127.0.2.2/tcp/52034
Listening in /ip4/127.0.2.3/tcp/52034
Listening in /ip4/192.168.1.34/tcp/52034
Listening in /ip4/172.16.0.2/tcp/52034
PUT rust awesome
Successfully put record "rust"
Listening in /ip4/127.0.0.1/tcp/52035
Listening in /ip4/127.0.2.2/tcp/52035
Listening in /ip4/127.0.2.3/tcp/52035
Listening in /ip4/192.168.1.34/tcp/52035
Listening in /ip4/172.16.0.2/tcp/52035
GET rust
Got record "rust" "awesome"
Got record "rust" "awesome"

Same works fine for me as well

@dariusc93
Copy link
Member

Hey! Could you explain your environment, provide any logs (eg using RUST_LOG=debug, etc), and if applicable, any changes made to the example?

@SAMAD101
Copy link

SAMAD101 commented Feb 2, 2025

@dariusc93 I seem to lose connection with another peer (I'm using 2 peers) multiple times as long as I have them running.

2025-02-02T17:35:21.863619Z DEBUG Swarm::poll: libp2p_swarm: Connection closed with error KeepAliveTimeout: Connected { endpoint: Listener { local_addr: /ip4/172.17.0.1/tcp/41711, send_back_addr: /ip4/192.168.1.9/tcp/43489 }, peer_id: PeerId("12D3KooWBQDLCRVmdRCwFXR96mteNqnjUBk6sWUeQQErmPgDNSRE") } total_peers=0

However, it re-establishes the connection soon after:

2025-02-02T17:37:20.187092Z DEBUG new_established_connection{remote_addr=/ip4/192.168.1.9/tcp/41711 id=15 peer=12D3KooWQMLWsixcXYrGFEiGS8onaXFaqduy4FRcBstYnQV1g8WP}:Connection::poll: yamux::connection::stream: 7626da93/1: eof

No, I didn't edit the code in the example.

Environment:

  • OS: Linux (Arch Linux)
  • rustup 1.27.1
  • rustc 1.83.0
  • cargo 1.83.0
  • Shell: zsh

@Prabhat1308
Copy link
Contributor

@SAMAD101 is correct here. I tried the same setup on my macbook pro (M4 pro) and the examples seems to be working. It takes time to pickup the connection with the peer and then it works fine (It also disconnects in between).

These are the logs from my terminals

terminal 1

Listening in /ip4/127.0.0.1/tcp/53535
Listening in /ip4/10.81.43.130/tcp/53535
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Failed to put record: QuorumFailed { key: Key(b"my-key"), success: [], quorum: 1 }
PUT my-key my-value
Successfully put record "my-key"
PUT a 1
Successfully put record "a"
PUT B 2
Successfully put record "B"
PUT C 3
Successfully put record "C"

terminal 2

Listening in /ip4/127.0.0.1/tcp/53537
Listening in /ip4/10.81.43.130/tcp/53537
Got record "my-key" "my-value"
GET my-key
Got record "my-key" "my-value"
GET my-key
Got record "my-key" "my-value"
GET my-key
Got record "my-key" "my-value"
GET my-key
Got record "my-key" "my-value"
GET my-key
Got record "my-key" "my-value"
GET a
Got record "a" "1"
Get b
expected GET, GET_PROVIDERS, PUT or PUT_PROVIDER
GET b   
Failed to get record: NotFound { key: Key(b"b"), closest_peers: [PeerId("12D3KooWKf5FeLwgTckeaGBqRKfhdRvgB3Aj752hGrPo3G41HW73")] }
GET B
Got record "B" "2"

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

No branches or pull requests

5 participants