Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 2700 - "Failed to open the project database"
"Failed to open the project database"
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Application Core
3.0.0
All All
: P2 MoonPhase
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-03-19 18:16 UTC by James Crook
Modified: 2021-05-19 10:06 UTC (History)
6 users (show)

See Also:
Steps To Reproduce:
Moonphase. Awaiting more detail.
Release Note:
First Git SHA:
Group: ---
Workaround:
Try: 1) On Tools menu, click Reset Configuration if that still fails 2) Exit Audacity and relaunch if that fails 3) Exit Audacity, delete content of the audacity settings folder and relaunch
Closed: 2021-05-19 00:00:00


Attachments
Collapsed error ddialog (546.29 KB, image/png)
2021-04-01 06:15 UTC, Leland Lucius
Details
Expanded error dialog (517.37 KB, image/png)
2021-04-01 06:15 UTC, Leland Lucius
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Crook 2021-03-19 18:16:16 UTC
Reported here:

https://forum.audacityteam.org/viewtopic.php?f=46&t=116645

See that report for updates and breaking news...

Speculation that something in AppData\Local\Audacity\SessionData is locking Audacity out.
Comment 1 James Crook 2021-03-21 11:12:58 UTC
Google Summer of Code student Rupanshi saw this problem too.
For him it was a configuration problem, though apparently not a directories preferences problem.

He was able to fix the problem by Tools -> Reset Configuration.
Unfortunately that means we don't know what was wrong in the configuration.  However, we can more confidently suggest this workaround to other people.

Looking at the code for OnResetConfiguration it seems most unlikely that any of the settings that are reset other than directory preferences could cause this problem, so I am suspecting it is actually directory preferences.

A more informative error message about the problem in future Audacity is a must.
Comment 2 Peter Sampson 2021-03-21 11:22:46 UTC
(In reply to James Crook from comment #1)
>He was able to fix the problem by Tools -> Reset Configuration.

On the odd occasions when this happened to me in the middle days of 3.0.0 alpha testing my workaround was to purge the contents of the audacity settings folder.

I always assumes it was because I was tripping between various Audacity versions and that that had somehow corrupted my config.
Comment 3 Peter Sampson 2021-03-22 11:47:05 UTC
I just got this with 3.0.1
1) Exited from existing unsaved project
2) relaunched
3) Observe: Recovery offered for New project....
4) reject and delete
5) Observe empty Audacity window
6) drag audio file in
7) Observe: error message "Failed to open the project's database"

8) Exit Audacity
9) Purge contents of audacity settings folder
10) relaunch 3.0.1
11) drag audio file in 
12) Observe: it imports fine and dandy
Comment 4 James Crook 2021-03-24 08:58:13 UTC
We've established it isn't a bad config file, so the workaround 'Reset Configuration' is probably bogus, and the workaround is probably 'try again'.


I'm suspecting anti-virus and this code in SQLite3:


      /* Try 3 times to get the pending lock.  This is needed to work
      ** around problems caused by indexing and/or anti-virus software on
      ** Windows systems.
      ** If you are using this code as a model for alternative VFSes, do not
      ** copy this retry logic.  It is a hack intended for Windows only.
      */
      OSTRACE(("LOCK-PENDING-FAIL file=%p, count=%d, rc=%s\n",
               pFile->h, cnt, sqlite3ErrName(res)));
      if( cnt ) sqlite3_win32_sleep(1);
    }
    gotPendingLock = res;
    if( !res ){
      lastErrno = osGetLastError();
    }


This would confirm this as a windows only problem.  See bug 1266 for some history with anti-virus.
Comment 5 Leland Lucius 2021-03-24 10:18:17 UTC
(In reply to James Crook from comment #4)
> We've established it isn't a bad config file, so the workaround 'Reset
> Configuration' is probably bogus, and the workaround is probably 'try again'.
> 
> 
> I'm suspecting anti-virus and this code in SQLite3:
> 
> 
>       /* Try 3 times to get the pending lock.  This is needed to work
>       ** around problems caused by indexing and/or anti-virus software on
>       ** Windows systems.
>       ** If you are using this code as a model for alternative VFSes, do not
>       ** copy this retry logic.  It is a hack intended for Windows only.
>       */
>       OSTRACE(("LOCK-PENDING-FAIL file=%p, count=%d, rc=%s\n",
>                pFile->h, cnt, sqlite3ErrName(res)));
>       if( cnt ) sqlite3_win32_sleep(1);
>     }
>     gotPendingLock = res;
>     if( !res ){
>       lastErrno = osGetLastError();
>     }
> 
> 
> This would confirm this as a windows only problem.  See bug 1266 for some
> history with anti-virus.

