Resolve API versions on connection#1136
Conversation
22f0102 to
1033aa4
Compare
| self.assertEqual(rmsg1.timestamp, None) | ||
| self.assertEqual(rmsg1.timestamp_type, None) | ||
| self.assertNotEqual(rmsg1.timestamp, None) | ||
| self.assertTrue(rmsg1.timestamp >= s_time_ms) |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
829c29b to
6a5edf6
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1136 +/- ##
==========================================
- Coverage 95.79% 94.85% -0.95%
==========================================
Files 88 88
Lines 15834 15671 -163
Branches 1425 1374 -51
==========================================
- Hits 15168 14864 -304
- Misses 411 563 +152
+ Partials 255 244 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c04dded to
a62d7a6
Compare
a62d7a6 to
710a348
Compare
|
@vmaurin I see one test became flaky with "BrokenPipeError: [Errno 32] Broken pipe" error after this change, while it succeeds for other your branch. Any idea why it may happen? |
I have a lead @ods . I fix a garbage collection issue of the connection being passed to log.debug that was preventing the proper collection. But as it is not held by the log, it is probably getting collected to early here. Let me see if I can find a fix |
f2f76cf to
e86cff6
Compare
Could you elaborate please? How |
This test was failing on CI while running on my local Line 61 in e86cff6 After investigating, it appears it was related to the log level used for running the test, appearing only with level == DEBUG. In the code, there are statement like these that are passing I solved the issue by using Unfortunately, I tried a commit here to fix the test e86cff6 but it haven't made things better, I need to investigate further |
e86cff6 to
a9b30c7
Compare
|
Have you tried using |
|
BTW, using |
a9b30c7 to
1913063
Compare
|
It is some kind of flaky behavior if the logging is happening and releasing the resource before or after the "del conn" in the integration test. I have updated the code to use repr and also add a conditional to avoid paying too much resource to compute the repr. I still have the flaky test with the broken pipe to solve |
|
The main difference I am seeing at the moment, is that before, this test was not performing the api versions request/response roundtrip (so it was purely writing data on the socket) Now we have:
|
Do you see a way to make the problem reproducable locally, e.g. by inserting |
|
For me (and the CI) it was systematic. Maybe playing with the log handler configuration to have something slower here ? But at least this one is fixed, and it is probably a good thing to not leak references to the logger layer (we cannot know how fast is handled) |
|
For the current flaky tests, it has nothing to do with garbage collection. I have dumped the server logs and we do have an issue So the server is closing the connection, resulting in the broken pipe. In my local, it is not fast enough to close the connection before the test end |
1e55a44 to
9996c9a
Compare
9996c9a to
08bbfc9
Compare
| def test_creating_invalid_request_classes(): | ||
| with pytest.raises(TypeError): | ||
|
|
||
| class MissingFieldRequest(Request): |
Check notice
Code scanning / CodeQL
Unused local variable Note test
|
|
||
| with pytest.raises(TypeError): | ||
|
|
||
| class WrongInheritence(int, Request): |
Check notice
Code scanning / CodeQL
Unused local variable Note test
|
Thanks! Great work. Let me know when you think we’re ready to merge. |
I guess it is ready. I did a sanity check on my test project (so running with producer/consumer/transactional loop/admin on a cluster compose of 3 workers) and I didn't see errors |
54b7eaa to
5e22d32
Compare
As stated in the Kafka protocol documentation https://kafka.apache.org/protocol#api_versions the API versions should be solved for each single connection we open with a broker (the broker might be updated while we talk to it).
This commit aim to move all the versions logic into the protocol and the connection only instead of being spread in various classes.
It is introducing for that a new "Request" class that is acting as a builder for the Struct we are going to send into the wire. The Request class tries to collect all possible parameters, and then will react according the best available version in two possible ways:
This choice is made on per API basis.
From the caller perspective, if a different logic need to be ran according the API version, it can look up on the Response.API_VERSION
Doing such a change will help aiokafka supporting Kafka 4.0 as some API versions were removed as mentioned in #1085
It might not achieve the compatibility as we could lack some protocol definition, but it will definitively help.
Changes
Fixes #
Checklist
CHANGESfolder<issue_id>.<type>(e.g.588.bugfix)issue_idchange it to the pr id after creating the PR.feature: Signifying a new feature..bugfix: Signifying a bug fix..doc: Signifying a documentation improvement..removal: Signifying a deprecation or removal of public API..misc: A ticket has been closed, but it is not of interest to users.Fix issue with non-ascii contents in doctest text files.