I spent more time than I wanted installing Gerrit on our Snow Leopard Server at work so that we could streamline code reviews. I’ve found dealing with diffs in email to be rather inconvenient, so I’m hoping that Gerrit will be a big help.
As I went through the process of installing Gerrit, I hit a speed bump at the end of the init process where it couldn’t create a required function (nextval_account_id()
).
Here’s a log of what happened:
$ java -jar gerrit.war init -d /Library/Gerrit/ *** Gerrit Code Review 2.1.6.1 *** *** Git Repositories *** Location of Git repositories [/Volumes/Data/src/git]: Import existing repositories [Y/n]? *** SQL Database *** Database server type [MYSQL/?]: Server hostname [localhost]: Server port [(MYSQL default)]: Database name [reviewdb]: Database username [gerrit2]: Change gerrit2's password [y/N]? *** User Authentication *** Authentication method [OPENID/?]: *** Email Delivery *** SMTP server hostname [exchsrvr]: SMTP server port [(default)]: SMTP encryption [NONE/?]: SMTP username [devbuilder]: Change devbuilder's password [y/N]? *** Container Process *** Run as [devbuilder]: Java runtime [/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home]: Upgrade /Library/Gerrit/bin/gerrit.war [Y/n]? Copying gerrit.war to /Library/Gerrit/bin/gerrit.war *** SSH Daemon *** Listen on address [*]: Listen on port [29418]: *** HTTP Daemon *** Behind reverse proxy [y/N]? Use SSL (https://) [y/N]? Listen on address [*]: Listen on port [8081]: Canonical URL [http://myserver.local:8081/]: Exception in thread "main" com.google.gwtorm.client.OrmException: Error in mysql_nextval.sql: CREATE FUNCTION nextval_account_id () RETURNS BIGINT LANGUAGE SQL NOT DETERMINISTIC MODIFIES SQL DATA BEGIN INSERT INTO account_id (s) VALUES (NULL); DELETE FROM account_id WHERE s = LAST_INSERT_ID(); RETURN LAST_INSERT_ID(); END; at com.google.gerrit.server.schema.ScriptRunner.run(ScriptRunner.java:55) at com.google.gerrit.server.schema.SchemaCreator.create(SchemaCreator.java:103) at com.google.gerrit.server.schema.SchemaUpdater.update(SchemaUpdater.java:52) at com.google.gerrit.pgm.Init$SiteRun.upgradeSchema(Init.java:190) at com.google.gerrit.pgm.Init.run(Init.java:85) at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:155) at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:89) at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:47) at Main.main(Main.java:25) Caused by: java.sql.SQLException: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2571) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:782) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:625) at com.google.gerrit.server.schema.ScriptRunner.run(ScriptRunner.java:53) ... 13 more
The solution is to make one change to the MySQL configuration before initializing Gerrit:
SET GLOBAL log_bin_trust_function_creators=1;
Thanks to Anthony on the Google Group for Gerrit for the answer.