Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More database nits #1773

Merged
merged 6 commits into from
Apr 20, 2021
Merged

More database nits #1773

merged 6 commits into from
Apr 20, 2021

Conversation

pm47
Copy link
Member

@pm47 pm47 commented Apr 19, 2021

Commits are independent and are best reviewed separately.

It is good practice to create a dedicated read-only user to browse the
database safely. But since the app itself creates its tables, the
postgres user is the owner and a manual `GRANT` is required everytime a
new table is added.

This PR makes it possible to specify an arbitrary username, that will be
granted read-only access to all tables in the `public` schema.

NB: The assumption here is that eclair is the only app using the
eclair database (in the `CREATE DATABASE eclair` sense), which I believe
is reasonable.
This only affects newly created table, there is no migration.

Users that are already using postgres will keep the previous column
type, it doesn't change anything for them.
We use a timeout, because due to concurrency we may not be able to
obtain a lock immediately.

The timeout has been set to its original value of 5s and made
configurable.
@pm47
Copy link
Member Author

pm47 commented Apr 19, 2021

Rebased.

From Hikari doc:
> 🔤connectionInitSql
This property sets a SQL statement that will be executed after every new
connection creation before adding it to the pool. If this SQL is not
valid or throws an exception, it will be treated as a connection failure
and the standard retry logic will be followed. Default: none
@codecov-commenter
Copy link

Codecov Report

Merging #1773 (7a5bf88) into master (32a86a4) will decrease coverage by 0.00%.
The diff coverage is 93.54%.

@@            Coverage Diff             @@
##           master    #1773      +/-   ##
==========================================
- Coverage   89.31%   89.31%   -0.01%     
==========================================
  Files         144      144              
  Lines       10880    10892      +12     
  Branches      465      459       -6     
==========================================
+ Hits         9718     9728      +10     
- Misses       1162     1164       +2     
Impacted Files Coverage Δ
...n/scala/fr/acinq/eclair/router/StaleChannels.scala 89.65% <ø> (ø)
.../src/main/scala/fr/acinq/eclair/db/Databases.scala 85.71% <75.00%> (-0.40%) ⬇️
...main/scala/fr/acinq/eclair/db/pg/PgNetworkDb.scala 97.84% <100.00%> (+0.07%) ⬆️
...src/main/scala/fr/acinq/eclair/db/pg/PgUtils.scala 91.30% <100.00%> (+0.12%) ⬆️
...la/fr/acinq/eclair/db/sqlite/SqliteNetworkDb.scala 97.75% <100.00%> (+0.07%) ⬆️
...cinq/eclair/blockchain/bitcoind/zmq/ZMQActor.scala 90.00% <0.00%> (-5.00%) ⬇️
.../acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala 98.18% <0.00%> (-0.91%) ⬇️
...cala/fr/acinq/eclair/payment/relay/NodeRelay.scala 95.52% <0.00%> (+1.49%) ⬆️

@pm47 pm47 merged commit 33d52b6 into master Apr 20, 2021
@pm47 pm47 deleted the db-nits-3 branch April 20, 2021 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants