Bug #103560 "Index was out of range" when closing tab during right-most tab's running query
Submitted: 3 May 2021 17:02 Modified: 3 May 2021 18:42
Reporter: Jason Brunette Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.24 OS:Windows
Assigned to: CPU Architecture:Any

[3 May 2021 17:02] Jason Brunette
Description:
An "Unexpected Error" dialog box appears and Workbench is rendered unusable if the right-most Query tab's query completes after a tab to the left has been closed.

How to repeat:
Steps to reproduce
1. Open 2 query tabs.
2. In the second tab, execute query "SELECT SLEEP(10)"
3. Close the first tab.
4. When the query returns, a "MySQL Workbench Unexpected Error" dialog box appears with the following information:

"Index was out of range..."
"Parameter name: index"

Workbench is now in an unstable state and will refuse to close, requiring "End Task" via the Windows Task Manager.

A related issue exists regarding a tab's spinner remaining forever after its query completes:
1. Open 3 query tabs.
2. In the second tab, execute query "SELECT SLEEP(10)"
3. Close the first tab.
4. When the query returns, the tab that ran the query will continue to show the spinner animation instead of being switched to the X. The spinner still acts like the X and lets you close the tab, and no Workbench instability is observed.

Suggested fix:
Cause
- Code is most likely storing the index position of the executing tab and attempts to reference the tab in the tab bar by that position when the query completes. If there is no longer a tab at that index when the query completes, however, an error occurs when Workbench tries to change the tab's spinner back to X.

Fix
- Use another means of targeting tab that just finished the query, or loop through all tabs and set all icons to X...
[3 May 2021 18:42] MySQL Verification Team
Thank you for the bug report.
[22 Sep 2022 15:05] Brian Jones
Similar situation. Ran query on final tab on workbench, then closed next tab to the left, which triggered the error.
[16 May 2023 23:26] Ed Critz
I had close to the same problem and can replicate what happened.  I have multiple tabs open.  I execute the next to last tab, and while it is running I save and then close the last tab. Workbench did not immediately fail and present an error.  2 - 3 seconds after clicking to execute the query, I switched to another full-screen program.  When I went back to Workbench to check the query results, I encountered the error window "MySQL Workbench has encountered a problem  Index was out of range. Must be non-negative and less than the size of the collection.  Parameter name: index".  

I think I understand what might be causing this problem and others reported about managing tabs, primarily closing one or more, while there is a tab waiting for the results of an active query.  I would very much like to assist in resolving this but it would be the first time in over 10 years that I have worked on an open-source project.  It would probably be like doing it for the first time. Point me to a link showing what I would need to do to get involved.  I think the open-source would be a good place to wind down a multi-century career.