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

Error when upgrading nextcloud: table nextcloud.oc_jobs doesn't exist #1818

Closed
janvlug opened this issue Aug 21, 2023 · 11 comments
Closed

Error when upgrading nextcloud: table nextcloud.oc_jobs doesn't exist #1818

janvlug opened this issue Aug 21, 2023 · 11 comments

Comments

@janvlug
Copy link
Contributor

janvlug commented Aug 21, 2023

I have migrated an old database to nextcloudpi. The old database had no prefixes in the database tables, so I set in the config file dbtableprefix to ''.

But when trying to upgrade nextcloud, I get this:

image

table nextcloud.oc_jobs doesn't exist

System information


NextcloudPi version  v1.52.4
NextcloudPi image    NextCloudPi_RaspberryPi_v1.51.3.img
OS                   Debian GNU/Linux 11. 6.1.21-v8+ (aarch64)
automount            yes
USB devices          sda 
datadir              /media/nextcloudpi_data/ncdata/data
data in SD           no
data filesystem      btrfs
data disk usage      1.3T/5.3T
rootfs usage         4.0G/59G
swapfile             /var/swap
dbdir                /media/USBdrive/ncdatabase
Nextcloud check      ok
Nextcloud version    25.0.9.2
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
HPB service          down
Postfix service      up
Internet check       ok
Public IPv4          ***REMOVED SENSITIVE VALUE***
Public IPv6          ***REMOVED SENSITIVE VALUE***
Port 80              closed
Port 443             closed
IP                   ***REMOVED SENSITIVE VALUE***
Gateway              ***REMOVED SENSITIVE VALUE***
Interface            eth0
Certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
Uptime               3days

@janvlug
Copy link
Contributor Author

janvlug commented Aug 22, 2023

This error also happens when trying to upgrade from 25.0.9 to 25.0.10:

[ nc-update-nextcloud ] (Tue Aug 22 09:33:53 BST 2023)
Current Nextcloud version 25.0.9.2
Available Nextcloud version 25.0.10
ERROR 1146 (42S02) at line 1: Table 'nextcloud.oc_jobs' doesn't exist

@janvlug
Copy link
Contributor Author

janvlug commented Aug 22, 2023

There is a 'jobs' table in my nextcloud database, but no 'oc_jobs' database:

MariaDB [nextcloud]> show tables like 'jobs';
+----------------------------+
| Tables_in_nextcloud (jobs) |
+----------------------------+
| jobs |
+----------------------------+
1 row in set (0.002 sec)

@janvlug
Copy link
Contributor Author

janvlug commented Aug 22, 2023

I'm pretty sure that this is the problematic line:

mysql nextcloud <<<"UPDATE oc_jobs SET reserved_at=0;"

in the file: in /usr/local/bin/ncp-update-nc

@janvlug
Copy link
Contributor Author

janvlug commented Aug 26, 2023

I tried changing the line with the oc_ prefix removed, but now the update failed on downloading:

image

But maybe this is a totally independent issue.

Edit: I just retried, and then the upgrade worked fine.

@janvlug
Copy link
Contributor Author

janvlug commented Feb 25, 2024

I ran again into this issue. In the /usr/local/bin/ncp-update-nc script is this fragment:

# make sure that cron.php is not running and there are no pending jobs
# https://github.com/nextcloud/server/issues/10949
pgrep -cf cron.php &>/dev/null && { pkill -f cron.php; sleep 3; }
pgrep -cf cron.php &>/dev/null && { echo "cron.php running. Abort"; exit 1; }
mysql nextcloud <<<"UPDATE oc_jobs SET reserved_at=0;"

The issue with my Nextcloudpi installation is that it is a migration from a previous installation. My installation does not use the oc_ prefix in the database, so this line fails:

mysql nextcloud <<<"UPDATE oc_jobs SET reserved_at=0;"

Note however the reference to the closed bug 10949 [WORKAROUND] NC14 RC2: occ upgrade hangs on running cronjob it states in the above fragment of the script.

One of the comments in bug 10949 states:
"We removed this via nextcloud/server#12188"

That merge requests seems to fix bug 9992: Cronjob blocking update (forever)

Is my interpretation correct that the part of the script that I quoted above can therefore be removed? If that is indeed the case, removing that part would also fix this issue.

@janvlug
Copy link
Contributor Author

janvlug commented Feb 25, 2024

Another option to solve this issue would be to get the dbtableprefix from the config file: /var/www/nextcloud/config/config.php, and use that in the line:

mysql nextcloud <<<"UPDATE oc_jobs SET reserved_at=0;"

I would have to figure out how to get the value of a php config file in a /bin/bash script.

@janvlug
Copy link
Contributor Author

janvlug commented Feb 25, 2024

This is a command to get the value of dbtableprefix in a script:

php -r 'include("/var/www/nextcloud/config/config.php"); print ( $CONFIG['"'dbtableprefix'"'] );'

@janvlug
Copy link
Contributor Author

janvlug commented Mar 31, 2024

I created a pull request to solve the database prefix. But maybe setting the whole SQL command that I improved is not necessary any more, as described in: #1818 (comment).

@theCalcaholic
Copy link
Collaborator

@janvlug Thank you for the PR! I adjusted it a bit, so that the dynamically detected DB prefix is used everywhere and not just in ncp-update-nc.
It's now in devel and being tested

@rustyb78
Copy link

I'm getting this error with 1.54.3.

@theCalcaholic
Copy link
Collaborator

@rustyb78 Please create a new issue for this. The original issue is fixed, so we need to debug your case separataely

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

No branches or pull requests

3 participants