[CONPY-196] Missing decrement of reference pointer (connection) when closing the cursor Created: 2022-03-24  Updated: 2022-05-03  Resolved: 2022-03-24

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.0.10
Fix Version/s: 1.0.11

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to CONPY-195 Memory leak - using cursor function -... Closed
Python Version: 3.8

 Description   

When closing a cursor the reference pointer for the corresponding connection object needs to be decremented to prevent leakage.

How to repeat:

import resource, mariadb
 
    ...
 
    def test_connection_ref(self):
        if is_maxscale():
            self.skipTest("skip test (possible timeout)")
        last= 0
        for i in range(1,100000):
            conn= create_connection()
            cursor= conn.cursor()
            cursor.close()
            conn.close()
            usage = resource.getrusage(resource.RUSAGE_SELF)
            new= usage[2]
            if (last > 0):
                self.assertEqual(new, last)
            last= new

This doesn't affect Connector/Python 1.1.x



 Comments   
Comment by Georg Richter [ 2022-03-24 ]

fixed in rev. 2bad21412f195a2f5489bd3fa3f790d35497b24b

Generated at Thu Feb 08 03:30:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.