Skip to content

feat(server): socket migration across shard - #2476

Merged
spetz merged 31 commits into
apache:masterfrom
tungtose:socket-transfer
Dec 21, 2025
Merged

spetz merged 31 commits into
apache:masterfrom
tungtose:socket-transfer

Conversation

@tungtose

Copy link
Copy Markdown
Contributor

This PR addressing #2386

Enable TCP socket migration across shards. When a client sends messages to the wrong shard, migrate the socket to the correct shard to eliminate cross-shard forwarding overhead

@tungtose tungtose changed the title feat(performance): socket migration across shard feat(server): socket migration across shard Dec 12, 2025
Comment thread Cargo.toml Outdated
add handler result to control lifecycle

add the point failed to login

at the point the connection hanging, wait for the new recover tcp stream

convert handle_request & handle_event take &Rc<IggyShard> in order to spawn a connection inside the message handler

stucking with the single client polling tests

need to debug test background_graceful_shutdown

all tests pass now

self review

@hubcio hubcio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

overall, design in this PR is sound, however i'd like you to consider: all 50+ handlers now return HandlerResult but only SendMessages use Migrated. have you thought about adding IggyError::ConnectionMigrated(to_shard) and catch it in connection handler? this would greatly reduce changed files in the PR

@spetz @numinnex opinions?

Comment thread core/server/src/shard/handlers.rs Outdated
Comment thread core/server/src/shard/handlers.rs Outdated
Comment thread core/server/src/binary/handlers/messages/send_messages_handler.rs Outdated
Comment thread core/server/src/binary/handlers/messages/send_messages_handler.rs Outdated
Comment thread core/server/src/streaming/session.rs
Comment thread core/configs/server.toml
@tungtose

tungtose commented Dec 15, 2025 •

Copy link
Copy Markdown
Contributor Author

overall, design in this PR is sound, however i'd like you to consider: all 50+ handlers now return HandlerResult but only SendMessages use Migrated. have you thought about adding IggyError::ConnectionMigrated(to_shard) and catch it in connection handler? this would greatly reduce changed files in the PR

@spetz @numinnex opinions?

I actually did that in the first place, but on second thought, this is not an error, so I have to change all of the handler results. I would be happy to change it if you prefer to treat it as an error

@hubcio

hubcio commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

overall, design in this PR is sound, however i'd like you to consider: all 50+ handlers now return HandlerResult but only SendMessages use Migrated. have you thought about adding IggyError::ConnectionMigrated(to_shard) and catch it in connection handler? this would greatly reduce changed files in the PR
@spetz @numinnex opinions?

I actually did that in the first place, but on second thought, this is not an error, so I have to change all of the handler results. I would be happy to change it if you prefer to treat it as an error

I mean your approach does make sense... Lets wait for other core devs opinion.

@tungtose

Copy link
Copy Markdown
Contributor Author

@hubcio I have resolved all comments and fixed the C# tests

Comment thread core/server/src/binary/handlers/messages/send_messages_handler.rs Outdated
Comment thread core/common/src/sender/mod.rs
Comment thread core/server/src/streaming/utils/crypto.rs Outdated
Comment thread core/common/src/sender/mod.rs Outdated
Comment thread core/server/src/binary/handlers/messages/send_messages_handler.rs

@hubcio hubcio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@numinnex can you check this too?

@spetz
spetz merged commit 96c3b1f into apache:master Dec 21, 2025
53 checks passed
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.

5 participants