Open jdegoes opened 1 month ago
/bounty $5000
/attempt #1016
with your implementation plan/claim #1016
in the PR body to claim the bountyThank you for contributing to golemcloud/golem!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🟢 @justcoon | Nov 6, 2024, 3:01:20 PM | WIP |
/attempt #1016
The host implementation will live in the worker-executor service
I am assuming you mean golem-worker-executor-base
directory because golem-worker-executor
simply starts up the server with all the services defined in the former directory
and will the .wit
files reside in this repo https://github.com/golemcloud/golem-wit/blob/main/wit ?
@palash25 Please don't work on this one, it's already taken. I will have new bounties up soon.
hey @justcoon are you working on it ?
hi @debaa98 , yes I am working on it
@palash25 Please don't work on this one, it's already taken. I will have new bounties up soon.
only one person can attempt it at the same time?
@volfcan Yes, please! But be on the look out for many more bounties in the next 2 months.
WASM RDBMS
WASM components do not have access to databases natively. Rather, they must obtain all functionality from their host, through the component model types.
Although there exists a
wasi-sql
project, which intends to provide a WASI standard for database access, it is still in its infancy and shows no signs of active development.Rather than await the completion of
wasi-sql
, WASM startup Fermyon introduced a series of WIT interfacespostgres
,sqlite
, andmysql
in their WASM-native framework Spin, which use a related series of database types. These interfaces are supported by the Spin host environment.It is not clear if Fermyon’s interfaces will become standard or not, or if work will be resumed on the earlier (but far less complete)
wasi-sql
. Rather than wait for the lengthy process of standardization to produce something useful, Golem needs to support some level of database access now, so that developers using databases have options.This specification calls for the development of a new
wasm-rdbms
interface, which is designed to support features common to mainstream databases, as well as a corresponding set of implementations in Golem, powered by a low-level Rust library.Overview
The basic approach of this language-agnostic interface to databases is to have a generalized core upon which all specific database interfaces can depend.
This allows new databases to be introduced cheaply, while still respecting the fact that developers must necessarily program against specific databases, due to differences in column types, SQL syntax, and other features.
Common Elements
Common elements belong to the same generic package and have generic interface names.
They include the following, as well as related supporting types:
Unique Elements
Unique elements belong to database-specific packages, with database-specific interface names. They represent aspects of a database interface that benefit from tying to one specific database.
WIT Sketch
Common Elements
Something like the following should work for most databases (other than SQLite):
Unique Elements
Something like the following should work for databases that are not SQLite:
SQLite will require its own interface, perhaps inspired by the one in Spin.
Host Implementation
The host implementation will live in the worker-executor service and will use best-in-class async Rust libraries to provide implementations of the specified interfaces.
One slight complication is that a
connection
in the guest must not map to aconnection
in the host. The reason for this is that on a single worker-executor node, there may exist thousands of workers, and these workers should not maintain their own independent connections to the database.Therefore, in order to improve performance, it is necessary to perform connection pooling in the host, so that if only 20 concurrent connections are needed across all workers, then only 20 concurrent connections are created and maintained.
Note that if the
wasm-rdbms
interface improves in power to allow interleaving database updates with side-effects as part of a single database transaction, then pooling becomes much more difficult. However, with the current interface, the only two things a worker can do with a connection arequery
andexecute
, which atomically return results; and if those results are small enough to fit in memory, then there is no need to keep an underlying connection dedicated to the worker (instead, it can be reused for another worker).