openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Failed to initialize memory_tree schema: disk I/O error: Error code 1546: Error attempting to truncate file

Open tiny-sentry[bot] opened this issue 6 months ago • 2 comments

Sentry Issue: TAURI-RUST-EV

Failed to initialize memory_tree schema: disk I/O error: Error code 1546: Error attempting to truncate file

tiny-sentry[bot] avatar May 21 '26 04:05 tiny-sentry[bot]

We discussed this when we worked on https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1019. @OrKoN thoughts?

natorion avatar May 13 '26 09:05 natorion

Yes, if ClaudeCode does not start a new instance and shares the instance between conversations, the --experimentalPageIdRouting is the way to make it work for concurrent conversations.

OrKoN avatar May 13 '26 09:05 OrKoN

We should document this feature in our docs. Seems like we have nothing.

natorion avatar May 13 '26 09:05 natorion

it is still experimental and we have not done evals. Let's bring to planning if it is important. Although with this bug I am not sure if the expectation is that we should manage multiple Chrome instances with one MCP server instance. We decided against this in https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1019

OrKoN avatar May 13 '26 12:05 OrKoN

@gilbertococchi, if you would start MCP with --isolated flag, you can run as many parallel individual sessions as you'd like even now. Each Claude session will use its own context when spinning up the mcp.

There are basically two features available atm:

  • For "subagents" (who shares the tools from parent main agent) but within the same session - you can use pageId routing - so they will reuse the same browser context and parallel work will be managed in separate tabs
  • For "Team of Agents"/"Swarm" or just two or more instances of the CLI - use the isolated flag - each session will use its own instance of the mcp and browser.

My default now is:

"chrome-devtools": {
            "command": "npx",
            "args": ["-y", "chrome-devtools-mcp@latest", "--experimentalPageIdRouting", "--isolated"]
        }

Basically it works everywhere enabling both modes of operation.

passtas avatar May 14 '26 13:05 passtas

@gilbertococchi — this is structural to the --remote-debugging-port + --user-data-dir launch model: Chrome refuses to let two instances share a profile (SingletonLock in the user-data-dir), so the second chrome-devtools-mcp invocation either deadlocks on the lockfile or silently no-ops. The isolated-context feature request (#1985) only partly helps — isolated contexts are separate sandboxes, so your second session loses the auth state the first one had, which is usually why people want two instances in the first place.

For the narrow case "two parallel agent tasks against the same logged-in profile" (versus #1985's "two parallel tasks with different auth states"), there's an architectural sidestep that doesn't show up in the CDP-launch design space: drive the already-running Chrome via an MV3 extension + native messaging host, so there's no second instance for Chrome to refuse. I ship Chrome Relay (https://chrome-relay.kushalsm.com/) on exactly that primitive — multiple concurrent agent invocations can address different tabs of the same running Chrome (chrome-relay --tab <id>) without launching anything. Doesn't help #1985's parallel-auth case at all — for that, @etairl's parallel-browser-mcp work on top of storage-state snapshots is the right primitive — but for the "two prompts, same login" case it takes the multi-instance question off the table.

Tradeoff worth naming: chrome-relay gives up the chrome-devtools-mcp tool surface (Network.*, Performance.*, accessibility-tree preloading, etc.), so it's not a chrome-devtools-mcp replacement — different point on the local-Chrome axis. Flagging here because the issue title is the right framing for the design-space distinction.

kiluazen avatar May 16 '26 13:05 kiluazen

I took a first pass at reproducing this on current main (c204a53, crate version 0.54.4) from a clean Windows worktree.

Findings:

  • Current src/openhuman/memory/tree/store.rs already treats SQLite extended code 1546 (SQLITE_IOERR_TRUNCATE) as a transient cold-start condition, together with 14 (CANTOPEN) and 4874 (IOERR_SHMMAP).
  • with_connection now serializes first-time schema initialization per DB path and caches the initialized connection, so concurrent workers should not all race through PRAGMA journal_mode=WAL / schema setup on a cold workspace.
  • The jobs worker also classifies 1546 as transient and backs off instead of reporting it as a hard failure.

Verification I ran:

cargo test --manifest-path Cargo.toml --lib with_connection_serialises_concurrent_schema_init -- --nocapture
cargo test --manifest-path Cargo.toml --lib is_transient_cold_start_classifies_known_extended_codes -- --nocapture
cargo test --manifest-path Cargo.toml --lib is_sqlite_io_transient_matches_ioerr_truncate -- --nocapture
$env:OPENHUMAN_WORKSPACE = "<fresh temp workspace>"
$env:RUST_LOG = "debug"
.\target\debug\memory-tree-init-smoke.exe 64
.\target\debug\memory-tree-init-smoke.exe 64

Result:

  • All three focused tests passed.
  • Fresh cold-start smoke: 64/64 ok, 0 failed.
  • Warm re-run smoke: 64/64 ok, 0 failed.

I could not reproduce the schema-init failure on current main. This may already be covered by the current connection-cache / transient-I/O handling, or the Sentry event may be from an older build or a production filesystem state that the local smoke does not recreate. If this is still firing after c204a53 / 0.54.4, the next useful data point would be the affected app version/build and whether the event happens during first launch, after a crash/restart, or on an existing memory_tree/chunks.db with stale -wal / -shm side files.

sunilkumarvalmiki avatar May 21 '26 08:05 sunilkumarvalmiki

Fixed by #2455 (fix(memory): run memory_tree on TRUNCATE journal instead of WAL, merged 2026-05-21).

The root cause is that the memory_tree SQLite store (chunks.db) was the only tree DB running on a WAL journal. WAL's -wal/-shm side-files fail at cold-start init under concurrent worker bootstrap — surfacing on Windows as SQLITE_IOERR_TRUNCATE (code 1546, "Error attempting to truncate file"), which is exactly this report.

#2455 switches the store to the TRUNCATE rollback journal (with synchronous=FULL), removing the -wal/-shm files entirely; existing WAL databases migrate in place on first open with committed data preserved.

Note: the fix is on main but not yet in a tagged release (current is v0.54.0), so it will reach users with the next release cut. Closing as resolved by #2455.

sanil-23 avatar May 21 '26 19:05 sanil-23