Ysqlsh: FATAL: role "yugabyte" does not exist

While going through the tutorial, I got stuck while trying to initialize ysqlsh to create demo tables and data.

Using Windows 10 with docker containers. Error is:

PS YugaByteDB> docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1  --echo-queries
ysqlsh: FATAL:  role "yugabyte" does not exist

Can you please help? I’m using docker-compose to start the containers with the template provided in the documentation:

version: '2'

services:
  yb-master:
      image: yugabytedb/yugabyte:latest
      container_name: yb-master-n1
      command: [ "/home/yugabyte/bin/yb-master", 
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1", 
                "--master_addresses=yb-master-n1:7100", 
                "--replication_factor=1"]
      ports:
      - "7000:7000"
      environment:
        SERVICE_7000_NAME: yb-master

  yb-tserver:
      image: yugabytedb/yugabyte:latest
      container_name: yb-tserver-n1
      command: [ "/home/yugabyte/bin/yb-tserver", 
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
                "--start_pgsql_proxy", 
                "--tserver_master_addrs=yb-master-n1:7100"]
      ports:
      - "9042:9042"
      - "6379:6379"
      - "5433:5433"
      - "9000:9000"
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master

Please advise.
Thanks.

Best Regards,
Hélder Hugo Ferreira

Hi hhferreira
Can you try this ?

