# Frontend is unavailable during db:add-missing-indices

**URL:** <https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984>\
**Category:** ℹ️ Support\
**Tags:** occ, database, setup\_warning\
**Created:** [September 26, 2024, 1:31pm UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984 "2024-09-26T13:31:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 26, 2024, 1:31pm UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/1 "2024-09-26T13:31:18Z")

</div>

I need to run `occ db:add-missing-indices` but it takes few days to be completed. During this time service is unavailable, so it doesn’t suit me. Any hints to run command without downtime?

---

<div class="post-metadata">

**Author:** ![SysKeeper](https://help.nextcloud.com/letter_avatar/syskeeper/32/5_5575768a8748004e209b776fc1b2916d.png) [@SysKeeper](https://help.nextcloud.com/u/SysKeeper)\
**Post date:** [September 26, 2024, 2:02pm UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/2 "2024-09-26T14:02:35Z")

</div>

Usually that should not run for days, what size of an instance are we talking about here?

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 26, 2024, 3:39pm UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/3 "2024-09-26T15:39:49Z")

</div>

mysql 90Gb.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/5_5575768a8748004e209b776fc1b2916d.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [September 27, 2024, 6:55am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/4 "2024-09-27T06:55:05Z")

</div>

Hundreds of users?  
Or some table that grew too large due to some problem? Can you check that e.g. oc\_sessions or similar tables did not get abnormally large? Or some app-related table?

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 7:18am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/5 "2024-09-27T07:18:45Z")

</div>

many users, yes.

filecache takes most of size.

```auto
| file | oc_filecache | 92702.34 |
| file | oc_files_metadata | 1156.91 |
| file | oc_activity | 115.74 |
| file | oc_onlyoffice_filekey | 66.11 |
| file | oc_properties | 46.40 |
| file | oc_cards | 29.88 |
| file | oc_filecache_extended | 24.83 |
| file | oc_files_versions | 17.03 |

```

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 27, 2024, 7:24am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/6 "2024-09-27T07:24:18Z")

</div>

You can execute. Maybe it helps.

`occ files:cleanup`

You can read [this thread](https://help.nextcloud.com/t/occ-files-cleanup-does-it-delete-the-db-table-entries-of-the-missing-files/20253) for more infos.

How much files do you have in your Nextcloud user and group data directorys?

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 8:15am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/7 "2024-09-27T08:15:35Z")

</div>

have no idea. a lot.

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 27, 2024, 9:15am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/8 "2024-09-27T09:15:18Z")

</div>

You can execute `occ db:add-missing-indices` in the background. You can use tools like `screen` or better `tmux` on your Nextcloud server. Read something about `tmux`.

- install `tmux` on your Nextcloud server (`apt-get install tmux`)
- use only one session ever, use on every use this command:  
`tmux attach || tmux new` or shorter `tmux attach || tmux`
- in tmux execute your command e.g. `occ`
- detach from tmux session and your Nextcloud server (read documentaton or just kill ssh-session)
- connect again to your server and reattach you old tmux with the command above, maybe your `occ`-command is executed to the end.

First test it with another command e.g. `top` or a `vim`. 😉

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 9:16am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/9 "2024-09-27T09:16:25Z")

</div>

yeah i know about tmux. Problem that NC fall into 504 during command execution.

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 27, 2024, 9:19am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/10 "2024-09-27T09:19:24Z")

</div>

Can you explain it? You must not interrupt your `occ`-command. Or can you not start the command again?

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 9:20am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/11 "2024-09-27T09:20:27Z")

</div>

sorry misspell) execution ofcourse.

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 27, 2024, 9:21am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/12 "2024-09-27T09:21:33Z")

</div>

Then you probably have another problem. After how long or how many hours does the error occur? Are there any logs?

Maybe a timeout problem. Search e.g. `max_execution_time`

Maybe test:

`php -d max_execution_time=7200 occ db:add-missing-indices`

Use a high value.

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 9:26am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/13 "2024-09-27T09:26:35Z")

</div>

That about DB table locking during operation.  
We wait the whole night, NC was unavailable.

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 27, 2024, 9:29am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/14 "2024-09-27T09:29:48Z")

</div>

Sorry i am not an expert. But maybe you can use:  
`'filelocking.enabled' => false,`  
while executing the command. But it maybe a risk for you.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/5_5575768a8748004e209b776fc1b2916d.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [September 27, 2024, 9:37am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/15 "2024-09-27T09:37:19Z")

</div>

Do you have as many files as you have entries in the filecache table? It should be of the same order of magnitude.

Not sure how you configured your database, but now with a very large table, it might be an option to give the database a bit more resources so it can work more efficiently. When you clean up the database, and you want to avoid conflicts with other access, I’d put NC in maintenance mode.

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 9:39am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/16 "2024-09-27T09:39:36Z")

</div>

we have really many files, so table size is fine.  
DB host never run out of resources. Basic mysql optimisation also done.

cleanup will take a lot time too, so i can do it only during night.

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 9:42am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/17 "2024-09-27T09:42:20Z")

</div>

> [@devnull](#):
>
> Sorry i am not an expert. But maybe you can use:  
> `'filelocking.enabled' => false,`  
> while executing the command. But it maybe a risk for you.

that about files multiple access, not database.

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 27, 2024, 10:18am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/18 "2024-09-27T10:18:03Z")

</div>

for now we testing [Database configuration — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/linux_database_configuration.html)  
this part looks like solution `/etc/php7/conf.d/mysql.ini`.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/5_5575768a8748004e209b776fc1b2916d.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [September 27, 2024, 11:07am UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/19 "2024-09-27T11:07:53Z")

</div>

It’s the part in the documentation. But if your table is that big, these values are likely not valid for you. You can try mysqltuner or tuning-primer scripts that analyze your runtime information and give tips what values might be interesting to change.

> [@TristisOris](#):
>
> we have really many files, so table size is fine.

in this case, it’s not sure if the clean procedure helps a lot, and it will probably verify that all the entries are valid.

---

<div class="post-metadata">

**Author:** ![TristisOris](https://help.nextcloud.com/letter_avatar/tristisoris/32/5_5575768a8748004e209b776fc1b2916d.png) [@TristisOris](https://help.nextcloud.com/u/TristisOris)\
**Post date:** [September 28, 2024, 1:51pm UTC](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984/20 "2024-09-28T13:51:40Z")

</div>

after a bit more optimisations, command works as intended without downtime.

[Next page](https://help.nextcloud.com/t/frontend-is-unavailable-during-db-add-missing-indices/204984.md?page=2)
