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

[GAIAPLAT-1236] db_server - better error message when 'Address already in use' #881

Merged
merged 5 commits into from
Aug 28, 2021

Conversation

simone-gaia
Copy link
Contributor

@simone-gaia simone-gaia commented Aug 27, 2021

  • Improved server messaging.

The output of a successful run:

Starting Gaia Database Server...
No configuration file found.
Persistence is disabled.
Database instance name is 'gaia_default_instance'.

The output of an unsuccessful run:

Starting Gaia Database Server...
No configuration file found.
Persistence is disabled.
Database instance name is 'gaia_default_instance'.
ERROR: bind() failed! - Address already in use
The Gaia Database Server cannot start because another instance is already running.
Please stop any running instance of the server.

Copy link
Contributor

@senderista senderista left a comment

Choose a reason for hiding this comment

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

LGTM, except that I think we need to print the friendly error message first.

// TODO it would be nice to have a common error handler that can handle common errors.
if (errno == EADDRINUSE)
{
cerr << "ERROR: bind() failed! - " << (::strerror(errno)) << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the pattern should be that we print the friendly error message before the detailed message/stack trace. (You could also avoid duplicating the system error message by putting this in a try/catch block and printing e.what(), but maybe it's simpler this way for now.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the same pattern and formatting used in gaiac. At the moment I'm trying to make things consistent. Once we re-design the CLI we can re-evaluate these decisions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➜  cmake-build-gaiarelease-debug git:(wayne/test-auto-conn-discon) ✗ catalog/gaiac/gaiac ../schemas/test/one_to_one/one_to_one.ddl                                      
ERROR: Connect failed! - Connection refused
Can't connect to a running instance of the Gaia Database Server.
Start the Gaia Database Server and rerun gaiac.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, that's not so bad (as long as there's no stack trace before the friendly message). Approved.

// TODO it would be nice to have a common error handler that can handle common errors.
if (errno == EADDRINUSE)
{
cerr << "ERROR: bind() failed! - " << (::strerror(errno)) << endl;

Choose a reason for hiding this comment

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

Is this for our use? If not what useful information does it provide to the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, more skilled users will know what the syscall bind is. For now, we just have this one but in the future, we may have more, and knowing exactly what went wrong can be helpful. This can also be used by the user to report the errors back to us.

if (errno == EADDRINUSE)
{
cerr << "ERROR: bind() failed! - " << (::strerror(errno)) << endl;
cerr << "The Gaia Database Server cannot start because another instance is already running. Please stop any instances of the server that are running." << endl;

Choose a reason for hiding this comment

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

could there be non running instances of the server that could cause an issue?

Maybe
Stop any instances of the server and try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could there be non running instances of the server that could cause an issue?

Potentially you could create an address with the same name, but very unlikely.

Stop any instances of the server and try again.

Changed.

@simone-gaia simone-gaia merged commit 61ae802 into master Aug 28, 2021
@simone-gaia simone-gaia deleted the rondelli-db-server-address-already-in-use branch August 28, 2021 00:13
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.

4 participants