GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — A thread might skip the line in publisher flow controller · Issue #421 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.
This repository was archived by the owner on Oct 13, 2026. It is now read-only.

A thread might skip the line in publisher flow controller #421

Copy link
Copy link
Closed
#422
Closed
A thread might skip the line in publisher flow controller#421
#422
Copy link
Assignees
plamut
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@plamut
plamut
opened on May 29, 2021
Issue body actions

In publisher FlowController, the checks whether or not a message can go through based on the current message count are not strict enough.

When a thread blocks because the message limit is hit, it goes to sleep in the add() method until a slot for another message becomes available. This happens when publishing one of the earlier messages completes and that message is released from the flow controller. Assuming that there's now again enough capacity to accept at least one new message, the sleeping threads get notified.

Now, just when our sleeping thread wakes up, but before it re-acquires the lock, another thread might arrive, call add() and acquire the lock just in front of the the woken up thread's nose. The new thread sees that there's room for a new message and takes it, forcing the older thread to wait until the next opportunity.

Expected result:
Threads should always be let through in FIFO order.

The fix is to force threads to reserve a slot for the message in the same way they need to reserve the free bytes capacity. Also, any released message slots must be distributed in FIFO order among the queued up threads.

In an extreme case, this issue can also cause some starving, though that becomes increasingly unlikely, as the waiting thread will eventually get lucky and grab the lock before the threads arriving after it will.

Activity

  1. plamut
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on May 29, 2021
  2. plamut
    self-assigned this
    on May 29, 2021
  3. product-auto-label
    added
    api: pubsubIssues related to the googleapis/python-pubsub API.
    on May 29, 2021
  4. plamut
    closed this as completedin #422on Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @plamut
    plamut

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.