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

Error: "role "root" does not exist" while trying to sync a node #1953

Closed
dav8t opened this issue Mar 29, 2023 · 10 comments · Fixed by #2076
Closed

Error: "role "root" does not exist" while trying to sync a node #1953

dav8t opened this issue Mar 29, 2023 · 10 comments · Fixed by #2076
Milestone

Comments

@dav8t
Copy link

dav8t commented Mar 29, 2023

Encountered the following error while trying to sync a full node:
zkevm-state-db | 2023-03-28 19:35:21.637 UTC [458] FATAL: role "root" does not exist

@arnaubennassar
Copy link
Member

this is a problem related to the DB. How are you setting up Postgres?

@obynonwane
Copy link

Firstly, I think you should check that the "zkevm-state-db" container is actually running and possibly if your state-db volumes are actually there and read/write access granted. but generally this has to do with your db which is postgres in this instance. also confirm that your configuration (.env) for ZKEVM_NODE_STATEDB_DATA_DIR is properly pointed to its path

@dav8t
Copy link
Author

dav8t commented Apr 3, 2023

Issue got resolved after fixing the test parameter in docker compose.

@dav8t dav8t closed this as completed Apr 3, 2023
@ajb
Copy link

ajb commented Apr 3, 2023

it would be nice if you explained a bit more? which test parameter?

Here's a related issue: peter-evans/docker-compose-healthcheck#16

@ajb
Copy link

ajb commented Apr 3, 2023

I would re-open this issue, as I believe this still needs attention from the maintainers. cc @arnaubennassar

@bimlas
Copy link

bimlas commented Apr 24, 2023

I think #2042 will solve the problem.

@bimlas
Copy link

bimlas commented Apr 24, 2023

For the very first time, the database credentials seems to be applied (using state_user in the init), but it does not using it after the restart (trying to use root which happens when there is no PostgreSQL login user defined):

zkevm-state-db    | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql                 
zkevm-state-db    | CREATE DATABASE                                                                                   
zkevm-state-db    | You are now connected to database "prover_db" as user "state_user".                               
zkevm-state-db    | CREATE SCHEMA                                                                                     
zkevm-state-db    | CREATE TABLE                                                                                      
zkevm-state-db    | CREATE TABLE                                                                                      
zkevm-state-db    | CREATE ROLE                                                                                       
zkevm-state-db    | GRANT                                                                                             
zkevm-state-db    | GRANT                                                                                             
zkevm-state-db    | GRANT                                                                                             
zkevm-state-db    | GRANT   
zkevm-state-db    | 2023-04-24 13:41:56.360 UTC [49] LOG:  received fast shutdown request 

# PostgreSQL restarted

zkevm-state-db    | 2023-04-24 13:41:56.808 UTC [1] LOG:  database system is ready to accept connections              
zkevm-state-db    | 2023-04-24 13:42:05.210 UTC [79] FATAL:  role "root" does not exist  

# ...

zkevm-pool-db     | 2023-04-24 13:44:54.398 UTC [48] FATAL:  role "root" does not exist                               
zkevm-state-db    | 2023-04-24 13:44:54.399 UTC [59] FATAL:  role "root" does not exist  

@bimlas
Copy link

bimlas commented Apr 28, 2023

Upgraded to 0.0.6, still getting error during initialization and later as well:

