Skip to content

async_receive2 completes with zero complete messages #373

Open

Description

@mzimbres

While playing with valgrind massif I produced a condition where async_receive2 completes with zero messages. I noticed this because flat_tree::get_total_msgs() was returning 0. From looking at the code I could not spot the problem so I will have to investigate more.

Activity

  1. mzimbres commented on Dec 14, 2025

    @mzimbres
    CollaboratorAuthor

    Found the problem: The push was arriving before I set the receive response and therefore it was being handled in the default adapter. I think this should be considered a misuse of the API: the receive response must be set before any pushes might possibly arrive i.e. before calling async_run.

  2. anarthal commented on Dec 14, 2025

    @anarthal
    Collaborator

    We could make the receive adapter part of config to prevent this, maybe?

  3. mzimbres commented on Dec 14, 2025

    @mzimbres
    CollaboratorAuthor

    Yes, I think that is the correct thing to do. Also, I think async_run should exit with error if no receive adapter is set and a push is received.

  4. anarthal commented on Dec 14, 2025

    @anarthal
    Collaborator

    We have some heuristics where under certain edge cases a regular message is interpreted as a push. I'm worried exiting with an error could do harm if these cases are hit and the user is not actually expecting pushes. Maybe we could issue a warning in the log?

  5. mzimbres commented on Dec 14, 2025

    @mzimbres
    CollaboratorAuthor

    I think there is room to improve the heuristics, for example

    • Unsolicited errors (- and !) should not be sent over the receive channel but logged only.
    • The receive channel should only get pushes (>). This will make a custom message types for pushes more reliable and simpler to write i.e. no need to handle errors.
    • Any other resp3 type for which there is no corresponding request should cause an error and async_run to exit.
  6. anarthal commented on Dec 14, 2025

    @anarthal
    Collaborator

    Wasn't MONITOR using a response type that wasn't a push (>)?

  7. mzimbres commented on Dec 14, 2025

    @mzimbres
    CollaboratorAuthor

    Indeed, just check and it looks like it sends simple strings

    "+1765740441.218176 [0 127.0.0.1:49960] \"ping\"\r\n"
    

    This makes it harder to write custom response types since they have to accomodate for all possibilities. It is pretty hard to traverse a generic_response dealing with all kinds of responses.

  8. anarthal commented on Dec 14, 2025

    @anarthal
    Collaborator

    Yeah, pretty evil. I don't think it's a common case, although we should probably still support it. I'll think of it. I agree the current status quo is not good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions