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
Config error messages #202
Conversation
Added a `lineno` field to the `limit` structure, so that when the configuration is read such field is filled with the line number. This helps in producing error messages that point the user to the right place for editing.
Reverts 275d9f7 I changed my mind: I do believe it is better for the user to know exactly all the entries that are going to be zeroed, so she can do the right math in advance.
The parsing of the configuration file now takes the sum of "max" connections required, so that at the end it is possible to warn the user with a cumulative message like: WARN configuration.c:1366 server_max = 10 is less than required 68 max connections defined in limit file /etc/pgagroal/pgagroal_databases.conf. Adjust your configuration.
I think one error message is enough so bail as soon we know the configuration is invalid. I think the entry number is enough as well, so no need for the line number integration for now |
Uhm...I must confess that I do like programs that tell me what is happening and where, that's why I introduced line numbers that are less obscure that entry numbers. And that's also why I placed the filename in the error messages, so that the user is not mislead to a wrong path in the case of multiple installations. Besides, the only thing that we can do here is to abort immediately the parsing of the configuration as soon as we find out there is a zeroed entry, but I don't like the idea very much. In any case, the real problem will remain hidden to the user, who will "see" only that an entry is zero when its configuration file says the opposite. |
Yeah, I like the idea of keeping the line number but just record it in
or something like that. We know that a |
Produces something like this in the logs: WARN configuration.c:1356 server_max = 2 is less than required 204 max connections defined in limit file /etc/pgagroal/pgagroal_databases.conf. Adjust your configuration. FATAL configuration.c:1383 max_size must be greater than 0 for limit entry 1 WARN configuration.c:1384 Limit entry 1 (line 2) not handled
I've improved a little more, but now only the first zeroed entry is logged, because I don't do an extra loop to verify all the entries in the validate function.
|
Well, the
->
|
Remember to remove your unrelated changes (spaces, indentation, pool.c, ...) |
Sorry, but we cannot: the math about connection limits is done during the configuration parsing, i.e., at I see two possible solutions here:
I like the (1) the most. |
Or just have Then |
This means that the error message printed out now is about the max number of connection exceeded, not anymore something related to the configuration entry. Improve also the fatal messages about entry number to specify also the line number. Change `max` in `max_connections` in fatal log message.
It could be simpler: if we remove the zeroing of the entries, as you suggested, the error message becomes |
Yeah, it could. I think it is a good idea to add the file name (and line number) to each of the WARNs / FATALs so Let me know if you want a detailed review but it is mostly white-space / indentation / ... related. E.g. remove all changes that isn't necessary for this patch. Thanks, Luca ! |
It should be fine now with spaces and file/line number in limit warning messages.
looks like other
then I realized that all other |
Both are ok for single statement... But latter reads better I think |
You need to file an enhancement issue with a description of what this pull request is trying to solve, and then use that issue number in the first line of the commit message |
In commit d113e12 I mistakenly staged the pool.c with a debug message that is not useful.
Looks good, but you need to rebase against (Note, you have some merge branches in your development history) |
I've rebased against |
Looks like you merged master into your branch instead of rebasing on it, so I took your changes and created a patch manually. I have
Then I do
This makes it easier for both reviewing the patch, and using Thanks for your contribution ! |
As per discussion #199, this implements a better warning message for limits that go beyond the availability of connections.
The end result is:
the
DEBUG
andWARN
are added messages that explain when the user should look at to fix the problem. Only one warning message is printed out, even if the subsequent entries are zeroed too.This attaches also a
lineno
field to thelimit
struct to keep track of the configruation line, in order to help the user to fix the problem.