Bug 754780 - If Tb 10 and Tb 11 is skipped, Gloda Scheme change is not correctly detected and gloda error is reported to Error Console by Tb 12 or newer, then Global Search doesn't work. fix. r+a=Standard8
authorAndrew Sutherland <asutherland@asutherland.org>
Fri, 25 May 2012 11:25:19 -0700
changeset 11355 166d519fc95e0d504a892409e5a8eb34e6e43747
parent 11354 7f4b2ca13eba52e89777007b8327d19279ae085c
child 11356 01303a6f3d9b407f5df7eb37af6c19f97daa3765
push id516
push userbugzilla@standard8.plus.com
push dateTue, 29 May 2012 08:06:22 +0000
treeherdercomm-beta@01303a6f3d9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs754780
Bug 754780 - If Tb 10 and Tb 11 is skipped, Gloda Scheme change is not correctly detected and gloda error is reported to Error Console by Tb 12 or newer, then Global Search doesn't work. fix. r+a=Standard8
mailnews/db/gloda/modules/datastore.js
--- a/mailnews/db/gloda/modules/datastore.js
+++ b/mailnews/db/gloda/modules/datastore.js
@@ -42,17 +42,17 @@
  */
 
 const EXPORTED_SYMBOLS = ["GlodaDatastore"];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
- 
+
 Cu.import("resource:///modules/IOUtils.js");
 Cu.import("resource://gre/modules/Services.jsm");
 
 Cu.import("resource:///modules/gloda/log4moz.js");
 
 Cu.import("resource:///modules/gloda/datamodel.js");
 Cu.import("resource:///modules/gloda/databind.js");
 Cu.import("resource:///modules/gloda/collection.js");
@@ -729,17 +729,17 @@ var GlodaDatastore = {
 
   /**
    * Schema version policy. IMPORTANT!  We expect the following potential things
    *  to happen in the life of gloda that can impact our schema and the ability
    *  to move between different versions of Thunderbird:
    *
    * - Fundamental changes to the schema so that two versions of Thunderbird
    *    cannot use the same global database.  To wit, Thunderbird N+1 needs to
-   *    blow away the database of Thunderbird N and reindex from scratch. 
+   *    blow away the database of Thunderbird N and reindex from scratch.
    *    Likewise, Thunderbird N will need to blow away Thunderbird N+1's
    *    database because it can't understand it.  And we can't simply use a
    *    different file because there would be fatal bookkeeping losses.
    *
    * - Bidirectional minor schema changes (rare).
    *    Thunderbird N+1 does something that does not affect Thunderbird N's use
    *    of the database, and a user switching back to Thunderbird N will not be
    *    negatively impacted.  It will also be fine when they go back to N+1 and
@@ -784,17 +784,17 @@ var GlodaDatastore = {
    *
    *
    * SO, YOU WANT TO CHANGE THE SCHEMA?
    *
    * Use the ranges below for Thunderbird 11 as a guide, bumping things as little
    *  as possible.  If we start to use up the "accepts and leaves intact" range
    *  without majorly changing things up, re-do the numbering acceptance range
    *  to give us additional runway.
-   * 
+   *
    * Also, if we keep needing non-nuking upgrades, consider adding an additional
    *  table to the database that can tell older versions of Thunderbird what to
    *  do when confronted with a newer database and where it can set flags to tell
    *  the newer Thunderbird what the older Thunderbird got up to.  For example,
    *  it would be much easier if we just tell Thunderbird N what to do when it's
    *  confronted with the database.
    *
    *
@@ -1113,17 +1113,18 @@ var GlodaDatastore = {
             let newVersion = dbSchemaVersion - DB_SCHEMA_DOWNGRADE_DELTA;
             this._log.debug("db from the future in downgrade range; setting " +
                             "version to " + newVersion + " down from " +
                             dbSchemaVersion);
             dbConnection.schemaVersion = this._actualSchemaVersion = newVersion;
           }
           // too far from the future, nuke it.
           else {
-            dbConnection = this._nukeMigration(dbConnection);
+            dbConnection = this._nukeMigration(dbService, dbFile,
+                                               dbConnection);
           }
         }
         // - database from the past!  migrate it, possibly.
         else if (dbSchemaVersion < this._schemaVersion) {
           this._log.debug("Need to migrate database.  (DB version: " +
             this._actualSchemaVersion + " desired version: " +
             this._schemaVersion);
           dbConnection = this._migrate(dbService, dbFile,
@@ -1441,20 +1442,21 @@ var GlodaDatastore = {
     aNounDef.dbAttribAdjuster = aNounDef._dataBinder.adjustAttributes;
 
     if (aNounDef.schema.genericAttributes) {
       aNounDef.attrTableName = aNounDef.tableName + "Attributes";
       aNounDef.attrIDColumnName = "nounID";
     }
   },
 
-  _nukeMigration: function gloda_ds_nukeMigration(aDBConnection) {
+  _nukeMigration: function gloda_ds_nukeMigration(aDBService, aDBFile,
+                                                  aDBConnection) {
     aDBConnection.close();
     aDBFile.remove(false);
-    this._log.warn("Global database has been purged due to schema change.  " + 
+    this._log.warn("Global database has been purged due to schema change.  " +
                    "old version was " + this._actualSchemaVersion +
                    ", new version is: " + this._schemaVersion);
     return this._createDB(aDBService, aDBFile);
   },
 
   /**
    * Migrate the database _to the latest version_ from an older version.  We
    *  only keep enough logic around to get us to the recent version.  This code
@@ -1497,26 +1499,26 @@ var GlodaDatastore = {
     // - add the messagesAttribFastDeletion index we thought was already covered
     //  by an index we removed a while ago (migrate-able)
     // version 26
     // - bump page size and also cache size (blow away)
     // version 30
     // - recover from bug 732372 that affected TB 11 beta / TB 12 alpha / TB 13
     //    trunk.  The fix is bug 734507.  The revision bump happens
     //    asynchronously. (migrate-able)
-    
+
     // nuke if prior to 26
     if (aCurVersion < 26)
-      return this._nukeMigration(aDBConnection);
+      return this._nukeMigration(aDBService, aDBFile, aDBConnection);
 
     // They must be desiring our "a.contact is undefined" fix!
     // This fix runs asynchronously as the first indexing job the indexer ever
     //  performs.  It is scheduled by the enabling of the message indexer and
     //  it is the one that updates the schema version when done.
-    
+
     // return the same DB connection since we didn't create a new one or do
     //  anything.
     return aDBConnection;
   },
 
   /**
    * Asynchronously update the schema version; only for use by in-tree callers
    *  who asynchronously perform migration work triggered by their initial