Skip to content

Ensure use of cachetools is thread-safe#2178

Merged
Robert Yokota (rayokota) merged 3 commits intomasterfrom
fix-cachetools
Jan 26, 2026
Merged

Ensure use of cachetools is thread-safe#2178
Robert Yokota (rayokota) merged 3 commits intomasterfrom
fix-cachetools

Conversation

@rayokota
Copy link
Copy Markdown
Member

@rayokota Robert Yokota (rayokota) commented Jan 24, 2026

What

Ensure use of cachetools is thread-safe

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

Copilot AI review requested due to automatic review settings January 24, 2026 22:16
@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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make cachetools usage safe under concurrency by protecting cache access with locks across both sync and async Schema Registry clients and JSON schema validator caches.

Changes:

  • Add locking around “latest schema” caches in sync/async SchemaRegistryClient implementations.
  • Add locking around JSON Schema validator LRU caches (sync and async).
  • Update unasync generation rules and apply formatting/import-order adjustments across tests and modules.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/unasync.py Updates unasync substitutions to convert asyncio locks/usages into threading locks for sync output.
src/confluent_kafka/schema_registry/_sync/schema_registry_client.py Adds a threading lock to guard cachetools “latest” caches.
src/confluent_kafka/schema_registry/_async/schema_registry_client.py Adds an asyncio lock to guard cachetools “latest” caches and updates cache-clearing methods.
src/confluent_kafka/schema_registry/_sync/json_schema.py Adds a threading lock to guard JSON Schema validator LRU cache.
src/confluent_kafka/schema_registry/_async/json_schema.py Adds an asyncio lock and makes validator retrieval awaitable.
src/confluent_kafka/schema_registry/_sync/avro.py Formatting/import grouping changes (no functional logic change shown in diff).
src/confluent_kafka/schema_registry/_sync/protobuf.py Formatting/whitespace changes (no functional logic change shown in diff).
tests/schema_registry/_sync/test_json_serdes.py Reorders imports/formatting.
tests/schema_registry/_sync/test_json.py Reorders imports/formatting.
tests/schema_registry/_sync/test_avro_serdes.py Reorders imports/formatting.
tests/schema_registry/_sync/test_avro.py Formats long lines for serializer construction.
tests/schema_registry/_sync/test_api_client.py Reorders imports and formats a long test signature.
tests/integration/schema_registry/_sync/test_json_serializers.py Reorders imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/unasync.py
Comment thread src/confluent_kafka/schema_registry/_sync/json_schema.py
Comment thread src/confluent_kafka/schema_registry/_sync/schema_registry_client.py
Comment thread src/confluent_kafka/schema_registry/_sync/protobuf.py Outdated
@sonarqube-confluent
Copy link
Copy Markdown

@rayokota Robert Yokota (rayokota) merged commit 25973e0 into master Jan 26, 2026
2 of 3 checks passed
@rayokota Robert Yokota (rayokota) deleted the fix-cachetools branch January 26, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants