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

[Bug] Memory leak in seen_outbound_block_requests #3326

Open
elderhammer opened this issue Jun 23, 2024 · 0 comments · May be fixed by #3330
Open

[Bug] Memory leak in seen_outbound_block_requests #3326

elderhammer opened this issue Jun 23, 2024 · 0 comments · May be fixed by #3330
Assignees
Labels
bug Incorrect or unexpected behavior

Comments

@elderhammer
Copy link
Contributor

elderhammer commented Jun 23, 2024

🐛 Bug Report

seen_outbound_block_requests may contain some old requests and never be cleaned up.

2024-06-23T15:27:56.042427Z DEBUG snarkos_node_router::helpers::cache: Block requests: {127.0.0.1:4132: {BlockRequest { start_height: 3517, end_height: 3518 }}, 127.0.0.1:42031: {}, 127.0.0.1:4203: {BlockRequest { start_height: 211, end_height: 216 }, BlockRequest { start_height: 21, end_height: 26 }, BlockRequest { start_height: 41, end_height: 46 }, BlockRequest { start_height: 61, end_height: 66 }, BlockRequest { start_height: 11, end_height: 16 }, BlockRequest { start_height: 121, end_height: 126 }, BlockRequest { start_height: 181, end_height: 186 }, BlockRequest { start_height: 186, end_height: 191 }, BlockRequest { start_height: 1, end_height: 6 }, BlockRequest { start_height: 116, end_height: 121 }, BlockRequest { start_height: 101, end_height: 106 }, BlockRequest { start_height: 126, end_height: 131 }, BlockRequest { start_height: 196, end_height: 201 }, BlockRequest { start_height: 216, end_height: 221 }, BlockRequest { start_height: 146, end_height: 151 }, BlockRequest { start_height: 26, end_height: 31 }, BlockRequest { start_height: 36, end_height: 41 }, BlockRequest { start_height: 221, end_height: 226 }, BlockRequest { start_height: 16, end_height: 21 }, BlockRequest { start_height: 96, end_height: 101 }, BlockRequest { start_height: 66, end_height: 71 }, BlockRequest { start_height: 111, end_height: 116 }, BlockRequest { start_height: 51, end_height: 56 }, BlockRequest { start_height: 136, end_height: 141 }, BlockRequest { start_height: 206, end_height: 211 }, BlockRequest { start_height: 226, end_height: 231 }, BlockRequest { start_height: 71, end_height: 76 }}}
...
2024-06-23T15:58:41.527649Z DEBUG snarkos_node_router::helpers::cache: Block requests: {127.0.0.1:42031: {}, 127.0.0.1:4201: {}, 127.0.0.1:4132: {BlockRequest { start_height: 10434, end_height: 10435 }}, 127.0.0.1:4203: {BlockRequest { start_height: 211, end_height: 216 }, BlockRequest { start_height: 21, end_height: 26 }, BlockRequest { start_height: 41, end_height: 46 }, BlockRequest { start_height: 61, end_height: 66 }, BlockRequest { start_height: 11, end_height: 16 }, BlockRequest { start_height: 121, end_height: 126 }, BlockRequest { start_height: 181, end_height: 186 }, BlockRequest { start_height: 186, end_height: 191 }, BlockRequest { start_height: 1, end_height: 6 }, BlockRequest { start_height: 116, end_height: 121 }, BlockRequest { start_height: 101, end_height: 106 }, BlockRequest { start_height: 126, end_height: 131 }, BlockRequest { start_height: 196, end_height: 201 }, BlockRequest { start_height: 216, end_height: 221 }, BlockRequest { start_height: 146, end_height: 151 }, BlockRequest { start_height: 26, end_height: 31 }, BlockRequest { start_height: 36, end_height: 41 }, BlockRequest { start_height: 221, end_height: 226 }, BlockRequest { start_height: 16, end_height: 21 }, BlockRequest { start_height: 96, end_height: 101 }, BlockRequest { start_height: 66, end_height: 71 }, BlockRequest { start_height: 111, end_height: 116 }, BlockRequest { start_height: 51, end_height: 56 }, BlockRequest { start_height: 136, end_height: 141 }, BlockRequest { start_height: 206, end_height: 211 }, BlockRequest { start_height: 226, end_height: 231 }, BlockRequest { start_height: 71, end_height: 76 }}}

Steps to Reproduce

  1. When sending a block request to a peer, the block request will be recorded
    // If the message type is a block request, add it to the cache.
    if let Message::BlockRequest(request) = message {
    self.router().cache.insert_outbound_block_request(peer_ip, request);
    }
  2. The peer closes the connection
  3. Since no block response will be received, the block request will not be cleaned up
    // Remove the block request, checking if this node previously sent a block request to this peer.
    if !self.router().cache.remove_outbound_block_request(peer_ip, &request) {
    bail!("Peer '{peer_ip}' is not following the protocol (unexpected block response)")
    }

Expected Behavior

This shouldn't happen.

Your Environment

snarkOS Version: 5d4de02

@elderhammer elderhammer added the bug Incorrect or unexpected behavior label Jun 23, 2024
@ljedrz ljedrz self-assigned this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants