Actors, Threading and SQLite

Having partially non-reentrant actors would be nice in this situation I think.
The SQLite database pointer and basic functions (*_bind_*, *_column_*) inside an actor can be stuffed inside a reentrant actor.

Though that database actor shouldn’t be aware in my view of the underlying model. The model could be spread out over multiple databases, local storage for large files or even remote storage. Each of these could be their own actor with the model an actor in itself.

So if I would want to save some large file, I could for example end up with this
function on the model actor.

func add(file:…) {
await mainDB.write(..) 
await fileDB.write(…)
await remote.send(…)
}

If one of the writes fail, the other one should be rolled back. Such a function could presumably be reentrant (not there yet in my version).

But what shouldn’t be re-entrant is this function in the model actor.

func load() 
{
  let version = await mainDB.read(“select version from…”)
  if version.isOld  
  {
     await mainDB.run(“create newTable…”)
     await mainDB.write(“update version…”)
  } 
}

Every await is a suspension point during which example the add function could run. But if the database schema hasn’t been updated yet then that could fail. So the load function should be non-reentrant.

At least this is the current stage of my understanding and experience thus far. Just wanted to share.