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 — [Bug] TopicTransactionBuffer contains potential thread safety issues · Issue #22119 · apache/pulsar

[Bug] TopicTransactionBuffer contains potential thread safety issues #22119

New issue
Copy link
New issue
Copy link
Closed
#22149
Closed
[Bug] TopicTransactionBuffer contains potential thread safety issues#22119
#22149
Copy link
Assignees
dao-jun

Description

@lhotari
lhotari
opened on Feb 26, 2024
Issue body actions

Search before asking

  • I searched in the issues and found nothing similar.

Version

master

Minimal reproduce step

The ongoingTxns field is a LinkedMap which isn't thread safe.

What did you expect to see?

thread safe handling in TopicTransactionBuffer

What did you see instead?

ongoingTxns is handled in a problematic way. There are multiple threads that both mutate and read the collection.
It's possible that this isn't a problem, but it's very hard to reason about the thread safetyness of the code currently.

There definitely have been attempts to ensure thread safety. There seems to be an assumption that it's fine to either have synchronized (TopicTransactionBuffer.this) { or run on a single thread such as
topic.getBrokerService().getPulsar().getTransactionExecutorProvider().getExecutor(this), to make it thread safe.

One note about topic.getBrokerService().getPulsar().getTransactionExecutorProvider().getExecutor(this) is that this is pointing to different object instances in the code base. It wouldn't be ensuring single threaded access to all accesses of the object instances that are handled.

It is possible that thread safety is achieved through ways that are hard to observe. As long as all accesses form a "happens-before" chain, even through "piggy backing", it's possible that the code is after all thread safe. The problem is that a small change might break that and the solution is very brittle. Thread safety issues are very hard to notice. The best way to prevent them is to write code that is thread safe.

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. dao-jun
    self-assigned this
    on Feb 26, 2024
  2. dao-jun
    closed this as completedin #22149on Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dao-jun
    dao-jun

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

    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.