105

I was trying to do a svn cleanup because I can't commit the changes in my working copy, and I got the following error:

sqllite: database disk image is malformed

Cleanup failed to process the following paths

What can I do right now?

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148

18 Answers18

115

First, open command/terminal at repository root (folder which has .svn as child folder):

cd /path/to/repository

Download sqlite3 and put executable sqlite3 at root of folder.

You do an integrity check on the sqlite database that keeps track of the repository (/path/to/repository/.svn/wc.db):

sqlite3 .svn/wc.db "pragma integrity_check"

That should report some errors.

Then you might be able to clean them up by doing:

sqlite3 .svn/wc.db "reindex nodes"
sqlite3 .svn/wc.db "reindex pristine"

If there are still errors after that, you still got the option to check out a fresh copy of the repository to a temporary folder and copy the .svn folder from the fresh copy to the old one. Then the old copy should work again and you can delete the temporary folder.

namgold
  • 1,009
  • 1
  • 11
  • 32
HenningJ
  • 3,099
  • 1
  • 20
  • 17
  • 1
    How the heck do you get to sqlite3 on the Windows8 command line? (I guess, using PowerShell ??) thanks! – Fattie Jun 29 '15 at 09:38
  • 2
    I was using the _sqlite command-line shell_ which you can download from the [sqlite website](https://www.sqlite.org/download.html). But I guess you can also use any other sqlite client. – HenningJ Jun 30 '15 at 10:43
  • This solution works if the issue on the client-side. You can get the same error if the rep-cache.db is corrupt on the server-side. See the post from Muhammad in this thread for a resolution: http://stackoverflow.com/a/24907861/1993525 – powderflask Feb 01 '16 at 22:56
  • It looks to me that replacing .svn folder has a side effect of converting missing updates in changes. That is if your copy was not updated svn will think you are at the latest rev and reverted (manually) the changes so that if you commit your version you may have troubles. To avoid the inconvenience it should suffice to checkout the same rev you were at. – user110954 Aug 03 '16 at 22:40
  • 7
    Weird, I get `Error: unable to identify the object to be reindexed` – Pacerier Dec 17 '16 at 22:27
  • Damn, I ran `reindex` and even tried `vacuum`. `pragma integrity_check` gives `ok` but I'm still getting `database disk image is malformed` – Pacerier Dec 17 '16 at 23:19
  • 1
    I get: *Error: unable to identify the object to be reindexed* – JavaRunner Oct 11 '17 at 18:20
  • 1
    Getting `'sqlite3' is not recognized as an internal or external command` when I run the first command – aagjalpankaj Jun 19 '18 at 04:39
  • 4
    The Link http://www.polak.ro/svn-e200030-sqlite-database-disk-image-is-malformed.html seems to be permanently down. – MadMike Feb 11 '19 at 08:23
  • Replacing the old .svn with new .svn (fresh checkout) worked for me. – Bhargav Aug 20 '20 at 05:38
31

Integrity check

sqlite3 .svn/wc.db "pragma integrity_check"

Clean up

sqlite3 .svn/wc.db "reindex nodes"
sqlite3 .svn/wc.db "reindex pristine"

Alternatively

You may be able to dump the contents of the database that can be read to a backup file, then slurp it back into an new database file:

sqlite3 .svn/wc.db

sqlite> .mode insert
sqlite> .output dump_all.sql
sqlite> .dump
sqlite> .exit

mv .svn/wc.db .svn/wc-corrupt.db
sqlite3 .svn/wc.db

sqlite> .read dump_all.sql
sqlite> .exit
matt burns
  • 24,742
  • 13
  • 105
  • 107
  • 2
    I didn't get everything dumped, but it was enough. Scrolled through the sql file and changed the final `ROLLBACK;`to `COMMIT;` before doung the `.read dump_all.sql`. – Jan Katins Apr 05 '18 at 21:40
  • 2
    This approach now seems to fail with the error `svn: E235000: In file 'D:\Development\SVN\Releases\TortoiseSVN-1.9.7\ext\subversion\subversion\libsvn_wc\wc_db_wcroot.c' line 311: assertion failed (format >= 1)`, however there is a workaround here: http://hanscarpenter.blogspot.com.au/2016/05/subversion-fails-du-to-power-outage.html – mpeac Apr 15 '18 at 22:29
  • 3
    The proper fix for the assertion error is: 1. run `sqlite3 .svn/wc.db 'PRAGMA user_version;'` against the original db to get the correct number. 2. run `sqlite3 .svn/wc.db 'PRAGMA user_version = XXX;'` against the restored version with the correct number. – Chronial Jan 13 '20 at 09:29
  • From what I know dumping everything out into a practically new database file is what the "VACUUM" command does. – blerontin Nov 21 '22 at 14:31
20

The SVN cleanup didn't work. The SVN folder on my local system got corrupted. So I just deleted the folder, recreated a new one, and updated from SVN. That solved the problem!

Sildoreth
  • 1,883
  • 1
  • 25
  • 38
EmKay
  • 209
  • 2
  • 2
16

After a power blackout, I ran into the database disk image is malformed error and the suggested reindex nodes command did not fix all issues due to violated constraints. Also the procedure described in http://mail-archives.apache.org/mod_mbox/subversion-users/201111.mbox/%3C874nybhpxi.fsf@stat.home.lan%3E did not resolve the problem.

Solution in my case:

  • Checkout the svn repository again into a temporary folder
  • Copy, i.e. replace, the file ".svn/wc.db" from the new checkout to the corrupt one

This may be useful, if your original svn checkout contains many modified or unversioned files and you don't want to switch to a fresh svn checkout.

Thomas853
  • 517
  • 1
  • 7
  • 12
13

I copied over .svn folder from my peer worker's directory and that fixed the issue.

user3884070
  • 131
  • 1
  • 2
4

Do not waste your time on checking integrity or deleting data from work queue table because these are temporary solutions and it will hit you back after a while.

Just do another checkout and replace the existing .svn folder with the new one. Do an update and then it should go smooth.

Jawad Khan
  • 156
  • 1
  • 8
3
  1. check out this svn at another place
  2. show hidden .svn file
  3. replace wc file

this works for me!

Kaikai
  • 31
  • 3
2

Maybe, could be a solution:

  1. right mouse click over project
  2. team -> disconnect
  3. Select: Also delete ...

Now, re-connect again:

  1. right mouse click over project
  2. team -> Share project
  3. select your repositorie: mine SVN ( other case: git, etc)
  4. select your repositorie folder

Note:

On my case, I did a backup of my files. ( safe ur back :P )

Edit:

I am talking about SVN plugin on Eclipse :)

