IndexedDB: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0)

IndexedDB: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0)

我正在尝试将 IndexedDB 数据库迁移到不同的 Firefox 实例。

我只需将 ~/.mozilla/firefox/PROFILE/storage/default/file++++... 复制到新名称即可将其迁移到不同的站点(或目录,用于文件 URL)。

我也可以在同一个 Firefox 实例中迁移到不同的配置文件。

但是如果我创建一个新的主目录 (export HOME=/tmp/test-home) 并将其复制到其中,Firefox 将拒绝打开数据库,并给出错误:

UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0))

(其实我想迁移到新机器,但用相同的机器、用户和 FF 版本测试缩小了问题的范围)

FF通过什么测试来决定是否允许打开数据库?我在 "database" table 中看到一个带有路径的二进制 .metadata 文件,还有一个带有它的 .sqlite 文件(我尝试手动更新)。

我正在使用 Firefox 40.0.3 进行测试。


更新:在 Javascript 控制台中找到:

Security Error: Content at file:///home/.../ may not load data from file:///cache.manifest.
Quota 'idb' is not a valid schema!: QuotaManager.cpp:4932 <unknown>
Quota Origin 'idb' failed to parse, handled tokens: : QuotaManager.cpp:4858 <unknown>
IndexedDB UnknownErr: ActorsParent.cpp:573

元数据文件给出了旧的来源。 Firefox 的 QuotaManager 加载元数据文件,读取旧源,并尝试扫描 'idb' 目录以查找旧源。该目录不存在,因此中止。如果元数据文件被删除,Firefox 将使用正确的内容重新创建它。

此外,请确保目标 Firefox 实例至少与源实例一样新。我在 Firefox 37 尝试从 Firefox 40 读取文件时也遇到了这个错误。

感谢您的 post,很有帮助。 让我解释一下我在做什么,我认为这至少会帮助您理解问题。据我所知,隐藏文件 .metadata 与此问题无关。

我正在尝试将 sqlite 数据库从 FFOS 2.1 移动到 FFOS 2.6。该应用程序使用 indexDB,并且就应用程序所知,没有任何更改(应用程序、代码、应用程序的数据库未更改)。但是,Firefox 更改了存储应用程序数据库的数据库架构。该后端存储数据库与应用程序数据库无关。

使用 sqlite3 和 .schema 命令我可以解释差异:

旧版 2.1

CREATE TABLE database (name TEXT PRIMARY KEY, origin TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0, last_vacuum_time INTEGER NOT NULL DEFAULT 0, last_analyze_time INTEGER NOT NULL DEFAULT 0, last_vacuum_size INTEGER NOT NULL DEFAULT 0) WITHOUT ROWID;
CREATE TABLE index_data( index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_store_id INTEGER NOT NULL, value_locale BLOB, PRIMARY KEY (index_id, value, object_data_key), FOREIGN KEY (index_id) REFERENCES object_store_index(id) , FOREIGN KEY (object_store_id, object_data_key) REFERENCES object_data(object_store_id, key) ) WITHOUT ROWID;
CREATE INDEX index_data_value_locale_index ON index_data (index_id, value_locale, object_data_key, value) WHERE value_locale IS NOT NULL;
CREATE TABLE object_store( id INTEGER PRIMARY KEY, auto_increment INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL, key_path TEXT);
CREATE TABLE unique_index_data( index_id INTEGER NOT NULL, value BLOB NOT NULL, object_store_id INTEGER NOT NULL, object_data_key BLOB NOT NULL, value_localeBLOB, PRIMARY KEY (index_id, value), FOREIGN KEY (index_id) REFERENCES object_store_index(id) , FOREIGN KEY (object_store_id, object_data_key) REFERENCES object_data(object_store_id, key) ) WITHOUT ROWID;
CREATE INDEX unique_index_data_value_locale_index ON unique_index_data (index_id, value_locale, object_data_key, value) WHERE value_locale IS NOT NULL;
CREATE TABLE file (id INTEGER PRIMARY KEY, refcount INTEGER NOT NULL);
CREATE TRIGGER file_update_trigger AFTER UPDATE ON file FOR EACH ROW WHEN NEW.refcount = 0 BEGIN DELETE FROM file WHERE id = OLD.id; END;
CREATE TABLE object_data ( object_store_id INTEGER NOT NULL, key BLOB NOT NULL, index_data_values BLOB DEFAULT NULL, file_ids TEXT, data BLOB NOT NULL, PRIMARY KEY (object_store_id, key), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ) WITHOUT ROWID;
CREATE TRIGGER object_data_insert_trigger AFTER INSERT ON object_data WHEN NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(NULL, NEW.file_ids);END;
CREATE TRIGGER object_data_update_trigger AFTER UPDATE OF file_ids ON object_data WHEN OLD.file_ids IS NOT NULL OR NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NEW.file_ids);END;
CREATE TRIGGER object_data_delete_trigger AFTER DELETE ON object_data WHEN OLD.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NULL);END;
CREATE TABLE object_store_index ( id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, name TEXT NOT NULL, key_path TEXT NOT NULL, unique_index INTEGER NOT NULL, multientry INTEGER NOT NULL, locale TEXT, is_auto_locale BOOLEAN, FOREIGN KEY (object_store_id) REFERENCES object_store(id) );

