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

bench restore: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation #1215

Closed
2 of 6 tasks
zongo811 opened this issue Nov 12, 2021 · 3 comments
Labels

Comments

@zongo811
Copy link

Issue: Bug report

Please make sure your issue is reproducible on the latest bench version. The currently supported branches are:

  • PyPI latest
  • master (minor bug fixes)
  • v5.x (Merged with develop on every release)
  • develop (all updates)

Do the checklist before filing an issue:

  • Can you replicate the issue on the supported bench versions?
  • Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome

Describe the bug 📉
We use stored functions and views in our database. When we do "bench backup" and "bench restore" the stored functions and dependent views are not recreated, and this error occurs:
Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation

Workaround:
Stored functions and views can be recreated manually by running a sql-script.

To Reproduce 📃
Steps to reproduce the behavior:

  1. Run sql-script to create stored function and view:
DELIMITER $$
CREATE FUNCTION double_me(p_value INT)
RETURNS INT DETERMINISTIC
BEGIN
	return p_value * 2;
END $$
DELIMITER ;

CREATE OR REPLACE
VIEW `View_double_me` AS
select
    `double_me`(123) AS `double_me(123)`;

  1. bench backup
  2. bench restore ...
  3. See error

Expected behavior 📈
bench restore runs without error, stored function and view are created by bench restore .

Screenshots 🔮
If applicable, add screenshots to help explain your problem.

OS (please complete the following information): 🌀

  • Linux: debian:buster
  • macOS: version
  • Windows version
  • Others? haros:distro:version

Version Information

Can be found out by running bench version in your respective bench folder.

  • Bench Branch: 5.6.0
  • Frappe Version: 13.14.0
  • ERPNext Version: 13.14.0

Additional context 📄
Add any other context about the problem here.

Possible Solution 📑
Any idea what might be causing the issue. Or if you have a proposed solution to the problem.

@zongo811 zongo811 added the bug label Nov 12, 2021
@zongo811
Copy link
Author

The failing SQL-statement is CREATE VIEW:
grafik

Also a CREATE FUNCTION for the referenced function "json_field_value" is not included in the unpacked sql-script.
"json_field_value" is a function created by me to be used in views.

@zongo811
Copy link
Author

Got it. The target DB has a different name than the source DB, hence the DEFINER points to a nonexistent user which leads to the error.
Copying to another DB is not the same as restoring a backup :)

But: can you do something about including the stored functions?

@gavindsouza
Copy link
Collaborator

But: can you do something about including the stored functions?

You would have to raise a feature request on frappe/frappe since backup is managed there. However, from what I read in the mariadb docs, it's possible.

mysqldump dumps triggers along with tables, as these are part of the table definition. However, stored procedures, views, and events are not, and need extra parameters to be recreated explicitly (for example, --routines and --events). Procedures and functions are however also part of the system tables (for example mysql.proc).

The only bit is that it's going to be time-consuming (and probably require a lot of RnD) for someone (like me) who hasn't used these before to get this done. Seems like you have some experience here though, if you can provide the mysqldump command you'd use to make the backup, we could get a starting point for this.


Closing this since it's not covered in this project. Please continue this discussion on an issue thread on frappe/frappe or feel free to raise a PR there for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants