U4-9388 - propertytype.GetPropertyTypes causes an inner data reader to close the outer reader

Created by Shannon Deminick 16 Jan 2017, 04:25:13 Updated by Stephan 17 Jan 2017, 07:19:09

Tags: Unscheduled

Is duplicated by: U4-9372

Relates to: deploy-132

Relates to: U4-9322

This problem isn't immediately bubbled to the surface but the problem definitely exist and is probably causing other unwanted issues.

In some cases when you click on a user we get a YSOD

Invalid attempt to Read when reader is closed.

[Stack Trace]
[InvalidOperationException: Invalid attempt to Read when reader is closed.]
   System.Data.SqlServerCe.SqlCeDataReader.Read() +189
   umbraco.DataLayer.RecordsReaderAdapter`1.Read() +23
   umbraco.cms.businesslogic.propertytype.PropertyType.GetPropertyTypes() +139
   umbraco.cms.presentation.user.EditUser.SetupChannel() +729
   umbraco.cms.presentation.user.EditUser.Page_Load(Object sender, EventArgs e) +6029
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   umbraco.BasePages.BasePage.OnLoad(EventArgs e) +14
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

and it's because in the legacy propertytype.GetPropertyTypes method, it does an ExecuteReader and inside of this reader it will execute another reader, however that read is actually the 'same' reader instance and therefore the inner reader closes the outer reader! Pretty sure it's something to do with the changes that was made in order for the legacy business logic layer to use the correct SqlConnection instance. That said, if you use the 7.6 source you won't see this YSOD because the exception is swallowed!! So, we need to:

  • Check all the places where the legacy business logic layer uses: RecordsReaderAdapter.Read and check if we are ever executing a reader inside of a reader
  • Find out if there is a way to prevent errors from a reader inside of a reader - i don't think so, this shouldn't really have ever been allowed, i actually don't think it ever has but since we swallow exceptions we'd never know


Stephan 16 Jan 2017, 08:01:29

@sebastiaan if you are happy having it in 7.5.next I'll merge the PR

Sebastiaan Janssen 16 Jan 2017, 10:01:10

@zpqrtbnk Yes please! Marked for 7.5.8 now.

Stephan 17 Jan 2017, 07:19:04


Priority: Major

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.8

Sprint: Sprint 50

Story Points: