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

chore(postgres): not loading the libpq library by default & better user feedback #2028

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented Sep 12, 2023

Description

Before this change, when a new nwaku user wanted to start a node, the next error appeared if the libpq library wasn't installed on his/her system.

could not load: libpq.so(.5|)
(compile with -d:nimDebugDlOpen for more information)

This is indeed confusing and very little information is given. Especially confusing because it appeared even the user not mounting the Store protocol.

This change aims to enhance that and, by default, if the user doesn't mount the Store protocol, the node will start as usual.

Changes

  • Adding explicit Makefile parameter to load the postgres module, and therefore, add the dependency with the libpq library.
  • Removing unused imports from waku/waku_archive/archive.nim (not directly related to the issue being enhanced in this PR.)
  • Adding more feedback if the user tries to mount the Store protocol and use Postgres as the archive backend.

How to test

  1. Run the wakunode2 without Store mounted. The node should start properly, even if the libpq is not being installed.
  2. Run the wakunode2 mounting Store with SQLite. The node should start properly.
  3. Run wakunode2 mounting Store with Postgres and no libpq is present in the system. In this case, the next message should appear and the wakunode2 ends immediately:
    "Postgres has been configured but not been compiled. Check compiler definitions."

i. make POSTGRES=1 wakunode2 -j11 ( In this case, the user has postgres in his/her mindset )
ii. Run wakunode2 mounting Store with Postgres and no libpq is present in the system.
iii. The next message should appear, which is a little bit more descriptive than the one that appeared in all the cases:
libpq.so.5: cannot open shared object file: No such file or directory
libpq.so: cannot open shared object file: No such file or directory
could not load: libpq.so(.5|)

  1. Follow all the points from 4. but having installed the libpq. The node should start properly.

@Ivansete-status Ivansete-status self-assigned this Sep 12, 2023
@github-actions
Copy link

github-actions bot commented Sep 12, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2028

Built from 2ed497e

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the error message explanation it looks good to me. Thank you!

else:
## Error variable to be used if the user is trying to mount Store with a Postgres database
var errPgMsg = "ERROR:"
errPgMsg &= "The POSTGRES flag should be passed to the make command, e.g. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds me that the message is more like targeting developers not node operators.
It's lucky when it is met.
I would rather say something "This build does not support store with PostgresSQL."

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this. :) I add one comment re the content of the error message - it should be more generic to not assume knowledge of build environment and wakunode2 in the driver. Will this also fix the requirement for libpq when running make test in a clean environment? I think we might have to hide postgres tests behind the same compiler definition too.


else:
## Error variable to be used if the user is trying to mount Store with a Postgres database
var errPgMsg = "ERROR:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the error message here (i.e. the builder.nim) can have no knowledge of the encapsulating application, wakunode2, or make commands, etc. It's good that we're trying to be helpful, but at most the driver knows something like: "Postgres has been configured but not been compiled. Check compiler definitions."
I think it's OK to link to the install guide here, even though strictly speaking this module should not even know it's part of nwaku. :)

(Not for this PR, but the correct way to do it is to enumerate the error types here, rather than just returning error strings. That way the application wakunode2 receives an error result when setting up the archive and the application can then log more instructions as it has the context to do so. For now, this will be overkill.)

@Ivansete-status
Copy link
Collaborator Author

LGTM! Thanks for this. :) I add one comment re the content of the error message - it should be more generic to not assume...

Super good catch re make test!. I'll review that.

I'll also make the message more generic as you both suggested :)

…n builder.nim

* We only run the postgres tests when explicitly willing to, i.e. make
POSTGRES=1 test. The reason is that the postgres tests expect a
database instance to be running locally.

* waku/waku_archive_driver/builder.nim: more generic message to also
address node operators.
@Ivansete-status Ivansete-status merged commit e860202 into master Sep 13, 2023
18 checks passed
@Ivansete-status Ivansete-status deleted the avoid-load-libpq-by-default branch September 13, 2023 10:45
@Ivansete-status
Copy link
Collaborator Author

Ivansete-status commented Sep 15, 2023

Weekly Update

  • achieved: Make the nwaku not directly depend on the libpq library unless the user doesn't explicitly configure it as Store with Postgres.
  • next: -

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.

None yet

3 participants