Issue 3687: gerrit 2.11.4 with postgresql on ubuntu 14.0.4 won't start
Status:  Invalid
Owner: ----
Closed:  Nov 25
Reported by luciano....@rockwellcollins.com, Nov 19, 2015
*****************************************************************
*****                                                       *****
***** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!!  *****
*****                                                       *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, CYANOGENMOD,  *****
***** INTERNAL ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.*****
*****                                                       *****
*****   THOSE ISSUES BELONG IN DIFFERENT ISSUE TRACKERS     *****
*****                                                       *****
*****************************************************************

Affected Version: 2.11.4

What steps will reproduce the problem?
1. Following:  https://gerrit-documentation.storage.googleapis.com/Documentation/2.11.4/install.html
2. Using gerrit 2.11.4
3. Using psql (PostgreSQL) 9.3.10
4. Using java-7-openjdk-amd64/jre
5. Using Ubuntu 64bit 14.04

What is the expected output? What do you see instead?

Installation manual states that the browser will be forked automatically displaying gerrit site when (java ... init ...) complete.  I didn't get this.  Instead http://localhost:8080 results in "unable to connect" browser error.

gerrit.conf contents:

[gerrit]
        basePath = .
        canonicalWebUrl = http://ubuntu:8080/
[database]
        type = postgresql
        hostname = localhost
        database = reviewdb
        username = gerrit2
[index]
        type = LUCENE
[auth]
        type = OPENID
[sendemail]
        smtpServer = localhost
        smtpUser = lmougen5
[container]
        user = gerrit2
        javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
[sshd]
        listenAddress = *:22
[httpd]
        listenUrl = http://*:8080/
[cache]
        directory = cache


etc/logs/error_log 1st error, there are many more included in file:

[2015-11-17 10:15:51,347] ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) No index versions ready; run Reindex

1 error
        at com.google.gerrit.lucene.LuceneVersionManager.start(LuceneVersionManager.java:119)
        at com.google.gerrit.lifecycle.LifecycleManager.start(LifecycleManager.java:74)
        at com.google.gerrit.pgm.Daemon.start(Daemon.java:293)
        at com.google.gerrit.pgm.Daemon.run(Daemon.java:205)
        at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:64)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:166)
        at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:93)
        at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
        at Main.main(Main.java:25)


Reindex attempt, as per recommendation in error_log results in the following java dump:

gerrit2@ubuntu:~$ java -jar gerrit-2.11.4.war reindex -d .
[2015-11-19 15:05:27,336] INFO  com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 119m
[2015-11-19 15:05:28,024] INFO  com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /home/gerrit2/cache
Reindexing changes: done    
Reindexed 0 changes in 0.0s (0.0/s)
Warning: InterruptedException
java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at java.lang.Thread.join(Thread.java:1289)
	at org.h2.util.MathUtils.getSecureRandom(MathUtils.java:104)
	at org.h2.util.MathUtils.secureRandomBytes(MathUtils.java:301)
	at org.h2.store.FileLock.setUniqueId(FileLock.java:309)
	at org.h2.store.FileLock.lockFile(FileLock.java:339)
	at org.h2.store.FileLock.lock(FileLock.java:133)
	at org.h2.engine.Database.open(Database.java:575)
	at org.h2.engine.Database.openDatabase(Database.java:236)
	at org.h2.engine.Database.<init>(Database.java:231)
	at org.h2.engine.Engine.openSession(Engine.java:56)
	at org.h2.engine.Engine.openSession(Engine.java:160)
	at org.h2.engine.Engine.createSessionAndValidate(Engine.java:139)
	at org.h2.engine.Engine.createSession(Engine.java:122)
	at org.h2.engine.Engine.createSession(Engine.java:28)
	at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:323)
	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
	at org.h2.Driver.connect(Driver.java:73)
	at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlHandle.<init>(H2CacheImpl.java:636)
	at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.acquire(H2CacheImpl.java:604)
	at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.buildBloomFilter(H2CacheImpl.java:365)
	at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.open(H2CacheImpl.java:337)
	at com.google.gerrit.server.cache.h2.H2CacheImpl.start(H2CacheImpl.java:167)
	at com.google.gerrit.server.cache.h2.H2CacheFactory$1.run(H2CacheFactory.java:113)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
[2015-11-19 15:05:31,349] INFO  com.google.gerrit.server.cache.h2.H2CacheFactory : Finishing 4 disk cache updates

Even after adding gerrit2 to psql via the createuser/createdb commands I cannot launch psql under user gerrit2:
someone@ubuntu:~$ sudo -i -u gerrit2
gerrit2@ubuntu:~$ psql
psql: FATAL:  database "gerrit2" does not exist


Please provide any additional information below.

During init I installed all of the plug-ins.  I noticed that the gerrit 2.0 instructions included a schema initialization step that the 2.11.4 instructions leave out.  Attempts at manually schema initialization failed since the war file does not include the specified extra/ or sql/ folders.  So I assume these steps are no longer necessary and that my error is associated with something else.

I assume my inability to launch psql from the gerrit2 user is the source of one or more of my issues.
Nov 19, 2015
#1 luciano....@rockwellcollins.com
someone@ubuntu:~$ sudo -i -u postgres
postgres@ubuntu:~$ createuser --username=postgres -RDIElPS gerrit2
Enter password for new role: 
Enter it again: 
createuser: creation of new role failed: ERROR:  role "gerrit2" already exists
postgres@ubuntu:~$ psql
psql (9.3.10)
Type "help" for help.

postgres=# \q

This shows that user postgres exists, sans home folder, and can access psql.  Also that gerrit2 exists already.

I assume once I can get my gerrit2 user access to psql that my first hurdle will be resolved.  I'm looking up, at the moment, how to purge the database and start from scratch in case I somehow messed things up.  Will post update if that helps, otherwise still stuck.

Nov 19, 2015
#2 luciano....@rockwellcollins.com
Removed "-d ." from my reindex attempt and got different output:
gerrit2@ubuntu:~$ java -jar gerrit-2.11.4.war reindex
[2015-11-19 16:42:24,861] INFO  com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 119m
[2015-11-19 16:42:25,542] INFO  com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /home/gerrit2/cache
Reindexing changes: done    
Reindexed 0 changes in 0.0s (0.0/s)
[2015-11-19 16:42:26,525] WARN  com.google.gerrit.server.cache.h2.H2CacheImpl : Cannot build BloomFilter for jdbc:h2:file:/home/gerrit2/cache/diff_intraline: Error opening database: "Sleep interrupted" [8000-174]
[2015-11-19 16:42:26,526] INFO  com.google.gerrit.server.cache.h2.H2CacheFactory : Finishing 4 disk cache updates

Still can't launch psql from gerrit2 user account.  Still can't visit localhost:8080.
Nov 23, 2015
Project Member #3 bassem.rabil
You should be passing a full path to your review_site to the reindex command, i.e.
java -jar gerrit-2.11.4.war reindex -d /<Path-to-review_site>. This review_site is the path where the gerrit.config resides at <Path-to-review_site>/etc/gerrit.config.

Can you try this and see if you are able to get rid of this error.
Nov 23, 2015
#4 luciano....@rockwellcollins.com
Please close/cancel issue resolved via proper gerrit configuration.  Had mistakenly configured gerrit to use the terminal instance of sshd's port (22) vs. giving gerrit's sshd instance its own port.  Once conflict was cleared the init succeeded and web site worked.
Nov 25, 2015
Project Member #5 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Invalid