Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Open Database #488

Closed
titaniumbones opened this issue Jul 25, 2017 · 9 comments
Closed

Unable to Open Database #488

titaniumbones opened this issue Jul 25, 2017 · 9 comments

Comments

@titaniumbones
Copy link

General informations

  • system/distribution (with version): Archlinux, current
  • offlineimap version (offlineimap -V): offlineimap v7.1.1, imaplib2 v2.57 (bundled), Python v2.7.13, OpenSSL 1.1.0f 25 May 2017
  • Python version: Python 3.6.1, Python 2.7.13
  • server name or domain: mailbox126.utcc.utoronto.ca
  • CLI options: none

Configuration file offlineimaprc

# Sample minimal config file.  Copy this to ~/.offlineimaprc and edit to
# get started fast.

[general]
accounts = UofT

[Account UofT]
localrepository = LocalUofT
remoterepository = RemoteUofT
# status_backend = sqlite

[Repository LocalUofT]
type = Maildir
localfolders = ~/UofTMail

[Repository RemoteUofT]
type = IMAP
remotehost = mailbox126.utcc.utoronto.ca
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
folderfilter = lambda folder: folder in ['Inbox',  'inbox', 'Sent']

Logs, error

$offlineimap
OfflineIMAP 7.1.1
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v2.57 (bundled), Python v2.7.13, OpenSSL 1.1.0f  25 May 2017
Account sync UofT:
 *** Processing account UofT
 Establishing connection to mailbox126.utcc.utoronto.ca:993 (RemoteUofT)
Folder inbox [acc: UofT]:
 Syncing inbox: IMAP -> Maildir
Folder Sent [acc: UofT]:
 Syncing Sent: IMAP -> Maildir
Folder inbox [acc: UofT]:
 ERROR: while syncing inbox [account UofT]
  unable to open database file
 ERROR: ERROR in syncfolder for UofT folder inbox: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 618, in syncfolder
    remotefolder.syncmessagesto(localfolder, statusfolder)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 1116, in syncmessagesto
    action(dstfolder, statusfolder)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 928, in __syncmessagesto_copy
    statusfolder.savemessage(uid, None, flags, rtime)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/LocalStatusSQLite.py", line 356, in savemessage
    (uid,flags,mtime,labels))
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/LocalStatusSQLite.py", line 183, in __sql_write
    self.connection.execute(sql, args)
OperationalError: unable to open database file

  unable to open database file

Steps to reproduce the error

  • runb "offlineimap"
    Error occurs

THis is new develope spontaneousy this afternoon some time after a bsttery-related laptop crash. I'm imagining maybe an sql file is corrupted? If so, what should I do to fix it?

thank you!
Matt

@nicolas33
Copy link
Member

Move to the metadata directory (~/.offlineimap by default) and try to open the database manually:

$ cd Account-UofT/LocalStatus-sqlite
$ sqlite3 inbox
sqlite> select * from status;
sqlite> .quit

nicolas33 added a commit to nicolas33/offlineimap that referenced this issue Jul 25, 2017
Github-ref: OfflineIMAP#488
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
@nicolas33
Copy link
Member

I've written a patch to get the faulting UID on errors for insert. You might like to try the above version to know which UID fails.

@titaniumbones
Copy link
Author

Thank you @nicolas33!

Running the above sqlite command gives a very long list of UID's, about 2400:
sqlerror-offlineimap.txt

Hmm, what should I do to try to fix it? Should I just start from scratch with a new sql file?

I don't quite see how to build offlineimap from source (sorry to be slow) so I haven't tried the new branch you suggested.

Really appreciate your help here very much!
matt

@nicolas33
Copy link
Member

Yes, please try the patched version.

It's possible to install offlineimap as a user: remove the currently installed offlineimap and download the zip from here. Then, run ./offlineimap.py [options].

Since you can list the lines, it looks like the database file is not corrupted. I'm still trying to figure out what's going on.

Did you try to reboot the system?

@nicolas33
Copy link
Member

I wonder this is all about write permissions. What are the unix rights on this file?

@titaniumbones
Copy link
Author

you were right! The folder looked like this:

➜ LocalStatus-sqlite$ ls -l                                     
total 144
-rw-r--r-- 1 matt matt 81920 Jul 24 12:40 inbox
?--------- 1 root root     0 Dec 31  1969 inbox-journal
-rw-r--r-- 1 matt matt 65536 Jul 24 12:39 Sent

I deleted inbox-journal and then offlineimap was able to run again. Not sure what inbox-journal is -- and in fact it has reappeared in a strange way:

➜  LocalStatus-sqlite ls -ltr
ls: cannot access 'inbox-journal': No such file or directory
total 144
-????????? ? ?    ?        ?            ? inbox-journal
-rw-r--r-- 1 matt matt 65536 Jul 24 12:39 Sent
-rw-r--r-- 1 matt matt 81920 Jul 26 08:02 inbox

but running sudo rm inbox-journal has nonetheless solved my problem for now. Thank you!
Matt

1 similar comment
@titaniumbones
Copy link
Author

you were right! The folder looked like this:

➜ LocalStatus-sqlite$ ls -l                                     
total 144
-rw-r--r-- 1 matt matt 81920 Jul 24 12:40 inbox
?--------- 1 root root     0 Dec 31  1969 inbox-journal
-rw-r--r-- 1 matt matt 65536 Jul 24 12:39 Sent

I deleted inbox-journal and then offlineimap was able to run again. Not sure what inbox-journal is -- and in fact it has reappeared in a strange way:

➜  LocalStatus-sqlite ls -ltr
ls: cannot access 'inbox-journal': No such file or directory
total 144
-????????? ? ?    ?        ?            ? inbox-journal
-rw-r--r-- 1 matt matt 65536 Jul 24 12:39 Sent
-rw-r--r-- 1 matt matt 81920 Jul 26 08:02 inbox

but running sudo rm inbox-journal has nonetheless solved my problem for now. Thank you!
Matt

@nicolas33
Copy link
Member

Thanks for your feedback!

@titaniumbones
Copy link
Author

titaniumbones commented Jul 26, 2017 via email

michaelcoyote pushed a commit to michaelcoyote/offlineimap that referenced this issue Jan 15, 2018
Github-ref: OfflineIMAP#488
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants