CStoreEditor Should Count Connections

Bug #1415254 reported by Jason Stephenson
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Won't Fix

Bug Description

CStoreEditor (used throughout the backend and some utility scripts) should track the number of times its connect and disconnect methods are called and only actually disconnect when the count reaches 0. This improvement would reduce the amount of discipline required in using CStoreEditor. It would also reduce the possibility of a subroutine disconnecting a CStoreEditor that needs to remain connected after the subroutine finishes.

The proposal is to add a connection_count state variable to CStoreEditor. It will be initialized to 0 in the constructor.

Every call to connect will increment the count by 1. (Connect already checks if the editor is connected and only connects if it isn't already.)

The disconnect method will decrement the connection count by 1, if the count is greater than 0, each time it is called. If the count reaches 0, then the actual disconnect will happen if the editor is connected.

The reset method, which is mainly called from the CStoreEditor's destructor, will set the connection count to 0 before calling disconnect. This will force the disconnect to happen as is the current behavior of the reset method.

Tags: cstoreeditor
description: updated
Revision history for this message
Jason Stephenson (jstephenson) wrote :

After giving this some more thought and playing around with it, I've concluded it is a bad idea given the ways CStoreEditor is used. It actually doesn't do anyting to reduce the discipline required, makes some use cases (say a connect, followed by xact_begin/xact_commit in a loop, with a disconnect outside the loop) problematic. It also has the potential to allow the introduction of a new class of bugs.

Changed in evergreen:
status: In Progress → Won't Fix
assignee: Jason Stephenson (jstephenson) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers