Skip to content

Commit

Permalink
Added an extra condition on the join for the recreate issue.
Browse files Browse the repository at this point in the history
This is a less experimental rewrite of the query that fixes the exact problem.
The speedups from this query fix are also substantial, going from 2.5 hours to 11 minutes.

This is likely a fix to these issues:
#1699, #2048, #2140, #2178

This could help with issues:
#1391, #2050
  • Loading branch information
kenkendk committed Jan 19, 2017
1 parent a415a30 commit 305d8bc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Duplicati/Library/Main/Database/LocalRecreateDatabase.cs
Expand Up @@ -237,7 +237,7 @@ public void FindMissingBlocklistHashes(long hashsize, long blocksize, System.Dat
var selectBlocklistBlocksetEntries = string.Format(
@"SELECT ""E"".""BlocksetID"" AS ""BlocksetID"", ""D"".""FullIndex"" AS ""Index"", ""F"".""ID"" AS ""BlockID"" FROM ( " +
SELECT_BLOCKLIST_ENTRIES +
@") D, ""BlocklistHash"" E, ""Block"" F, ""Block"" G WHERE ""D"".""BlocklistHash"" = ""E"".""Hash"" AND ""D"".""BlocklistSize"" = ""G"".""Size"" AND ""D"".""BlocklistHash"" = ""G"".""Hash"" AND ""D"".""Blockhash"" = ""F"".""Hash"" AND ""D"".""BlockSize"" = ""F"".""Size"" ",
@") D, ""BlocklistHash"" E, ""Block"" F, ""Block"" G WHERE ""D"".""BlocksetID"" = ""E"".""BlocksetID"" AND ""D"".""BlocklistHash"" = ""E"".""Hash"" AND ""D"".""BlocklistSize"" = ""G"".""Size"" AND ""D"".""BlocklistHash"" = ""G"".""Hash"" AND ""D"".""Blockhash"" = ""F"".""Hash"" AND ""D"".""BlockSize"" = ""F"".""Size"" ",
blocksize,
hashsize,
m_tempblocklist,
Expand Down Expand Up @@ -269,15 +269,15 @@ public void FindMissingBlocklistHashes(long hashsize, long blocksize, System.Dat
}
catch (Exception ex)
{
m_result.AddError("Blockset insert failed, this is likely issue #2140, #1699, #2048 or #2178, comitting temporary tables as permanent", ex);
m_result.AddError("Blockset insert failed, comitting temporary tables for trace purposes", ex);

using (var fixcmd = m_connection.CreateCommand())
{
fixcmd.ExecuteNonQuery(string.Format(@"CREATE TABLE ""{0}-Failure"" AS SELECT * FROM ""{0}"" ", m_tempblocklist));
fixcmd.ExecuteNonQuery(string.Format(@"CREATE TABLE ""{0}-Failure"" AS SELECT * FROM ""{0}"" ", m_tempsmalllist));
}

throw new Exception("The recreate failed due to a known error, please create a bug-report from this database and send it to the developers for further analysis");
throw new Exception("The recreate failed, please create a bug-report from this database and send it to the developers for further analysis");
}
}
}
Expand Down

0 comments on commit 305d8bc

Please sign in to comment.