new DB creation even if the database exists (jira-core container vs MySQL host)

Francesco R
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2020

I'm new to containers and maybe I lack some impostant knowledges.
My goal was to create a jira-core container with my customizations (my plugins, some configuration files etc.) and to use it connected to a MySQL server running on the host, with already stored issues (i.e. already used with a normal jira-core instance).
I succeeded in connecting the customized container (FROM atlassian/jira-core:7.13.2-jdk8) to the server (after some failed attemps) sharing the dbconfig.xml file (through a VOLUME [${JIRA_HOME}]) and modifing the url string in it.

When the jira container started the 1st time in the log there were traces like these:

[...]
JIRA-Bootstrap WARN [o.o.c.entity.jdbc.DatabaseUtil] Entity "Action" has no table in the database
JIRA-Bootstrap ERROR [o.o.c.entity.jdbc.DatabaseUtil] Could not create table "jira_docker01.jiraaction"
JIRA-Bootstrap ERROR [o.o.c.entity.jdbc.DatabaseUtil] SQL Exception while executing the following:
CREATE TABLE jira_docker01.jiraaction (ID DECIMAL(18,0) NOT NULL, issueid DECIMAL(18,0), AUTHOR VARCHAR(255), actiontype VARCHAR(255), actionlevel VARCHAR(255), rolelevel DECIMAL(18,0), actionbody LONGTEXT, CREATED DATETIME, UPDATEAUTHOR VARCHAR(255), UPDATED DATETIME, actionnum DECIMAL(18,0), CONSTRAINT PK_jiraaction PRIMARY KEY (ID))
Error was: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jiraaction' already exists
JIRA-Bootstrap WARN [o.o.c.entity.jdbc.DatabaseUtil] Entity "Application" has no table in the database
JIRA-Bootstrap ERROR [o.o.c.entity.jdbc.DatabaseUtil] Could not create table "jira_docker01.cwd_application"
JIRA-Bootstrap ERROR [o.o.c.entity.jdbc.DatabaseUtil] SQL Exception while executing the following:
CREATE TABLE jira_docker01.cwd_application (ID DECIMAL(18,0) NOT NULL, application_name VARCHAR(255), lower_application_name VARCHAR(255), created_date DATETIME, updated_date DATETIME, active DECIMAL(9,0), description VARCHAR(255), application_type VARCHAR(255), credential VARCHAR(255), CONSTRAINT PK_cwd_application PRIMARY KEY (ID))
Error was: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'cwd_application' already exists
[...]

However the connection was ok and the running container had my all old issues.
My question is: why the installation process tries to create the tables in the DB if in dbconfig.xml I configured an existing one ?

I hope I've been clear enough in writing the question.
Thanks.

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2020

The setup in your home directory does not match the data that is in the existing database.  Your new Jira is still in a state where it expects to be given an empty database so that it can go through the setup routine.

If you are trying to create a new Jira install and connect it to a pre-existing database, what you need to do several steps (apologies if you did do this, but I couldn't see all the steps called out in your question)

Download a Jira install of exactly the same version as the existing database was from

  • Create a new empty database
  • Install Jira, pointed at the empty database, running through to the point where you can log in as the admin and be asked to start creating projects and users etc
  • Stop it
  • Change the dbconfig file so it points at the old database
  • Restart it
  • Log in using an admin user from the old Jira
  • Run a full re-index
Francesco R
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2020

I'll try a new docker build following your steps and I'll let you know, but I don't understand why I should start/stop and then change dbconfig.xml and restart.

My steps were:

  • Create a new database (let's call it mydbcpy) where I copied my actual development database (let's call it mydborig)
  • Build a docker image with VOLUME command to share /var/atlassian/application-data/jira where I store my plugins (in plugins/installed-plugins) and my dbconfig.xml file pointed to the newly copied database
  • Start the docker
  • Run the full re-index

At this point the behaviour I was expecting that Jira starts and, according the dbconfig.xml, it begins to use the mydbcpy database. Jira detects it but it tries to create the tables and just after doing this, it uses it and all datas in it.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2020

You need to do this because your installation does not match your database.

Your steps are wrong because you have created a new Jira that is missing all the config it needs and then pointed it at a load of data it is not expecting to see. 

A plain Jira install that has not yet run through the initial set up is missing a whole load of stuff it needs before it can be used.  You've not done any of that, you've just expected it work without any setup. 

It's a bit like putting me in front of a partly done oil painting and expecting me to finish it without teaching me how to paint first, not least the bit about going to get the paint and brushes I'll need.

serge calderara
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2022

@Francesco R , I am in the same situation as you did you manage to reach what you need to do ?

in my case I have run a full setup of a docker image using an empty database and login into it

Then I edit the dbconfig.xml to point to my db which contains all my data but as you mentionned, setup start from scratch

Any help on how you solve it ?

regards

Francesco R
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2022

Hello @serge calderara 
I just gave up because I was just doing some attempts and I did not need to use docker in production environment. I was just trying that for study purpose. Anyway if I well remember, since I had few issues I restore the database just after it starts fro scratch.
I'm sorry but I did not deepened the problem

Calderara Serge
Contributor
January 31, 2022

@Francesco R I manage to solve it by following the Miragration of jira from one server to an other

regards

Suggest an answer

Log in or Sign up to answer