It appears custom WASM endpoints do not have the additional databases attached when Trailbase initializes. I've done some experimenting and it seems that I'm able to have a dedicated WASM endpoint attach the database and all other requests can call queries referencing it, including to other WASM endpoints.
Since Trailbase appears to make internal HTTP requests for queries in WASM endpoints, I was concerned that it would only apply to a single connection and would randomly fail. Based on some basic testing it appears to apply to all requests, but I could just be getting the same connection each time. So, I made a second WASM endpoint that made repeated queries and made a script to hit that endpoint with simultaneous requests. The result was that all queries saw the attached database.
So, a few questions:
- What is the intended way to use
ATTACH DATABASE within custom WASM endpoints?
- Is every request guaranteed to see the attached database after it's attached?
- Since
ATTACH DATABASE is connection local, is there only a single connection serving WASM endpoints or is the attachment being propagated somehow?
- Can this be made simpler -- either automatically attach databases already linked in the UI, or allow this to be done during initialization and not require an initial request?
It appears custom WASM endpoints do not have the additional databases attached when Trailbase initializes. I've done some experimenting and it seems that I'm able to have a dedicated WASM endpoint attach the database and all other requests can call queries referencing it, including to other WASM endpoints.
Since Trailbase appears to make internal HTTP requests for queries in WASM endpoints, I was concerned that it would only apply to a single connection and would randomly fail. Based on some basic testing it appears to apply to all requests, but I could just be getting the same connection each time. So, I made a second WASM endpoint that made repeated queries and made a script to hit that endpoint with simultaneous requests. The result was that all queries saw the attached database.
So, a few questions:
ATTACH DATABASEwithin custom WASM endpoints?ATTACH DATABASEis connection local, is there only a single connection serving WASM endpoints or is the attachment being propagated somehow?