Baby Groot
  • 4,637
  • 39
  • 52
  • 71
mfruizs
  • 770
  • 14
  • 20
1

Have you seen this post on the subversion site? You could also potentially try validating and "fixing" the database directly as described here. (Note that I'm no expert, I just did a quick google search. May not be related to your issues at all).

Personally, I'd try checking out the repo again and reapplying your changes. Not sure if this is possible though in your case?

Mightymuke
  • 5,094
  • 2
  • 31
  • 42
  • I my case this not solved the problem, also caused a lot more errors in Tortoise SVN, just warn. – komorra Dec 11 '13 at 16:36
1

Throughout my researches, I've found 2 viable solutions.

  1. If you're using any type of connections, ssh, samba, mounting, disconnect/unmount and reconnect/remount. Try again, this often resolved the problem for me. After that you can do svn cleanup or just keep on working normally (depending on when the problem appeared). Rebooting my computer also fixed the problem once... yes it's dumb I know!

  2. Some times all there is to do is to rm -rf your files (or if you're not familiar with the term, just delete your svn folder), and recheckout your svn repository once again. Please note that this does not always solve the problem and you might also have changes you don't want to lose. Which is why I use it as the second option.

Hope this helps you guys!

Psykehoe
  • 99
  • 1
  • 2
1

I solved my problem of visual svn server rep-cache.db corruption.

Their are two solutions.

Stop the Visual SVN Server service.

Download sqllite3.exe shell from sqllite website and copy that into repo's db folder.

Type the following commands at command prompt in the repo's db folder.

-- First Solution --

sqlite3 rep-cache.db

.clone rep-cache-new.db

press ctrl+c to exit sqllite.

ren rep-cache.db rep-cache-old.db

ren re-cache-new.db rep-cache.db

-- 2nd Solution --

Delete The rep-cache.db

del rep-cache.db

it will be automatically created.

Muhammad Yousaf Sulahria
  • 1,708
  • 1
  • 14
  • 16
  • Thank you Muhammad -- just the clue I needed! One needs to determine if the issue is with the sqlite db(s) in your working copy or the one on the server. Try your commit on the command line -- if the file is transferred successfully and the error happens while "Committing Transaction", then the problem is probably on the server side. Muhammad's resolution here works like a charm. This old listserve archive has more details: http://svn.haxx.se/users/archive-2010-12/0257.shtml – powderflask Feb 01 '16 at 22:54
1

If you install the Tortoise SVN, Please go to task manager and stop it. Then try to delete the folder. it will work

1

I fixed this for an instance of it happening to me by deleting the hidden .svn folder and then performing a checkout on the folder to the same URL.

This did not overwrite any of my modified files & just versioned all of the existing files instead of grabbing fresh copies from the server.

0

Marked answer might be the correct one, according to subversion cleanup. But the error is definitely a generic one, which led me here, this question page.

Our project has the dependency System.Data.SQLite and the error message was the same:

database disk image is malformed

In my case, I've executed following check script and the followings via SQLiteStudio 3.1.1.

pragma integrity_check

(I don't have any idea if these statistics would help, but I'm going to share them anyway...)

The DataBase file is being used on everyday usage for 1.5 year, via the connection journal mode on Memory, and was about 750 MB large. There were approximately 140K records per table and 6 tables was this large.

After the execution of Integrity Check script, 11 rows was returned after 30 minutes of execution time.

wrong # of entries in index sqlite_autoindex_MyTableName_1
wrong # of entries in index MyOtherTableAndOrIndexName_1
wrong # of entries in index sqlite_autoindex_MyOtherTableAndOrIndexName_2
etc...

All the results were about the indexes. Following-up the re-building each indexes, my problem was resolved.

reindex sqlite_autoindex_MyTableName_1;
reindex MyOtherTableAndOrIndexName_1;
reindex sqlite_autoindex_MyOtherTableAndOrIndexName_2;

After re-indexing, the integrity check resulted "ok".

I've got this error last year, and I was restored the DB from the backup, and then re-committed all the changes, which was a real nightmare...

Dharman
  • 30,962
  • 25
  • 85
  • 135
LysanderM
  • 115
  • 1
  • 1
  • 6
0

Check your local machine space where you are trying to checkout data. In my case my c drive don't have space for complete checkout so that error was coming :)

Jyoti mishra
  • 597
  • 4
  • 16
-2

no need to worry for a directory lock guys.

Just you need to do is, If sqllite3 is not installed, type below command,

>sudo apt-get install sqlite3

Open SVN database by typing this command,

>sqlite3 .svn/wc.db 

Now just you need to do is to remove locks entries from SVN DB.

sqlite>  select * from wc_lock;
1|-1           
sqlite>  delete from wc_lock;
sqlite>  select * from wc_lock;
sqlite>  .q

Process Completed. You can work on your SVN repository, do commit, update, add, remove operations without issue.

:-)

-2

During app development I found that the messages come from the frequent and massive INSERT and UPDATE operations. Make sure to INSERT and UPDATE multiple rows or data in one single operation.

var updateStatementString : String! = ""

for item in cardids {

let newstring = "UPDATE "+TABLE_NAME+" SET pendingImages = '\(pendingImage)\' WHERE cardId = '\(item)\';"
            updateStatementString.append(newstring)

        }


        print(updateStatementString)
        let results = dbManager.sharedInstance.update(updateStatementString: updateStatementString)

        return Int64(results)
-4

cd to folder containing .svn

rm -rf .svn
svn co http://mon.svn/mondepot/ . --force
mmbenyoub
  • 54
  • 1
  • 4