-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Fix use :@ characters and add sub-section to configure username and password for sync_replica #8327
Fix use :@ characters and add sub-section to configure username and password for sync_replica #8327
Conversation
…ith the ability to read its from a file or from an environment variable Also fix use :@ characters in username and password
User names are SQL identifiers and cannot include |
Therefore, a subsection for configuration has been added that completely eliminates this problem. In the database part, the |
I'd suggest that if the new (sub-section) syntax is used for |
Yes, if a sub-section is used, the database name is used as is, including any characters. |
Fix opening a file if it is specified in absolute path Also fix the error message if there are not enough permissions to open the file
Any opinion whether it should be backported into v5? |
Where it should be documented ? I see no changes in replication.conf (at least). Also, it is not completely clear how environment or file could be used - is it allowed to use I support backporting it into v5. |
else if (key == "password") | ||
output.password = value.c_str(); | ||
else | ||
configError("unknown parameter", output.database, key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to read the file in advance, before check of key name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Since the configuration is set only by the administrator, it doesn't matter when to read from the file, before or after the key check, but in this case there is no need for double checking the key.
But can be refactor this into a separate function if need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Since the configuration is set only by the administrator, it doesn't matter when to read from the file, before or after the key check, but in this case there is no need for double checking the key.
There will be confusion with error diags when wrong key name points to the non-existing file, for example.
Consider case: pasword_file = deleted_file_name
But can be refactor this into a separate function if need?
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be confusion with error diags when wrong key name points to the non-existing file, for example.
Consider case:pasword_file = deleted_file_name
In this case, the administrator will get an error:
repl_database specifies missing or inaccessible file: deleted_file_name
which will force him to create this file anyway, and after that he will get an error:
repl_database specifies unknown parameter: pasword_file
After refactor the errors will be same, only in reverse order, first he will fix the parameter name, and then create the file.
But I agree, the option to check the parameter name before reading the file looks better, I will prepare a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the commit ebfc854
I will add a description to replication.conf, thanks for the reminder. |
Username / password (independently of each other) may be specified as either a string (key without suffix) or via envvar (key suffixed by |
Please review: 3575d91 |
That's all right. But now I've found out that there is uncertainty when several parameters with the same key are specified in a subsection, for example:
In this case, username will first be equal to |
…assword for sync_replica (#8327) * Add sub-section to configure username and password for sync_replica with the ability to read its from a file or from an environment variable Also fix use :@ characters in username and password * Corrections after Dmitry Yemanov review Fix opening a file if it is specified in absolute path Also fix the error message if there are not enough permissions to open the file * Add fixup separators also revert prefix if filename has relative path * Create a parseSyncReplica function and move the code to better read it * Add explicit to constructor SyncReplica class with a single non-default parameter --------- Co-authored-by: Andrey Kravchenko <[email protected]>
There is a problem with using :@ characters in the connection string to a sync_replica
For example, if the username contains the @ symbol:
jonh@it-corp:qwe@rty@localhost:employee
- the parser split it as:or only the password contains the @ symbol:
jonh:qwe@rty@db_alias
, then:In addition to fix it, this PR add a subsection to the sync_replica configuration. You can specify a username and password without any character restrictions, or specify where they should be read: from the first non-empty line of the file or from an environment variable.
Now in the replication.conf can: