Skip to content

fix(core): report send racing close as closed - #154

Open
NorthArea wants to merge 1 commit into
masterfrom
northarea/send-close-as-closed
Open

NorthArea wants to merge 1 commit into
masterfrom
northarea/send-close-as-closed

Conversation

@NorthArea

Copy link
Copy Markdown
Collaborator

ConnectionToTarantoolTest.testSendAndReceiveWithConcurrentClose fails in CI from time to time (at least 5 times on 28.10–05.11, both box-integration jobs): it expects the root cause ConnectionClosedException and gets netty's StacklessClosedChannelException.

Cause. A request passes the READY check in ConnectionImpl.send(), then close() closes the channel before netty writes it. The write fails with netty's error, while requests waiting for a response on the same close fail with ConnectionClosedException.

  • fix(core): report send racing close as closed — if a write fails and the connection already has a close reason, the root cause is ConnectionClosedException with that reason; the netty error is kept as suppressed. SendCloseRaceTest reproduces the race every time.

Stand: SendCloseRaceTest 3/3 failed without the fix, 10/10 passed with it; ConnectionToTarantoolTest 15/15 on 3.5.0, 5/5 on 2.11.8; verify and spotless:check pass.

#131 keeps the same expectation in this test (and makes it stricter) but does not change send(); this fix satisfies it.


ConnectionToTarantoolTest.testSendAndReceiveWithConcurrentClose время от времени падает в CI (не меньше 5 раз за 28.10–05.11, оба задания box-integration): ждёт первопричину ConnectionClosedException, а получает StacklessClosedChannelException netty.

Причина. Запрос проходит проверку READY в ConnectionImpl.send(), затем close() закрывает канал до того, как netty его запишет. Запись падает с ошибкой netty, а запросы, ждущие ответа, при том же закрытии падают с ConnectionClosedException.

  • fix(core): report send racing close as closed — если запись не удалась, а у соединения уже есть причина закрытия, первопричина — ConnectionClosedException с этой причиной; ошибка netty сохраняется как suppressed. SendCloseRaceTest воспроизводит гонку каждый раз.

Стенд: SendCloseRaceTest без исправления 3/3 упал, с исправлением 10/10 прошёл; ConnectionToTarantoolTest 15/15 на 3.5.0, 5/5 на 2.11.8; verify и spotless:check проходят.

#131 сохраняет в этом тесте то же ожидание (и делает его строже), но send() не меняет; это исправление ему удовлетворяет.


I haven't forgotten about:

  • Tests
  • Changelog
  • Documentation
  • JavaDoc was written
  • Commit messages comply with the guideline
  • Cleanup the code for review. See checklist

@NorthArea
NorthArea force-pushed the northarea/send-close-as-closed branch from da535cf to f679103 Compare November 6, 2026 07:29
@NorthArea
NorthArea force-pushed the northarea/send-close-as-closed branch 2 times, most recently from bb630b3 to 47731ca Compare November 6, 2026 10:15
A request could pass the READY check in send() and be written after
close() had closed the channel. Its future then failed with a netty
StacklessClosedChannelException, and ConnectionToTarantoolTest
testSendAndReceiveWithConcurrentClose, which expects the root cause to
be ConnectionClosedException, failed in CI from time to time.

When the connection has a close reason, the send failure now has
ConnectionClosedException with that reason as its root cause; the
netty error is kept as suppressed.

SendCloseRaceTest holds the event loop, sends a request and closes the
connection on the event loop before the write runs. Without the fix it
fails with StacklessClosedChannelException.
@NorthArea
NorthArea force-pushed the northarea/send-close-as-closed branch from 47731ca to 0419800 Compare November 6, 2026 11:19

This branch has not been deployed

No deployments
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.

1 participant