较新的 2.6

CREATE TABLE database (name TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0);
CREATE TABLE index_data (index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_data_id INTEGER NOT NULL, PRIMARY KEY (index_id,value, object_data_key), FOREIGN KEY (index_id) REFERENCES object_store_index(id) ON DELETE CASCADE, FOREIGN KEY (object_data_id) REFERENCES object_data(id) ONDELETE CASCADE);
CREATE INDEX index_data_object_data_id_index ON index_data (object_data_id);
CREATE TABLE object_store (id INTEGER PRIMARY KEY, auto_increment INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL, key_path TEXT, UNIQUE (name));
CREATE TABLE unique_index_data (index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_data_id INTEGER NOT NULL, PRIMARY KEY (index_id, value, object_data_key), UNIQUE (index_id, value), FOREIGN KEY (index_id) REFERENCES object_store_index(id) ON DELETE CASCADE FOREIGN KEY (object_data_id) REFERENCES object_data(id) ON DELETE CASCADE);
CREATE INDEX unique_index_data_object_data_id_index ON unique_index_data (object_data_id);
CREATE TABLE file (id INTEGER PRIMARY KEY, refcount INTEGER NOT NULL);
CREATE TRIGGER file_update_trigger AFTER UPDATE ON file FOR EACH ROW WHEN NEW.refcount = 0 BEGIN DELETE FROM file WHERE id = OLD.id; END;
CREATE TABLE object_data (id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, key_value BLOB DEFAULT NULL, file_ids TEXT, data BLOB NOT NULL, UNIQUE (object_store_id, key_value), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ON DELETE CASCADE);
CREATE TRIGGER object_data_insert_trigger AFTER INSERT ON object_data FOR EACH ROW WHEN NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(NULL, NEW.file_ids); END;
CREATE TRIGGER object_data_update_trigger AFTER UPDATE OF file_ids ON object_data FOR EACH ROW WHEN OLD.file_ids IS NOT NULL OR NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NEW.file_ids); END;
CREATE TRIGGER object_data_delete_trigger AFTER DELETE ON object_data FOR EACH ROW WHEN OLD.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NULL); END;
CREATE TABLE object_store_index (id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, name TEXT NOT NULL, key_path TEXT NOT NULL, unique_index INTEGER NOTNULL, multientry INTEGER NOT NULL, UNIQUE (object_store_id, name), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ON DELETE CASCADE);

我一直无法找到解决此问题的 mozilla 编写的脚本。但我怀疑你可以欺骗 firefox 为你修复这个问题——降级 Firefox 插入旧数据库然后升级 firefox。允许升级脚本重写数据库。

不幸的是,这些更改看起来比简单的 adding/columns 更复杂,所以我怀疑您是否可以安全地更改或升级现有数据库。因此,除非 Mozilla 的某个人留下一个脚本,否则我相信没有其他解决方案。

我在 2018 年底使用 Firefox 63 时遇到了这个错误。

IndexedDB: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0)

它来自同一用户个人资料的多次更新。

localStorage 调试器的面板是空的,键仍然可用。

devdocs 拒绝离线安装,出现 indexedDB 错误。

解决方案This mozilla page然后单击刷新 Firefox 按钮。