From 0d1eb14e89f2933fefb52dc2b05ab411bcb9677c Mon Sep 17 00:00:00 2001 From: Kegsay Date: Wed, 3 Jun 2020 17:28:04 +0100 Subject: [PATCH] Updated How p2p.riot.im works (markdown) --- How-p2p.riot.im-works.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/How-p2p.riot.im-works.md b/How-p2p.riot.im-works.md index 6e74a79..bf8c57a 100644 --- a/How-p2p.riot.im-works.md +++ b/How-p2p.riot.im-works.md @@ -4,7 +4,7 @@ Chances are, if you've heard about running other programming languages in the br #### Databases -First things first: databases. Dendrite previously only supported Postgres, which has no way of being compiled to WASM. SQLite is well known for its embeddability, and sure enough you can compile SQLite to WASM. We first had to make the server support multiple database engines, which itself was no small undertaking. Aside from SQL syntax differences, 'database is locked' errors were extremely common, but what does this mean exactly? SQLite doesn't allow multiple connections to write to the database at the same time. If you attempt to do so, you'll see 'database is locked'. You can mitigate this slightly by setting a [busy timeout](https://www.sqlite.org/c3ref/busy_timeout.html) which attempts to wait until the table is unlocked - but this is just a plaster over a fundamental structural problem of the code. To resolve the issue completely, you need to painstakingly go through where you make SQL queries and look for any write statements (CREATE, DELETE, DROP, INSERT, or UPDATE) and make sure that you are only doing this sequentially e.g from the same goroutine. +First things first: databases. Dendrite previously only supported Postgres, which has no way of being compiled to WASM. SQLite is well known for its embeddability, and sure enough you can compile SQLite to WASM. We first had to make the server support multiple database engines, which itself was no small undertaking. Aside from SQL syntax differences, 'database is locked' errors were extremely common, but what does this mean exactly? SQLite doesn't allow multiple connections to write to the database at the same time. If you attempt to do so, you'll see 'database is locked'. You can mitigate this slightly by setting a [busy timeout](https://www.sqlite.org/c3ref/busy_timeout.html) which attempts to wait until the table is unlocked - but this is just a plaster over a fundamental structural problem of the code. You could enable WAL, but this isn't supported in WASM builds. To resolve the issue completely, you need to painstakingly go through where you make SQL queries and look for any write statements (CREATE, DELETE, DROP, INSERT, or UPDATE) and make sure that you are only doing this sequentially e.g from the same goroutine. #### Build tags