0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-12-12 21:33:14 +01:00

Updated How p2p.riot.im works (markdown)

Kegsay 2020-06-03 17:28:04 +01:00
parent 19c3c23052
commit 0d1eb14e89

@ -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