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

Changing database details on multi-instance isn't applied to other instance until reboot #14906

Closed
flamber opened this issue Feb 20, 2021 · 1 comment · Fixed by #17307
Closed
Assignees
Labels
Administration/Settings .Correctness Operation/ Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Querying/ Type:Bug Product defects
Milestone

Comments

@flamber
Copy link
Contributor

flamber commented Feb 20, 2021

Describe the bug
Changing database connection details, like "Database name" or "Connection String" on multi-instance (HA/horizontal scaling) isn't applied to other instance until all instances are reboot.
Example when switching from the selected database from staging to production, or a different user (different privileges).
Or using Serialization, which will then cause all instances not to use the updated details.

There's no workaround like using sticky-connections on the load balancer, or even dropping the connections on the database.
It requires restarting all instances after details has been changed to ensure all instances are connecting using updated details.
Or manually saving settings for each instance (if the instances are accessible individually).

To Reproduce

  1. Setup two instances to the same application database - we'll call them instanceA and instanceB
  2. instanceA: Setup a new database source in Admin > Databases (I used MariaDB, but anything goes)
  3. instanceA: Run a query like SELECT DATABASE(), CURRENT_USER(); result would be something like:
| DATABASE | CURRENT_USER |
| -------- | ------------ |
| mydb     | myuser       |
  1. instanceB: Run step 3 on this instance, results are the same.
  2. instanceB: Admin > Database > change some details like Username or Database name, and run step 3 again, now results are:
| DATABASE | CURRENT_USER |
| -------- | ------------ |
| somedb   | anotheruser  |
  1. instanceA: Run step 3 on this instance, results does not match step 5's results as expected, but is still step 3's results.
  2. instanceA: Admin > Database > it will show the details that was updated on instanceB in step 5.

Expected behavior
Connection details to be flushed on all instances. Not sure if it should be graceful or hard, but I'm leaning towards hard.
By graceful, I mean only replacing idle connections, so it doesn't interrupt an existing ongoing query, whereas hard drops all connections.
It took a lot of work (years) to gracefully do reloads on Nginx and Apache, so better to do it hard, since the database details are probably not changed often and if they are, it's probably for a good reason.

Information about your Metabase Installation:
Only did two tests, since it took a long time to reproduce - one on 0.36.11 and one on 0.38.0

Severity
I'm unsure what consequence it has for sync/scan too, but it's definitely close to a P1.

Additional information
It's not the same problem as #13270, since that has a workaround with sticky load balancer.

⬇️ Please click the 👍 reaction instead of leaving a +1 or update? comment

@paoliniluis
Copy link
Contributor

Adding one use case to this one (maybe we have to create another issue if needed):

  • add a database with an ssh tunnel
  • then disable the ssh tunnel
    result: the SSH tunnel will stay enabled

@flamber flamber added Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness and removed Priority:P2 Average run of the mill bug labels Jun 8, 2021
@jeff303 jeff303 self-assigned this Aug 3, 2021
@jeff303 jeff303 linked a pull request Aug 4, 2021 that will close this issue
@jeff303 jeff303 added this to the 0.41 milestone Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Administration/Settings .Correctness Operation/ Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Querying/ Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants