You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
opfs: enable opfs temp_directory via pre-registered pool
Previously attempting to set temp_directory to an opfs:// path did not work.
Specifically, while 'auto' file handling scanned SQL stmts for opfs:// paths
to pre-open mentioned files via the async OPFS API and register them where
the sync openFile call could find them, it only worked for specific _files_,
not for a temp directory _in which_ open file would later attempt to create
files.
The sync vs async APIs of openFile vs OPFS presents a challenge here: when
the DB decides to spill to a tempfile and attempts to create it, it does so
via the openFile call, which is a sync call. This makes creating the OPFS
file at that point, via the async OPFS API, a problem.
To get around this, this change, when an OPFS temp directory is registered,
sets up a 'temp pool' of pre-created files, with sync access handles, which
can be handed out as needed in openFile calls. When closed, a file can be
truncated and returned to the pool, or deleted if the pool is already full.
When the pool runs low, new files can be opened and added to it async.
This approach works around the sync vs async API mismatch, while still
allowing openFile calls to create arbitrarily named -- from its point of
view -- files at arbitrary times.
Fixes#2061.
0 commit comments