PS YugaByteDB> docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -U postgres -h yb-tserver-n1  --echo-queries```

Unfortunately, did not help as can be seen below:

PS YugaByteDB> docker pull yugabytedb/yugabyte
Using default tag: latest
latest: Pulling from yugabytedb/yugabyte
Digest: sha256:0716c8c7d782b8380727d9e0768136fb7f7103f9aebf66fc170978d824ffe425
Status: Image is up to date for yugabytedb/yugabyte:latest
docker.io/yugabytedb/yugabyte:latest
PS YugaByteDB> docker-compose up -d
Creating network “yugabytedb_default” with the default driver
Creating yb-master-n1 … done
Creating yb-tserver-n1 … done
PS YugaByteDB> docker exec -it yb-master-n1 bash -c “YB_ENABLED_IN_POSTGRES=1 FLAGS_pggate_master_addresses=yb-master-n1:7100 /home/yugabyte/postgres/bin/initdb -D /tmp/yb_pg_initdb_tmp_data_dir -U postgres” The files belonging to this database system will be owned by user “root”.
This user must also own the server process.

In YugaByte DB, setting LC_COLLATE to C and all other locale settings to en_US.UTF-8 by default. Locale support will be enhanced as part of addressing https://github.com/YugaByte/yugabyte-db/issues/1557The database cluster will be initialized with locales
COLLATE: C
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: en_US.UTF-8
NUMERIC: en_US.UTF-8
TIME: en_US.UTF-8
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.

Data page checksums are disabled.

creating directory /tmp/yb_pg_initdb_tmp_data_dir … ok
creating subdirectories … ok
selecting default max_connections … 300
selecting default shared_buffers … 128MB
selecting dynamic shared memory implementation … posix
creating configuration files … ok
running bootstrap script … I0926 11:20:54.900111 42 mem_tracker.cc:250] MemTracker: hard memory limit is 1.659352 GB
I0926 11:20:54.900215 42 mem_tracker.cc:252] MemTracker: soft memory limit is 1.410449 GB
I0926 11:20:54.900596 43 async_initializer.cc:73] Starting to init ybclient
I0926 11:20:54.902719 43 async_initializer.cc:77] Successfully built ybclient
W0926 11:20:54.915623 48 reactor.cc:380] pggate_ybclient_R000: Client call yb.master.MasterService.IsInitDbDone has no timeout set for connection id: { remote: 172.27.0.2:7100 idx: 0 protocol: 0x00007fa6284a9d18 -> tcp }
ok
performing post-bootstrap initialization … I0926 11:21:11.094147 81 mem_tracker.cc:250] MemTracker: hard memory limit is 1.659352 GB
I0926 11:21:11.094249 81 mem_tracker.cc:252] MemTracker: soft memory limit is 1.410449 GB
I0926 11:21:11.094722 82 async_initializer.cc:73] Starting to init ybclient
I0926 11:21:11.096873 82 async_initializer.cc:77] Successfully built ybclient

and then when trying to run ysqlsh to connect to the service :

PS YugaByteDB> docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1 --echo-queries
ysqlsh: FATAL: role “yugabyte” does not exist
PS YugaByteDB> docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -U postgres -h yb-tserver-n1 --echo-queries
ysqlsh: FATAL: database “postgres” does not exist

Please advise.
Thanks.

Regards,
Hélder Hugo Ferreira

Can you tell me which tutorial you’re using ?

Sure, following URL used to launch docker: https://docs.yugabyte.com/latest/deploy/docker/docker-compose/#3-test-the-apis

… and this one to create tables and sample data: https://docs.yugabyte.com/latest/quick-start/explore-ysql/#docker

Any further hints?

Thanks in advance.

Best Regards,
Hélder Hugo

Hi @hhferreira,

It looks like YSQL didn’t end up getting initialized on your cluster. Can you please use this updated docker-compose.yaml?

version: '2'                                                                                         
                                                                                                     
services:                                                                                            
  yb-master:                                                                                         
      image: yugabytedb/yugabyte:latest                                                              
      container_name: yb-master-n1                                                                   
      command: [ "/home/yugabyte/bin/yb-master",                                                     
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1",                                              
                "--master_addresses=yb-master-n1:7100",                                              
                "--replication_factor=1",                                                            
                "--enable_ysql=true"]                                                                
      ports:                                                                                         
      - "7000:7000"                                                                                  
      environment:                                                                                   
        SERVICE_7000_NAME: yb-master                                                                 
                                                                                                     
  yb-tserver:                                                                                        
      image: yugabytedb/yugabyte:latest                                                              
      container_name: yb-tserver-n1                                                                  
      command: [ "/home/yugabyte/bin/yb-tserver",                                                    
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1",                                              
                "--start_pgsql_proxy",                                                               
                "--tserver_master_addrs=yb-master-n1:7100"]                                          
      ports:                                                                                         
      - "9042:9042"                                                                                  
      - "6379:6379"                                                                                  
      - "5433:5433"                                                                                  
      - "9000:9000"                                                                                  
      environment:                                                                                   
        SERVICE_5433_NAME: ysql                                                                      
        SERVICE_9042_NAME: ycql                                                                      
        SERVICE_6379_NAME: yedis                                                                     
        SERVICE_9000_NAME: yb-tserver                                                                
      depends_on:                                                                                    
      - yb-master

The main change is passing enable_ysql=true flag to yb-master process.

Steps to get it working will then be:

  1. docker-compose down : This will remove existing cluster
  2. docker-compose up -d : Create cluster using the new yaml
  3. docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1 --echo-queries : Connect to YSQL shell.

Let me know if this works.

Still not working :frowning:

PS YugaByteDB> docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1 --echo-queries
ysqlsh: FATAL: Not found: Error loading table with oid 1260 in database with oid 1: The object does not exist: table_id: “000000010000300080000000000004ec”

Could it be an error in the latest docker image?

Just tried with the latest docker image in a clean environment using the config from neha.
Can you repeat again doing steps:

  1. docker-compose stop
  2. docker-compose rm
  3. docker-compose up -d
  4. docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1 --echo-queries

Those commands run serially should work.
Taken from: https://docs.yugabyte.com/latest/deploy/docker/docker-compose/

Can you also run ps -ef and confirm that yb-master was started with —enable_ysql?

Can you also print the version that you’re using by doing select version(); in YSQL ?

Thanks! Working now, I had a weird character in my docker-compose.yaml file and the latest change to include the —enable_ysql was not being run. Nevertheless, i suggest you to update the documentation about the docker-compose.yaml definition to include this flag.

Best Regards,
Hélder Hugo Ferreira

1 Like

Good to see that it’s working now!
We’ve updated documentation as well, thanks for the feedback.

-Neha