Learn ArangoDB
Perform various experiments on ArangoDB
- Goto
database
folder docker compose up
Experiments in playground.net
- The tests use Testscontainer to setup a ArangoDB on localhost (random port)
- The database is reset to initial data after each test case.
- The initial data has 3 wallets '1', '2', '3', with balance = 100 for each.
- The goal is to transfer money from a wallet to other wallet (P2P) by creating a new "trans" edge and adjusting wallets balance; all in the same "database transaction".
I performed some experiments to see How ArangoDB would help to keep the database consistence.
Experiment 1) Happy path test:
- Open a database transaction
- perform the P2P
- Commit or Abort the database transaction should give expected result
Experiment 2) Race condition protection (without opening a transaction, nor locking anything)
- execute 3 tasks which concurently increase the wallet balance by 1
- only 1 task would successfully modify the wallet balance, the other 2 must failed
- the wallet balance is increase to 1 after the test
Experiment 3) Database Transaction locking experiment
- Open a transaction to update the balance of the wallet "1 and "2" (in the same transaction).
- The wallet "1" and "2" are (write) locked until the transaction is committed. The test was unable to modify the name of these 2 wallets.
- The wallet "3" is not locked. The test successfully modify the name of the wallet "3".
- ArangoDb is easy to learn compare to other databases (Mongo, Couchbase, Dgraph, RavenDb..). I feel like becoming productive real quick:
- (Not happy) .NET driver is (not yet) supporting Velostream
- (Skeptical) Foxx: IMO, it is similarly to stored-proc.. just more advance / power.. it is a good thing we have a powerful tool, just use with extra-caution + justification.