Skip to content

Conversation

@derektriley
Copy link
Contributor

@derektriley derektriley commented Oct 22, 2025

Description:
This pull request refactors the block node connection management logic to improve how connections are cleaned up and rescheduled, especially during stream resets and forced switches. The changes remove redundant cleanup methods, introduce a configurable delay for rescheduling connections after a forced switch, and update related tests to reflect the new behavior. The code now exposes connection state for easier management and testing.

This PR fixes bugs with connection promotion/switching, making sure the connection is removed from the manager's internal state so the node's are able to be connected to in the future.

Connection Cleanup and Rescheduling Improvements

  • Removed the connectionResetsTheStream and removeConnectionAndClearActive methods from BlockNodeConnectionManager, consolidating connection cleanup logic and making rescheduling more explicit. Stream resets now directly trigger selection of a new block node for streaming.
  • When closing a connection, the connection map is now updated directly from BlockNodeConnection

Forced Switch Handling

  • Added a new configuration property forcedSwitchRescheduleDelay to BlockNodeConnectionConfig, allowing the delay for rescheduling a closed active connection after a forced switch to be set via configuration.
  • Implemented logic to reschedule the previously active connection with the configured delay when a forced switch occurs.

Testing

  • Updated and removed obsolete tests for the old stream reset and cleanup logic, and added new tests for forced switch rescheduling, ensuring the new behavior is correctly validated.

Related issue(s):

Fixes #21734

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
@derektriley derektriley added this to the v0.68 milestone Oct 22, 2025
@derektriley derektriley self-assigned this Oct 22, 2025
@derektriley derektriley requested review from a team as code owners October 22, 2025 19:25
@lfdt-bot
Copy link

lfdt-bot commented Oct 22, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cks/impl/streaming/BlockNodeConnectionManager.java 82.35% 3 Missing ⚠️

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #21803      +/-   ##
============================================
+ Coverage     70.62%   70.81%   +0.19%     
- Complexity    24353    24377      +24     
============================================
  Files          2673     2667       -6     
  Lines        104202   104188      -14     
  Branches      10935    10942       +7     
============================================
+ Hits          73591    73785     +194     
+ Misses        26567    26365     -202     
+ Partials       4044     4038       -6     
Files with missing lines Coverage Δ Complexity Δ
...app/blocks/impl/streaming/BlockNodeConnection.java 90.72% <100.00%> (ø) 76.00 <0.00> (ø)
...ra/node/config/data/BlockNodeConnectionConfig.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
...cks/impl/streaming/BlockNodeConnectionManager.java 91.45% <82.35%> (-0.39%) 69.00 <2.00> (-5.00)

... and 67 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codacy-production
Copy link

codacy-production bot commented Oct 22, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.17% (target: -1.00%) 84.21%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (15aada6) 104107 77589 74.53%
Head commit (1060245) 103627 (-480) 77404 (-185) 74.69% (+0.17%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#21803) 19 16 84.21%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
@AlexKehayov
Copy link
Contributor

Probably the .md files will need some updating after these changes too.

Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
timfn-hg
timfn-hg previously approved these changes Oct 28, 2025
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
timfn-hg
timfn-hg previously approved these changes Oct 29, 2025
petreze
petreze previously approved these changes Oct 29, 2025
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
@derektriley derektriley dismissed stale reviews from petreze and timfn-hg via 1060245 October 29, 2025 16:49
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

Successfully merging this pull request may close these issues.

BlockBufferService force switching connections issue

6 participants