# Musicbrainz-docker: Cannot allocate memory at /musicbrainz-server/perl\_modules/lib/perl5/DateTime/Locale/Data.pm line 8146

**URL:** https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417
**Category:** Development
**Tags:** docker, en, development, issue, musicbrainz
**Created:** [July 26, 2024, 4:34pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417 "2024-07-26T16:34:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![robertok](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@robertok](https://community.metabrainz.org/u/robertok)
#### Post date: [July 26, 2024, 4:34pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/1 "2024-07-26T16:34:43Z")

</div>

Hi Everyone,

I seem to be facing an issue with setting up the musicbrainz-docker repository locally, specifically with the database dump download and creating the database.

The issue occurs when running (I am working in sample mode)

```auto
docker-compose run --rm musicbrainz recreatedb.sh -sample -fetch

```

and variants of of it including `sudo docker-compose...` and

```auto
docker-compose run --rm musicbrainz createdb.sh -sample -fetch

```

The common error is the line:

```auto
Cannot allocate memory at /musicbrainz-server/perl_modules/lib/perl5/DateTime/Locale/Data.pm line 8146.

```

For example running:

```auto
sudo docker-compose run --rm musicbrainz recreatedb.sh -sample -fetch

```

results in:

```auto
found existing dumps
2024/07/26 15:35:08 Waiting for: tcp://db:5432
2024/07/26 15:35:08 Connected to tcp://db:5432
2024/07/26 15:35:08 Command finished successfully.
--> Working on .
Configuring /musicbrainz-server ... OK
<== Installed dependencies for .. Finishing.
Catalyst::Plugin::StackTrace is up to date. (0.12)
File::Slurp is up to date. (9999.32)
Plack::Handler::Starlet is up to date. (undef)
Plack::Middleware::Debug::Base is up to date. (0.18)
Server::Starter is up to date. (0.35)
Term::Size::Any is up to date. (0.002)
Cannot allocate memory at /musicbrainz-server/perl_modules/lib/perl5/DateTime/Locale/Data.pm line 8146.
Compilation failed in require at /musicbrainz-server/admin/InitDb.pl line 11.
BEGIN failed--compilation aborted at /musicbrainz-server/admin/InitDb.pl line 11.

```

And running:

```auto
admin/configure add local/compose/memory-settings.yml
docker-compose up -d
sudo docker-compose run --rm musicbrainz recreatedb.sh -sample -fetch

```

results in `Failed to import dataset.`:

```auto
Fri Jul 26 15:00:16 2024 : InitDb.pl starting
Fri Jul 26 15:00:16 2024 : Creating database 'musicbrainz_db'
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
Fri Jul 26 15:00:22 2024 : Installing extensions (Extensions.sql)
Fri Jul 26 15:00:23 2024 : Creating collations ... (CreateCollations.sql)
Fri Jul 26 15:00:23 2024 : Creating types ... (CreateTypes.sql)
Fri Jul 26 15:00:24 2024 : Creating tables ... (CreateTables.sql)
Fri Jul 26 15:00:27 2024 : Creating CAA tables ... (caa/CreateTables.sql)
Fri Jul 26 15:00:28 2024 : Creating EAA tables ... (eaa/CreateTables.sql)
Fri Jul 26 15:00:29 2024 : Creating documentation tables ... (documentation/CreateTables.sql)
Fri Jul 26 15:00:31 2024 : Creating json_dump tables ... (json_dump/CreateTables.sql)
Fri Jul 26 15:00:32 2024 : Creating report tables ... (report/CreateTables.sql)
Fri Jul 26 15:00:32 2024 : Creating sitemaps tables ... (sitemaps/CreateTables.sql)
Fri Jul 26 15:00:33 2024 : Creating statistics tables ... (statistics/CreateTables.sql)
Fri Jul 26 15:00:34 2024 : Creating wikidocs tables ... (wikidocs/CreateTables.sql)
Cannot allocate memory at /musicbrainz-server/perl_modules/lib/perl5/DateTime/Locale/Data.pm line 8146.
Compilation failed in require at /musicbrainz-server/admin/MBImport.pl line 14.
BEGIN failed--compilation aborted at /musicbrainz-server/admin/MBImport.pl line 14.

Failed to import dataset.
Fri Jul 26 15:00:40 2024 : InitDb.pl failed

```

with the same error line in common as the first failure:

```auto
Cannot allocate memory at /musicbrainz-server/perl_modules/lib/perl5/DateTime/Locale/Data.pm line 8146.

```

**My setup is as follows:**

I followed [https://community.metabrainz.org/t/how-difficult-is-it-to-setup-a-local-musicbrainz-server/459658/21](https://community.metabrainz.org/t/how-difficult-is-it-to-setup-a-local-musicbrainz-server/459658/21), also running the extra command:  
`admin/configure add musicbrainz-standalone`.

I also set up a `local/compose/memory-settings.yml` file as suggested [here](https://github.com/metabrainz/musicbrainz-docker/blob/master/README.md#modify-memory-settings)  
and have uncommented the MAINTENANCE lines in the `DBDefs.pm` files.

I have also adjusted docker-compose.yml:

- Increased database memory: `shm_size: "8GB"`
- Database shared buffers size increase: `command: postgres -c "shared_buffers=8192MB" -c "shared_preload_libraries=pg_amqp.so"`
- musicbrainz, added a memory limit: `mem_limit: 8g`
- Changed the `docker-compose.yml` version: `version: '2.4'`

I have also made sure my docker daemon has sufficient resources with my memory set to 14GB and swap to 4GB.

Any recommendations would be very welcome, or if I need to create an issue on the musicbrainz-docker github let me know.

**Versions**

```auto
echo MusicBrainz Docker: `git describe --always --broken --dirty --tags`
>>> MusicBrainz Docker: v-2024-07-22.0-dirty
echo Docker Compose: `docker-compose version --short`
>>> Docker Compose: 2.21.0-desktop.1
sudo docker version -f 'Docker Client/Server: {{.Client.Version}}/{{.Server.Version}}'
>>> Docker Client/Server: 24.0.6/24.0.6

```

---

<div class="post-metadata">

### Author: ![Bitmap](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/f04885/32.png) [@Bitmap](https://community.metabrainz.org/u/Bitmap)
#### Post date: [July 29, 2024, 4:44pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/2 "2024-07-29T16:44:53Z")

</div>

Hi, unfortunately I wasn’t able to reproduce your issue on my system. I didn’t configure anything related to memory usage (but I have 32GB of RAM on this machine). My .env file just looks like this:

```auto
COMPOSE_FILE=docker-compose.yml:compose/musicbrainz-standalone.yml

```

Setting `shm_size`/`shared_buffers` to 8GB sounds like too much if you have 14GB available to Docker. The PostgreSQL documentation recommends 25% of available memory for `shared_buffers`, which would be 3.5GB in your case.

The “Cannot allocate memory” error is happening inside the `musicbrainz` container, though. So it’s possible that the other containers (including `db`) are using too much memory and not leaving enough for `musicbrainz`. I’d try reducing `shared_buffers` (and `shm_size`) to start with.

You can check the memory usage of running containers with `docker stats` (which may require `sudo` on your system). So you could try watching the `stats` output in another tab while the recreatedb command is running and observe the memory usage of each container.

---

<div class="post-metadata">

### Author: ![robertok](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@robertok](https://community.metabrainz.org/u/robertok)
#### Post date: [July 30, 2024, 2:23pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/3 "2024-07-30T14:23:20Z")

</div>

Hi Bitmap, thank you for your help, but it sounds like an issue with my system.

I have simplified to the following setup after removing the repository and all cached volumes & containers (`memory-settings.yml` provides the db container 4gb of shared\_buffers):

```auto
git clone https://github.com/metabrainz/musicbrainz-docker.git
cd musicbrainz-docker
admin/configure with alt-db-only-mirror
**uncomment MAINTENANCE configs in DBDef files**
docker-compose build
admin/configure add local/compose/memory-settings.yml
docker-compose run --rm musicbrainz createdb.sh -fetch

```

I don’t use sudo as I have previously run  
`sudo chown robertoking:staff /Users/robertoking/.docker/buildx/current`,  
I hope this isn’t an issue?

As I watch the containers using `docker stats` the `docker-run` container is at ~100% of CPU but none of the containers ever get anywhere near to 100% of memory and the highest that one gets to is the db-1 container getting to between 5-10% of allowed memory.

I am also seeing  
`There is no configuration in DBDefs for database MAINTENANCE`  
in the error lines:

```auto
There is no configuration in DBDefs for database MAINTENANCE at /musicbrainz-server/script/database_exists line 17.
Cannot allocate memory at /musicbrainz-server/local/lib/perl5/DateTime/Locale/Data.pm line 8146.
Compilation failed in require at /musicbrainz-server/admin/InitDb.pl line 11.
BEGIN failed--compilation aborted at /musicbrainz-server/admin/InitDb.pl line 11.

```

I have uncommented the MAINTENANCE configurations in both DBDefs.pm files. So it is odd behaviour.

---

<div class="post-metadata">

### Author: ![Bitmap](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/f04885/32.png) [@Bitmap](https://community.metabrainz.org/u/Bitmap)
#### Post date: [July 31, 2024, 2:31pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/4 "2024-07-31T14:31:18Z")

</div>

Which DBDefs.pm file are you modifying before building the image? build/musicbrainz/Dockerfile? I think that should work…

But the `MAINTENANCE` error sounds like a bug; it shouldn’t be necessary to hand-modify the raw DBDefs.pm file, AFAIK. @yvanzo: there are some scripts in musicbrainz-docker which run `./script/database_exists MAINTENANCE`, and I wonder if those have been [broken by this change](https://github.com/metabrainz/musicbrainz-server/pull/3244#discussion_r1593687363).

Have you tried building things without any custom memory settings or other local changes? In your initial post you mentioned, “I have also made sure my docker daemon has sufficient resources.” Does that mean you made other system-wide configuration changes related to Docker’s resource limits, e.g., via systemd?

---

<div class="post-metadata">

### Author: ![yvanzo](https://community.metabrainz.org/user_avatar/community.metabrainz.org/yvanzo/32/2864_2.png) [@yvanzo](https://community.metabrainz.org/u/yvanzo)
#### Post date: [August 7, 2024, 2:09pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/5 "2024-08-07T14:09:48Z")

</div>

Hi @robertok, I followed your steps and could not reproduce the issue. So it is most likely a memory allocation issue with your host operating system or with the settings of your Docker daemon.

If you are using macOS, see [troubleshooting](https://github.com/metabrainz/musicbrainz-docker/blob/master/TROUBLESHOOTING.md#initdbpl-failed-on-macos). Otherwise, see if your system can/must be configured to allow more memory for Docker containers.

> [@robertok](#):
>
> I don’t use sudo as I have previously run […] I hope this isn’t an issue?

Not using `sudo` isn’t an issue if your Docker setup doesn’t require it.

> [@robertok](#):
>
> I am also seeing `There is no configuration in DBDefs for database MAINTENANCE` in the error lines

This message is a glitch but it isn’t a blocking issue either.

---

<div class="post-metadata">

### Author: ![yvanzo](https://community.metabrainz.org/user_avatar/community.metabrainz.org/yvanzo/32/2864_2.png) [@yvanzo](https://community.metabrainz.org/u/yvanzo)
#### Post date: [August 7, 2024, 2:12pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/6 "2024-08-07T14:12:17Z")

</div>

> [@Bitmap](#):
>
> But the `MAINTENANCE` error sounds like a bug; it shouldn’t be necessary to hand-modify the raw DBDefs.pm file, AFAIK. @yvanzo: there are some scripts in musicbrainz-docker which run `./script/database_exists MAINTENANCE`, and I wonder if those have been [broken by this change](https://github.com/metabrainz/musicbrainz-server/pull/3244#discussion_r1593687363).

Hi @bitmap, What was this change needed for? Should it be reverted? Or should we make this script support an option `--(no-)fallback`?

---

<div class="post-metadata">

### Author: ![Bitmap](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/b/f04885/32.png) [@Bitmap](https://community.metabrainz.org/u/Bitmap)
#### Post date: [August 13, 2024, 3:38pm UTC](https://community.metabrainz.org/t/musicbrainz-docker-cannot-allocate-memory-at-musicbrainz-server-perl-modules-lib-perl5-datetime-locale-data-pm-line-8146/706417/7 "2024-08-13T15:38:32Z")

</div>

I [reverted this](https://github.com/metabrainz/musicbrainz-server/commit/72642ba9eea5e018a21be4db680bebcaa05b55cf) while doing the release yesterday, since I couldn’t see any reason for it to be changed (and it only introduced unexpected issues). Perhaps in the future a `--(no-)fallback` option would make sense if we do need that (reverted) behavior back.
