ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
3.98k stars 559 forks source link

Local Docker on M1 doesn't forgive mistakes #2252

Open vladnosiv opened 8 months ago

vladnosiv commented 8 months ago

Configuration:

When attempting to proceed according to instructions if the first attempt to run the container is performed:

docker run -d --rm --name ydb-local -h localhost --platform linux/amd64 \
  -p 2135:2135 -p 8765:8765 -p 2136:2136 \
  -v $(pwd)/ydb_certs:/ydb_certs -v $(pwd)/ydb_data:/ydb_data \
  -e YDB_DEFAULT_LOG_LEVEL=INFO \
  -e GRPC_TLS_PORT=2135 -e GRPC_PORT=2136 -e MON_PORT=8765 \
  cr.yandex/yc/yandex-docker-local-ydb:latest

The container will come up, but you will not be able to interact with it via the SDK. Executing health_check inside the container:

> bash health_check
+ /ydb -e grpcs://localhost:2135 --ca-file /ydb_certs/ca.pem -d /local scheme ls /local
.sys
+ /ydb -e grpcs://localhost:2135 --ca-file /ydb_certs/ca.pem -d /local table query execute -q 'create table `/local/.sys_health/test` (key int32, value utf8, primary key(key));' -t scheme
Status: GENERIC_ERROR
Issues: 
<main>: Error: Execution, code: 1060
    <main>:1:76: Error: Executing CREATE TABLE
        <main>: Error: Scheme operation failed, status: ExecError, reason: database doesn't have storage pools at all to create tablet channels to storage pool binding by profile id

After that, I noticed a warning in the documentation that to run on M1, you must select the in-memory storage option.

After the second attempt to up the container:

docker run -d --rm --name ydb-local -h localhost --platform linux/amd64 \
  -p 2135:2135 -p 8765:8765 -p 2136:2136 \
  -v $(pwd)/ydb_certs:/ydb_certs -v $(pwd)/ydb_data:/ydb_data \
  -e YDB_DEFAULT_LOG_LEVEL=NOTICE \
  -e GRPC_TLS_PORT=2135 -e GRPC_PORT=2136 -e MON_PORT=8765 \
  -e YDB_USE_IN_MEMORY_PDISKS=true \
  cr.yandex/yc/yandex-docker-local-ydb:latest

The output of the health_check command in the container is repeated exactly the same way again.

After several hours of searching for the problem, it turned out that it is enough to clear the $(pwd)/ydb_data directory, which was filled due to the first startup with disc storage. After that the problem goes away and a new attempt to run with in-memory storage no longer causes the health_check error.

> bash health_check
+ /ydb -e grpcs://localhost:2135 --ca-file /ydb_certs/ca.pem -d /local scheme ls /local
.sys_health  .sys
+ /ydb -e grpcs://localhost:2135 --ca-file /ydb_certs/ca.pem -d /local table query execute -q 'create table `/local/.sys_health/test` (key int32, value utf8, primary key(key));' -t scheme
>

Given that the warning about the need for M1 processors to use a non-standard command is below the standard command, the risk of running into such a problem is very high.

vladnosiv commented 8 months ago

I would also like to see a warning on startup with in-memory storage, which would catch such a problem much faster