Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14507

OutboundMessagingConnection backlog is not fully written in case of race conditions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Feedback Received
    • None
    • None
    • Normal

    Description

      The OutboundMessagingConnection writes into a backlog queue before the connection handshake is successfully completed, and then writes such backlog to the channel as soon as the successful handshake moves the channel state to READY.
      This is unfortunately race prone, as the following could happen:
      1) One or more writer threads see the channel state as NOT_READY in #sendMessage() and are about to enqueue to the backlog, but they get descheduled by the OS.
      2) The handshake thread is scheduled by the OS and moves the channel state to READY, emptying the backlog.
      3) The writer threads are scheduled back and add to the backlog, but the channel state is READY at this point, so those writes would sit in the backlog and expire.

      Please note a similar race condition exists between OutboundMessagingConnection#sendMessage() and MessageOutHandler#channelWritabilityChanged(), which is way more serious as the channel writability could frequently change, luckily it looks like ChannelWriter#write() never gets invoked with checkWritability at true (so writes never go to the backlog when the channel is not writable).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sbtourist Sergio Bossa
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: