Skip to content

[NOGIL] Make Message class methods thread safe - #2350

Open
Ojasva Jain (ojasvajain) wants to merge 1 commit into
dev_thread_free_supportfrom
msg_class_thread_safe
Open

[NOGIL] Make Message class methods thread safe#2350
Ojasva Jain (ojasvajain) wants to merge 1 commit into
dev_thread_free_supportfrom
msg_class_thread_safe

Conversation

@ojasvajain

@ojasvajain Ojasva Jain (ojasvajain) commented Sep 7, 2026

Copy link
Copy Markdown
Member
  • Message class exposes getters and setters to five fields. On free threaded Python builds, calling setters and getters concurrently can cause use-after-free conditions and incorrect reference counts.

  • This PR fixes this by acquiring a lock around code snippets where we want only one thread to run at a time (critical sections). The getters and setters have been refactored as part of this process. In Message_headers, an unrelated bug related to error not being handled is also fixed.

  • For the five fields that have getters and setters, we have introduced five lock fields within the Message struct.

  • Also contains a minor fix in Consumer_consume method.


Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

References

JIRA:

Test & Review

Open questions / Follow-ups

@confluent-cla-assistant

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@sonarqube-confluent

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
5.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@k-raina Kaushik Raina (k-raina) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR! Provided couple of comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not checking lock for "==" , "len()" etc?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expand more on test coverage, considering its change to message class? One thing i can thing of is memory leak test by counting refcount before and after?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants