Skip to content

Commit

Permalink
Merge #2416
Browse files Browse the repository at this point in the history
2416: Use a single-striped connection pool for each database layer instead of a single shared connection r=rvl a=KtorZ

# Issue Number

<!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. -->

ADP-586

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- 73df15f
  📍 **use a single-striped connection pool for each database layer**

  It is a rather common practice to use a pool of database connection
  when dealing with databases. So far, we've been using a single shared
  connection per wallet worker with, in front of each connection a lock
  preventing concurrent access to the database. The lock is only
  necessary because of the way persistent handles query statements
  internally, in principle, SQLite handles concurrent database accesses
  just well.

  For basic wallets, this is a relatively useless change. But for larger
  wallets like those manipulated by exchanges, we've observed very slow
  response time due to concurrent access of the database lock. Indeed,
  some requests may grab the lock for 10 or 20 seconds, preventing any
  requests from going throug. However, most requests are read-only
  requests and could be executed in parallel, at the discretion of
  the SQLite engine. I hope that the introduction of a connection pool
  will improve the overall experience for large wallets by better
  serving concurrent requests on the database. Finger crossed.


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: KtorZ <[email protected]>
Co-authored-by: Rodney Lorrimar <[email protected]>
  • Loading branch information
3 people authored Mar 10, 2021
2 parents da099bf + 7729917 commit 5379123
Show file tree
Hide file tree
Showing 17 changed files with 1,062 additions and 688 deletions.
5 changes: 3 additions & 2 deletions lib/core/cardano-wallet-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ library
, quiet
, random
, random-shuffle
, resource-pool
, retry
, safe
, scientific
Expand Down Expand Up @@ -393,7 +394,9 @@ benchmark db
, cardano-crypto
, cardano-wallet-core
, cardano-wallet-launcher
, cardano-wallet-test-utils
, containers
, contra-tracer
, criterion
, cryptonite
, deepseq
Expand All @@ -402,9 +405,7 @@ benchmark db
, fmt
, iohk-monitoring
, memory
, persistent-sqlite
, random
, temporary
, text
, text-class
, time
Expand Down
Loading

0 comments on commit 5379123

Please sign in to comment.