$ docker-compose ... rm
$ sudo rm -rf data/* # database directories
$ docker-compose ... up

zkevm-state-db    | The files belonging to this database system will be owned by user "postgres".                      
zkevm-state-db    | This user must also own the server process.                                                                                                                                                                                
zkevm-state-db    |                                                                                                    
zkevm-state-db    | The database cluster will be initialized with locale "en_US.utf8".                                 
zkevm-state-db    | The default database encoding has accordingly been set to "UTF8".                                  
zkevm-state-db    | The default text search configuration will be set to "english".                                    
zkevm-state-db    |                                                                                                    
zkevm-state-db    | Data page checksums are disabled.                                                                  
zkevm-state-db    |                                                                                                    
zkevm-state-db    | fixing permissions on existing directory /var/lib/postgresql/data ... ok                                                                                                                                                   
zkevm-state-db    | creating subdirectories ... ok                                                                     
zkevm-state-db    | selecting dynamic shared memory implementation ... posix                                           
zkevm-state-db    | selecting default max_connections ... 100                                                                                                                                                                                  
zkevm-state-db    | selecting default shared_buffers ... 128MB                                                         
zkevm-state-db    | selecting default time zone ... Etc/UTC                                                            
zkevm-state-db    | creating configuration files ... ok                                                                
zkevm-state-db    | running bootstrap script ... ok                                                                    
zkevm-state-db    | performing post-bootstrap initialization ... ok                                                                                                                                                                            
zkevm-state-db    | syncing data to disk ... ok                                                                        
zkevm-state-db    |                                                                                                    
zkevm-state-db    |                                                                                                    
zkevm-state-db    | Success. You can now start the database server using:                                              
zkevm-state-db    |                                                                                                    
zkevm-state-db    |     pg_ctl -D /var/lib/postgresql/data -l logfile start           
zkevm-state-db    |                                                                                                    
zkevm-state-db    | initdb: warning: enabling "trust" authentication for local connections                             
zkevm-state-db    | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
zkevm-state-db    | waiting for server to start....2023-04-28 07:06:36.813 UTC [49] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
zkevm-state-db    | 2023-04-28 07:06:36.814 UTC [49] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
zkevm-state-db    | 2023-04-28 07:06:36.818 UTC [52] LOG:  database system was shut down at 2023-04-28 07:06:36 UTC
zkevm-state-db    | 2023-04-28 07:06:36.822 UTC [49] LOG:  database system is ready to accept connections              
zkevm-state-db    |  done                                                                                              
zkevm-state-db    | server started                                                                                     
zkevm-state-db    | CREATE DATABASE                                                                                    
zkevm-state-db    |                                                                                                    
zkevm-state-db    |                                                                                                    
zkevm-state-db    | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
zkevm-state-db    | CREATE DATABASE                                                                                    
zkevm-state-db    | You are now connected to database "prover_db" as user "state_user".
zkevm-state-db    | CREATE SCHEMA
zkevm-state-db    | CREATE TABLE
zkevm-state-db    | CREATE TABLE
zkevm-state-db    | CREATE ROLE
zkevm-state-db    | GRANT                                  
zkevm-state-db    | GRANT                                  
zkevm-state-db    | GRANT                                  
zkevm-state-db    | GRANT                                  
zkevm-state-db    |
zkevm-state-db    | waiting for server to shut down...2023-04-28 07:06:37.104 UTC [49] LOG:  received fast shutdown request                                                                                                                    
zkevm-state-db    | .2023-04-28 07:06:37.105 UTC [49] LOG:  aborting any active transactions                                                                                                                                                   
zkevm-state-db    | 2023-04-28 07:06:37.106 UTC [49] LOG:  background worker "logical replication launcher" (PID 55) exited with exit code 1
zkevm-state-db    | 2023-04-28 07:06:37.107 UTC [50] LOG:  shutting down                                                                                                                                                                       
zkevm-state-db    | 2023-04-28 07:06:37.107 UTC [50] LOG:  checkpoint starting: shutdown immediate                     
zkevm-state-db    | 2023-04-28 07:06:37.172 UTC [50] LOG:  checkpoint complete: wrote 1840 buffers (0.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.060 s, sync=0.003 s, total=0.065 s; sync files=502, longest=0.002 s, average=0.0
01 s; distance=8466 kB, estimate=8466 kB                                                                               
zkevm-state-db    | 2023-04-28 07:06:37.259 UTC [49] LOG:  database system is shut down                                
zkevm-state-db    |  done                                                                                              
zkevm-state-db    | server stopped                                                                                     
zkevm-state-db    |                                                                                                    
zkevm-state-db    | PostgreSQL init process complete; ready for start up.                                              
zkevm-state-db    |                                                                                                    
zkevm-state-db    | 2023-04-28 07:06:37.479 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit                                                 
zkevm-state-db    | 2023-04-28 07:06:37.479 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432               
zkevm-state-db    | 2023-04-28 07:06:37.479 UTC [1] LOG:  listening on IPv6 address "::", port 5432                    
zkevm-state-db    | 2023-04-28 07:06:37.481 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"                                                                                                                         
zkevm-state-db    | 2023-04-28 07:06:37.483 UTC [68] LOG:  database system was shut down at 2023-04-28 07:06:37 UTC    
zkevm-state-db    | 2023-04-28 07:06:37.534 UTC [1] LOG:  database system is ready to accept connections               
zkevm-state-db    | 2023-04-28 07:06:46.040 UTC [79] FATAL:  role "root" does not exist                                
zkevm-state-db    | 2023-04-28 07:06:48.862 UTC [90] ERROR:  permission denied for schema public                       
zkevm-state-db    | 2023-04-28 07:06:48.862 UTC [90] STATEMENT:  create or replace function get_tree (root_hash bytea, remaining_key bytea)
...
zkevm-pool-db     | 2023-04-28 07:08:17.176 UTC [151] FATAL:  role "root" does not exist                               
zkevm-state-db    | 2023-04-28 07:08:17.283 UTC [217] FATAL:  role "root" does not exist   

@bimlas
Copy link

bimlas commented Apr 28, 2023

I was able to change root to anything else, but still does not runs migrations (tried postgres and state_user):

docker-compose.yml

...-db:
  environment:
    ...
    - PGUSER=whatever

EDIT

Postgres version: PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu

Modified image: postgres to image: postgres:14 in docker-compose.yml allowed migration to run (create or replace function get_tree (root_hash bytea, remaining_key bytea)), but role "root" does not exist is still and issue (BTW I don't know which code or Docker stuff triggers this).

Opened #2058 to fix PostgreSQL version.

@ARR552
Copy link
Contributor

ARR552 commented May 4, 2023

Following instructions decribed in https://github.com/0xPolygonHermez/zkevm-node/blob/develop/docs/production-setup.md

				   (get_byte(current_hash, 31) = 0) then
				   return;
				end if;
			-- If last 4 field elements are 1000, this is a leaf node
			when 1 then	
				current_hash =
					substring(current_row.data from 57 for 8) ||
					substring(current_row.data from 49 for 8) ||
					substring(current_row.data from 41 for 8) ||
					substring(current_row.data from 33 for 8);
				select * into current_row from state.nodes where hash = current_hash;
				if not found then
					raise EXCEPTION 'Hash % not found', current_hash;
				end if;
				return next current_row;
				return;
			else
				raise EXCEPTION 'Hash % got invalid 9th field element data=%', current_hash, current_row.data;
			end case;
		end loop;
		return;
	end;$$
	
2023-05-04 07:57:00.156 UTC [169] FATAL:  role "root" does not exist
2023-05-04 07:57:10.295 UTC [197] FATAL:  role "root" does not exist
2023-05-04 07:57:20.417 UTC [216] FATAL:  role "root" does not exist
2023-05-04 07:57:30.530 UTC [236] FATAL:  role "root" does not exist
2023-05-04 07:57:40.654 UTC [243] FATAL:  role "root" does not exist

This log is from state-db

@ARR552 ARR552 reopened this May 4, 2023
@ARR552 ARR552 mentioned this issue May 4, 2023
@ARR552 ARR552 added this to the Release 0.1.0 milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants