View Issue Details

IDProjectCategoryView StatusLast Update
0007952MMW v4Framework: Scripts/Extensionspublic2011-11-12 00:18
Reporterzvezdan Assigned To 
PrioritynoneSeverityminorReproducibilityalways
Status feedbackResolutionreopened 
Product Version4.0 
Fixed in Version4.0 
Summary0007952: AV error with QuerySongs and SDBPlaylist.AddTrack [MM4]
DescriptionI am getting the Access Violation error: "Starting a transaction while some query is open" on the line with SDBPlaylist.AddTrack. The same code works fine in MM3. I have another query with QuerySongs in my script, but it seems that this error occurs with any query. I am using now a solution with SDBPlaylist.AddTracks instead, but it is just a workaround.
Additional InformationOption Explicit

Sub OnStartup()
    Dim oMenuItem

    Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    oMenuItem.Caption = "Test SDBPlaylist.AddTrack"
    oMenuItem.UseScript = Script.ScriptPath
    oMenuItem.OnClickFunc = "Test"
End Sub

Sub Test(oItem)
    Dim oPlaylist
    Dim oSongIter

    Set oPlaylist = GetPlaylist("TestAddTrack")
    If oPlaylist Is Nothing Then
        Set oPlaylist = SDB.PlaylistByTitle("").CreateChildPlaylist("TestAddTrack")
    End If

    oPlaylist.Clear
    Set oSongIter = SDB.Database.QuerySongs("ID IN (SELECT ID FROM Songs LIMIT 100)")
    Do While Not oSongIter.EOF
        oPlaylist.AddTrack oSongIter.Item
        oSongIter.Next
    Loop
End Sub

Function GetPlaylist(sPlayListName)
    Dim oCurPlaylist
    Dim oSubPlaylists
    Dim j

    Set oCurPlaylist = SDB.PlaylistByTitle("")
    Set oSubPlaylists = oCurPlaylist.ChildPlaylists
    If oSubPlaylists.Count Then
        j = 0
        Do While j < oSubPlaylists.Count
            If oSubPlaylists.Item(j).Title = sPlayListName Then
                Set oCurPlaylist = oSubPlaylists.Item(j)
                Exit Do
            ElseIf j = oSubPlaylists.Count - 1 Then
                Set oCurPlaylist = Nothing
                Exit Do
            End If
            j = j + 1
        Loop
    Else
        Set oCurPlaylist = Nothing
    End if
    Set GetPlaylist = oCurPlaylist
End Function
TagsNo tags attached.
Fixed in build1392

Activities

jiri

2011-06-15 13:42

administrator   ~0026149

Fixed in build 1391.
 - The regression was caused by a performance improvement. It will no longer cause an error message, however for performance reasons I'd suggest to avoid DB updates while a query is opened. I.e. a preferred solution would be to get a list of tracks to a memory structure and only then perform required actions. Not a big deal for few tracks, but can make a difference for thousands of tracks.

zvezdan

2011-06-16 14:47

updater   ~0026183

I am still getting the mentioned AV error, but not always and I cannot reproduce it. However, I am now getting the another AV error "Thread creation error: Not enough storage is available to process this command." more often. I think it happens only if I have selected node with the playlist which is updating with AddTrack.

By the way, I understand the performance problem and as I said I already have modified script using SongList object and AddTracks method instead. However, maybe there exist scripts with similar code from other users that are not upgraded anymore and because of them you should keep compatibility.

jiri

2011-06-16 15:24

administrator   ~0026190

Fixed in build 1392.
 - Thanks, there was yet one more different issue.

zvezdan

2011-06-17 13:53

updater   ~0026209

Well, I got the same AV error "Starting a transaction..." with 1392, but only after approx. 30 attempts. So, maybe it could stay as resolved.

jiri

2011-06-19 15:19

administrator   ~0026225

Zvezdan, this shouldn't ever occur, in case you can reproduce while capturing a debug log, please e-mail it to me (with a rough indication of a line number where the problem occured). Thanks.

peke

2011-11-12 00:18

developer   ~0028843

If you have not received Zvezdan Mail I uploaded it to FTP for your revision.