Wow, great find!!!  Lets see if we can detect this situation and manage it with a better message.  I believe at least some of the folks were running Bitdefender right?  If so, I'll try installing it and see if I can reproduce.
Comment 6 Peter Sampson 2021-03-24 10:23:29 UTC
(In reply to Leland Lucius from comment #5)
>I believe at least some of the folks were running Bitdefender right?

Some were - but I don't (I run McAfee) and I still get this moonphasely
Comment 7 Leland Lucius 2021-03-24 11:27:29 UTC
Well, I installed Bitdefender and, so far, Audacity is opening files just fine.  I'll look at what James found in the SQLite source to see if I can deduce needed actions to tickle the issue.
Comment 8 James Crook 2021-03-24 11:37:13 UTC
Re Comment 1 - Rupanshi had AVG anti-virus.  He saw the issue once.

Relevant to the Bug 1266 issue, which involved a file rename, were: 

https://reviews.llvm.org/D13647#eeab044e 
https://github.com/audacity/audacity/pull/94/commits/d6297ed01dab3bd466697227c8e69a2c5d66b84d
and
https://github.com/audacity/wxWidgets/commit/5d609597d82c173e39402b57c7e444a43d49220b

Hope I've not started a wild goose chase with the anti-virus thought.  Llvm's issue involved hitting the hard drive hard (figuratively).
Comment 9 Leland Lucius 2021-03-24 12:02:33 UTC
Well, I installed Bitdefender and haven't yet seen an error.  I tried Peter's steps from comment #3 and various other combinations, but no joy.

So I guess we'll just have to try and put in a "watcher" for errors returned from the SQLite code that James found.

I'm putting my system back to normal now...
Comment 10 Peter Sampson 2021-03-24 12:12:58 UTC
(In reply to Leland Lucius from comment #9)
>I tried Peter's steps from comment #3 and various other combinations, but no joy.
But then those steps don't repeat for me either - hence the moonphase   :-//
Comment 11 Steve Daulton 2021-03-24 17:29:44 UTC
I "think" I've just seen this error.
Unfortunately it caught me by surprise and I failed to carefully note the exact error message.

The error appeared immediately after applying the Nyquist Prompt with code expected to work.
Applying the exact same code again worked as expected.

Certainly looks "moonphase" or even "Heisenbug" here.
Comment 12 Peter Sampson 2021-03-24 17:34:17 UTC
I have created a draft FAQ Error page for this error - the page it currently targets with its "?" help button has no entry for this and thus no help.

https://alphamanual.audacityteam.org/man/FAQ:Failed_to_open_the_project%27s_database#Failed_to_open_the_project.27s_database

It's properly linked from the FAQs so that it will get pulled as part of the release Manual later.
Comment 13 Peter Sampson 2021-03-24 17:41:41 UTC
(In reply to Peter Sampson from comment #12)
Link should be withot the # anchor
https://alphamanual.audacityteam.org/man/FAQ:Failed_to_open_the_project's_database
Comment 14 Peter Sampson 2021-03-27 10:09:08 UTC
Jack L. via lists.sourceforge.net 
	
8:44 AM (1 hour ago)
	
to Audacity-Devel
I was able to reproduce this "Unable to open project database" on
FreeBSD in addition to windows with 3.0.0 but it's very random. I
copied an old 2.4.2 project from another computer and then opened it
with 3.0.0. It asked me to recover "new project" and then when I
clicked no, it said unable to open database and had to close audacity.
I reopened the same old 2.4.2 project file again and it was fine.
Something is definitely odd with opening files outside of audacity and
not within audacity.
Comment 15 Leland Lucius 2021-03-27 19:30:08 UTC
If committed some info gathering changes in:

https://github.com/audacity/audacity/commit/125114c

I do NOT know if it will be enough to direct us to the cause. But, if we want to find this out, then we find someone that can consistently recreate the error and give them a copy of the artifact from the github action to test with.

In any case, we will want the Audacity log file when the problem occurs.
Comment 16 Leland Lucius 2021-03-27 19:41:36 UTC
I should point out that any messages we might see in the log file are NOT meant for the user to understand. If they are cryptic, then so be it. The log file was intended to collect info for the developers to diagnose unusual situations. 

Over time is has become a "user" thing and messages to the log are translated.  So now the developers will have to struggle to understand what the messages mean if we do get one back from a user.

If you wish to see one of the nice cryptic messages my change will cause to be written to the log file, then just create a project and crash Audacity.  After recover, look at the log file.  You should see a nice cryptic message like this:

14:40:43: sqlite3 message: (283) recovered 86 frames from WAL file C:\Users\Yam\AppData\Local\Audacity\SessionData\New Project 2021-03-27 14-11-51 N-1.aup3unsaved-wal
Comment 17 James Crook 2021-03-29 10:18:00 UTC
Re Comment 16:

IMNSHO we need to report more of the cryptic information in the (hopefully rare) error dialogs.  Good reporters of bugs to us will send us an actual screenshot of the dialog, or at least tell us the dialog said 'busy', 'locked' or 'readonly' on first reporting it.  Logs nearly always require a back and forth and a repeatable bug, so it is harder for us to actually get the log.


The log shows for example this:

sqlite3 message: (14) cannot open file at line 39567 of [7ebdfa80be]
sqlite3 message: (14) os_unix.c:39567: (0) open(/Volumes/Untitled/asdf.aup3-wal) -
sqlite3 message: (1544) attempt to write a readonly database in "PRAGMA main.synchronous = NORMAL;PRAGMA main.journal_mode = WAL;PRAGMA main.wal_autocheckpoint = 0;"
sqlite3 message: (14) cannot open file at line 39567 of [7ebdfa80be]
sqlite3 message: (14) os_unix.c:39567: (0) open(/Volumes/Untitled/asdf.aup3-wal) -
sqlite3 message: (1544) attempt to write a readonly database in "SELECT Count(*) FROM sqlite_master WHERE type='table';"
SQLite error: Failed to execute a project file command:

Of course that is too much for an error dialog.
I think we should from the get go show something like:

"Failed to execute a project file command"
"Readonly. ProjectFileIO.cpp(597)" 

First line translated.  Second line not.  I think we should do this ubiquitously, since in theory any SQL command can fail.  Any error dialog with the cryptic info in it should be linked to the same cryptic errors section of Peter's page.  That page should say that we would like the log, but we still have a good chance of knowing what's gone wrong if we don't get the log.
Comment 18 James Crook 2021-03-29 10:20:23 UTC
Just to be clear, I am saying the detailed log is great.  And we need a small amount of the most key information, the sql error code, in the error dialog too.
Comment 19 Leland Lucius 2021-04-01 06:15:30 UTC
Created attachment 1129 [details]
Collapsed error ddialog
Comment 20 Leland Lucius 2021-04-01 06:15:58 UTC
Created attachment 1130 [details]
Expanded error dialog
Comment 21 Leland Lucius 2021-04-01 06:18:03 UTC
Changes to the error dialog to (hopefully) provide a means for the users to include more info in their screenshots:

https://github.com/audacity/audacity/commit/392a060

See the 2 attachments for examples.  The "collapsed" fella is the default and when (if) they click "Show Log" then the "expanded" fella will be shown.
Comment 22 Peter Sampson 2021-04-03 11:57:53 UTC
New P2 moonphase Bug #2732 
>Faux recovery offered on launch (very moonphase) 

is thought to be a close cousin of this as they can appear in conjunction.
Comment 23 James Crook 2021-04-09 12:08:26 UTC
DEVEL - FIX MADE

1: Force order of creating connections, ensuring no overlap:
https://github.com/audacity/audacity/commit/40d3a3629637e588b04f5c207f5d9a30fcac8709

2: Get SQLite to retry locked connections.
https://github.com/audacity/audacity/commit/cceaf0d16247548d999146809c73829809e7b6d7

2700 is reproducible by Jack L and always from a 'locked' connection.  
1 aims to address the specific issue at start up, and 2 is a general solution.

Thanks to Paul for these.
Comment 24 Peter Sampson 2021-05-19 10:06:37 UTC
Closing this as we have had no further reports of this in 3.0.2 (nor have I seen it in any 3.0.3 alpha).

The failed/corrupted AUP3 databases we see in 3.x are not this issue.