PostgreSQL(Create db gitlabhq_production) error on install on WSL

Hello everyone,

I am trying to install GitLab-ee 16.11.4-ee.0 on Ubuntu 20.04 installed on WSL (Windows Subsystem for Linux) on Windows Server 2019.
However, I am encountering the following error during the installation process:

postgresql_database[gitlabhq_production] action create

[2024-06-21T06:39:12+00:00] INFO: execute[set options for gitlab_replicator postgresql user] ran successfully
        - execute /opt/gitlab/bin/gitlab-psql -d template1 -c "ALTER USER \"gitlab_replicator\" replication"

    * postgresql_database[gitlabhq_production] action create
      * execute[create database gitlabhq_production] action run
        [execute] WARNING:  could not flush dirty data: Function not implemented
                  createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
[2024-06-21T06:40:13+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 29 attempts left
        [execute] WARNING:  could not flush dirty data: Function not implemented
                  createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
[2024-06-21T06:41:15+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 28 attempts left
        [execute] createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
[2024-06-21T06:42:18+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 27 attempts left
        [execute] createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout


[2024-06-21T07:08:21+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 2 attempts left
        [execute] createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
[2024-06-21T07:09:23+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 1 attempt left
        [execute] createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
[2024-06-21T07:10:26+00:00] INFO: Retrying execution of execute[create database gitlabhq_production], 0 attempt left
        [execute] createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout

        ================================================================================
        Error executing action `run` on resource 'execute[create database gitlabhq_production]'
        ================================================================================

        Mixlib::ShellOut::ShellCommandFailed
        ------------------------------------
        Expected process to exit with [0], but received '1'
        ---- Begin output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
        STDOUT:
        STDERR: createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
        ---- End output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
        Ran /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production returned 1

        Cookbook Trace: (most recent call first)
        ----------------------------------------
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/database.rb:11:in `block in class_from_file'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:42:in `block (2 levels) in class_from_file'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `each'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `block in class_from_file'

        Resource Declaration:
        ---------------------
        # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/database.rb

         11:   execute "create database #{new_resource.database}" do
         12:     command %(/opt/gitlab/embedded/bin/createdb --port #{new_resource.database_port} -h #{new_resource.database_socket} -O #{new_resource.o
wner} #{new_resource.database})
         13:     user new_resource.user
         14:     retries 30
         15:     not_if { !new_resource.helper.is_running? || new_resource.helper.database_exists?(new_resource.database) }
         16:   end
         17: end

        Compiled Resource:
        ------------------
        # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/database.rb:11:in `block in class_from_file'

        execute("create database gitlabhq_production") do
          action [:run]
          default_guard_interpreter :execute
          command "/opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production"
          declared_type :execute
          cookbook_name "postgresql"
          recipe_name "standalone"
          user "gitlab-psql"
          retries 30
          not_if { #code block }
        end

        System Info:
        ------------
        chef_version=18.3.0
        platform=ubuntu
        platform_version=20.04
        ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
        program_name=/opt/gitlab/embedded/bin/cinc-client
        executable=/opt/gitlab/embedded/bin/cinc-client


      ================================================================================
      Error executing action `create` on resource 'postgresql_database[gitlabhq_production]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      execute[create database gitlabhq_production] (postgresql::standalone line 11) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process
 to exit with [0], but received '1'
      ---- Begin output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
      STDOUT:
      STDERR: createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
      ---- End output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
      Ran /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production returned 1

      Cookbook Trace: (most recent call first)
      ----------------------------------------
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/database.rb:11:in `block in class_from_file'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:42:in `block (2 levels) in class_from_file'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `each'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `block in class_from_file'

      Resource Declaration:
      ---------------------
      # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb

       42:     postgresql_database database_name do
       43:       database_port pg_port
       44:       database_socket pg_host
       45:       owner gitlab_sql_user
       46:       user postgresql_username
       47:       helper new_resource.pg_helper
       48:
       49:       only_if { rails_enabled }
       50:     end
       51:

      Compiled Resource:
      ------------------
      # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:42:in `block (2 levels) in class_from_file'

      postgresql_database("gitlabhq_production") do
        action [:create]
        default_guard_interpreter :default
        declared_type :postgresql_database
        cookbook_name "postgresql"
        recipe_name "standalone"
        database_port 5432
        database_socket "/var/opt/gitlab/postgresql"
        owner "gitlab"
        user "gitlab-psql"
        helper "*sensitive value suppressed*"
        only_if { #code block }
      end

      System Info:
      ------------
      chef_version=18.3.0
      platform=ubuntu
      platform_version=20.04
      ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
      program_name=/opt/gitlab/embedded/bin/cinc-client
      executable=/opt/gitlab/embedded/bin/cinc-client


    ================================================================================
    Error executing action `create` on resource 'database_objects[postgresql]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    postgresql_database[gitlabhq_production] (postgresql::standalone line 42) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[create databas
e gitlabhq_production] (postgresql::standalone line 11) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but recei
ved '1'
    ---- Begin output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
    STDOUT:
    STDERR: createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
    ---- End output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
    Ran /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production returned 1

    Cookbook Trace: (most recent call first)
    ----------------------------------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/database.rb:11:in `block in class_from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:42:in `block (2 levels) in class_from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `each'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:39:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/standalone.rb

     32: database_objects 'postgresql' do
     33:   pg_helper pg_helper
     34:   account_helper account_helper
     35:   not_if { pg_helper.replica? }
     36: end
     37:

    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/standalone.rb:32:in `from_file'

    database_objects("postgresql") do
      action [:create]
      updated true
      updated_by_last_action true
      default_guard_interpreter :default
      declared_type :database_objects
      cookbook_name "postgresql"
      recipe_name "standalone"
      pg_helper "*sensitive value suppressed*"
      account_helper "*sensitive value suppressed*"
      not_if { #code block }
    end

    System Info:
    ------------
    chef_version=18.3.0
    platform=ubuntu
    platform_version=20.04
    ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
    program_name=/opt/gitlab/embedded/bin/cinc-client
    executable=/opt/gitlab/embedded/bin/cinc-client

[2024-06-21T07:11:28+00:00] INFO: Running queued delayed notifications before re-raising exception
[2024-06-21T07:11:28+00:00] INFO: templatesymlink[Create a gitlab.yml and create a symlink to Rails root] sending run action to execute[clear the gitlab
-rails cache] (delayed)
Recipe: gitlab::gitlab-rails
  * execute[clear the gitlab-rails cache] action run[2024-06-21T07:14:26+00:00] INFO: execute[clear the gitlab-rails cache] ran successfully

    - execute /opt/gitlab/bin/gitlab-rake cache:clear
[2024-06-21T07:14:26+00:00] INFO: version_file[Create version file for Gitaly] sending hup action to runit_service[gitaly] (delayed)
Recipe: gitaly::enable
  * runit_service[gitaly] action hup[2024-06-21T07:14:26+00:00] INFO: runit_service[gitaly] signalled (HUP)
[2024-06-21T07:14:26+00:00] INFO: runit_service[gitaly] sent hup

    - send hup to runit_service[gitaly]
[2024-06-21T07:14:26+00:00] INFO: file[create /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf kernel.shmmax] sending run action to execute
[reload all sysctl conf] (delayed)
Recipe: package::sysctl
  * execute[reload all sysctl conf] action run
    [execute] * Applying /etc/sysctl.d/10-console-messages.conf ...
              * Applying /etc/sysctl.d/10-ipv6-privacy.conf ...
              * Applying /etc/sysctl.d/10-kernel-hardening.conf ...
              * Applying /etc/sysctl.d/10-link-restrictions.conf ...
              * Applying /etc/sysctl.d/10-magic-sysrq.conf ...
              * Applying /etc/sysctl.d/10-network-security.conf ...
              * Applying /etc/sysctl.d/10-ptrace.conf ...
              kernel.yama.ptrace_scope = 1
              * Applying /etc/sysctl.d/10-zeropage.conf ...
              * Applying /etc/sysctl.d/30-postgresql-shm.conf ...
              * Applying /usr/lib/sysctl.d/50-default.conf ...
              * Applying /usr/lib/sysctl.d/50-pid-max.conf ...
              sysctl: setting key "kernel.pid_max": Operation not permitted
              * Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf ...
              kernel.sem = 250 32000 32 275
              * Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf ...
              * Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmmax.conf ...
              kernel.shmmax = 17179869184
              * Applying /etc/sysctl.d/99-cloudimg-ipv6.conf ...
              * Applying /etc/sysctl.d/99-sysctl.conf ...
              * Applying /usr/lib/sysctl.d/protect-links.conf ...
              * Applying /etc/sysctl.conf ...
[2024-06-21T07:14:26+00:00] INFO: execute[reload all sysctl conf] ran successfully
    - execute sysctl -e --system

Running handlers:
[2024-06-21T07:14:26+00:00] ERROR: Running exception handlers
There was an error running gitlab-ctl reconfigure:

database_objects[postgresql] (postgresql::standalone line 32) had an error: Mixlib::ShellOut::ShellCommandFailed: postgresql_database[gitlabhq_productio
n] (postgresql::standalone line 42) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[create database gitlabhq_production] (postgresql::standa
lone line 11) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
STDOUT:
STDERR: createdb: error: database creation failed: ERROR:  canceling statement due to statement timeout
---- End output of /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production ----
Ran /opt/gitlab/embedded/bin/createdb --port 5432 -h /var/opt/gitlab/postgresql -O gitlab gitlabhq_production returned 1

I have attached the full error log for your reference. I have searched for solutions online but have not been able to find a resolution.
I would appreciate any assistance you can provide in resolving this issue.

Please let me know if you require any further information.
Thank you.

I am writing to inform you that I will be withdrawing my previous inquiry regarding the use of WSL on Windows Server 2019 on EC2.

I was initially testing this configuration in an EC2 environment with Windows Server 2019 and WSL installed on top of it.
However, I have since learned that using WSL on Windows Server 2019 on EC2 is not recommended.
As I am ultimately aiming to build an on-premises Windows Server 2019 environment, I no longer need to validate this configuration on EC2.

I apologize for any inconvenience this may cause. Thank you for your understanding.

Sincerely,