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

Scripts from docker-entrypoint-initdb.d are not executed when using --store=type=mem,size=0.25 for start-single-node #80005

Closed
janpio opened this issue Apr 15, 2022 · 3 comments · Fixed by #80036
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@janpio
Copy link

janpio commented Apr 15, 2022

We have successfully been using an adapted Docker image with a file in /docker-entrypoint-initdb.d to create a user and apply the suggested testing configuration: https://github.com/prisma/engine-images/blob/7695bfcc990b5f91cf5d86b15ec95fc3b129f709/cockroach/cockroach.Dockerfile

Now we were also recommended to use --store=type=mem,size=0.25 as an additional argument to start-single-node --insecure and noticed that a) the user is not present any more and b) all the configuration is default - so I think our .sql file from our image is not run correctly.

Reproduction is possible via this docker-compose:

version: "3"
services:
  test-db-cockroachdb:
    image: prismagraphql/build:cockroach-custom
    restart: always
    command: start-single-node --insecure
    ports:
      - "26257:26257"
    networks:
      - engine-tests

  test-db-cockroachdb-mem:
    image: prismagraphql/build:cockroach-custom
    restart: always
    command: start-single-node --insecure --store=type=mem,size=0.25
    ports:
      - "26258:26257"
    networks:
      - engine-tests

networks:
  engine-tests: null

The prismagraphql/build:cockroach-custom is our customized image that adds the .sql file to cockroachdb/cockroach-unstable:v22.1.0-alpha.1, it is built via https://github.com/prisma/engine-images/blob/7695bfcc990b5f91cf5d86b15ec95fc3b129f709/cockroach/cockroach.Dockerfile linked above.

Jira issue: CRDB-15693

@janpio janpio added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Apr 15, 2022
@blathers-crl
Copy link

blathers-crl bot commented Apr 15, 2022

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/sql-experience (found keywords: prisma)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Apr 15, 2022
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Apr 16, 2022
@ZhouXing19
Copy link
Collaborator

Thanks for making this issue! We definitely missed the case where memory is used for storage.

The key issue is that currently the datasets created in the init process are stored on disk, and they are inaccessible if the "real" server is started with storage in memory.

For the container initialization, the current logic is:

  1. start_init_server: start the single-node server in the background, with default on-disk storage setting;
  2. run_init_queries: create default db and user, and run the init scripts saved in docker-entrypoint-initdb.d;
  3. stop the init server and restart the server with given parameters (e.g. --store-type=mem... in this case) in foreground.

The possible workaround is to start and keep running the init server with the given parameters, and eliminate the "stop and restart" step. However, this can be a bit tricky, because without a foreground process, the container would automatically exit after executing all logic in DockerFile.

I'm still investigating more solutions. Will reply under this thread once I find a solid one.

@janpio
Copy link
Author

janpio commented Apr 16, 2022

Ah, I see - thanks for the acknowledgement and explanation.

Prisma will keep using the non memory option then for now.

ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Apr 20, 2022
Currently the datasets created in the init process are stored on disk,
and they are inaccessible if the “real” server is started with storage in memory.

This is because for the container initialization, the current logic is:
1. start_init_server: start the single-node server in the background, with
default on-disk storage setting;
2. run_init_queries: create default db and user, and run the init scripts
saved in
docker-entrypoint-initdb.d;
3. *stop the init server and restart the server* with given parameters in foreground.

In this commit we start and keep running the init server with the given
parameters, and eliminate the “stop and restart” step. Also, bring the server
process from background to foreground with fg once all init queries are finished.

Fixes cockroachdb#80005.

Release note (docker): refactor the initialization process of the docker image
to accomodate the use case with memory storage.
ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Apr 21, 2022
Currently the datasets created in the init process are stored on disk,
and they are inaccessible if the “real” server is started with storage in memory.

This is because for the container initialization, the current logic is:
1. start_init_server: start the single-node server in the background, with
default on-disk storage setting;
2. run_init_queries: create default db and user, and run the init scripts
saved in
docker-entrypoint-initdb.d;
3. *stop the init server and restart the server* with given parameters in foreground.

In this commit we start and keep running the init server with the given
parameters, and eliminate the “stop and restart” step. Also, bring the server
process from background to foreground with fg once all init queries are finished.

Fixes cockroachdb#80005.

Release note (docker): refactor the initialization process of the docker image
to accomodate the use case with memory storage.
@craig craig bot closed this as completed in 6537583 Apr 22, 2022
blathers-crl bot pushed a commit that referenced this issue Apr 22, 2022
Currently the datasets created in the init process are stored on disk,
and they are inaccessible if the “real” server is started with storage in memory.

This is because for the container initialization, the current logic is:
1. start_init_server: start the single-node server in the background, with
default on-disk storage setting;
2. run_init_queries: create default db and user, and run the init scripts
saved in
docker-entrypoint-initdb.d;
3. *stop the init server and restart the server* with given parameters in foreground.

In this commit we start and keep running the init server with the given
parameters, and eliminate the “stop and restart” step. Also, bring the server
process from background to foreground with fg once all init queries are finished.

Fixes #80005.

Release note (docker): refactor the initialization process of the docker image
to accomodate the use case with memory storage.
ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Apr 26, 2022
Currently the datasets created in the init process are stored on disk,
and they are inaccessible if the “real” server is started with storage in memory.

This is because for the container initialization, the current logic is:
1. start_init_server: start the single-node server in the background, with
default on-disk storage setting;
2. run_init_queries: create default db and user, and run the init scripts
saved in
docker-entrypoint-initdb.d;
3. *stop the init server and restart the server* with given parameters in foreground.

In this commit we start and keep running the init server with the given
parameters, and eliminate the “stop and restart” step. Also, bring the server
process from background to foreground with fg once all init queries are finished.

Fixes cockroachdb#80005.

Release note (docker): refactor the initialization process of the docker image
to accomodate the use case with memory storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants