Installation fails in db:migrate with Finnish locale

docker

(Jouni Seppänen) #1

I’m following the INSTALL-cloud.md instructions, using a 1GB DigitalOcean droplet. When I set the values in app.yml to the recommended settings and keep the default English locale, the installation works. When I change LANG to fi_FI.UTF-8 and DISCOURSE_DEFAULT_LOCALE to fi the installation fails. There are some errors from perl about the locale being missing, but while adding the relevant localegen command to the postgres template removes these errors, it doesn’t help with the failure. There’s an error message starting with ERROR: relation "users" does not exist but I get that with the English locale too, so it’s probably not the problem.

The final lines of output are

== Seed from /var/www/discourse/db/fixtures/501_meta_category.rb
#<ActiveModel::Errors:0x007f455624c280 @base=#<PostCreator:0x007f4555c229b8 @user=#<User id: -1, username: "system", created_at: "2015-06-01 19:48:29", updated_at: "2015-06-01 19:50:05", name: "system", seen_notification_id: 0, last_posted_at: "2015-06-01 19:48:31", email: "no_email", password_hash: "44f98c4209fddf46d4d21581233aa4c6a3decf96243365c3da...", salt: "a5af1f9c4f936f2a2a2dae501d78079d", active: true, username_lower: "system", auth_token: nil, last_seen_at: nil, admin: true, last_emailed_at: nil, email_digests: true, trust_level: 4, email_private_messages: false, email_direct: false, approved: true, approved_by_id: nil, approved_at: nil, digest_after_days: 7, previous_visit_at: nil, suspended_at: nil, suspended_till: nil, date_of_birth: nil, auto_track_topics_after_msecs: nil, views: 0, flag_level: 0, ip_address: nil, new_topic_duration_minutes: nil, external_links_in_new_tab: false, enable_quoting: true, moderator: true, blocked: false, dynamic_favicon: false, title: nil, uploaded_avatar_id: nil, email_always: false, mailing_list_mode: false, locale: nil, primary_group_id: nil, registration_ip_address: nil, last_redirected_to_top_at: nil, disable_jump_reply: false, edit_history_public: false, trust_level_locked: false>, @opts={:raw=>"Keskustelua tästä sivustosta, sen järjestämisestä, siitä miten se toimii ja miten sitä voisi parantaa.", :title=>"Alueesta Meta", :category=>"Meta", :archetype=>"regular"}, @spam=false, @topic=nil, @post=nil, @guardian=#<Guardian:0x007f4555c22940 @user=#<User id: -1, username: "system", created_at: "2015-06-01 19:48:29", updated_at: "2015-06-01 19:50:05", name: "system", seen_notification_id: 0, last_posted_at: "2015-06-01 19:48:31", email: "no_email", password_hash: "44f98c4209fddf46d4d21581233aa4c6a3decf96243365c3da...", salt: "a5af1f9c4f936f2a2a2dae501d78079d", active: true, username_lower: "system", auth_token: nil, last_seen_at: nil, admin: true, last_emailed_at: nil, email_digests: true, trust_level: 4, email_private_messages: false, email_direct: false, approved: true, approved_by_id: nil, approved_at: nil, digest_after_days: 7, previous_visit_at: nil, suspended_at: nil, suspended_till: nil, date_of_birth: nil, auto_track_topics_after_msecs: nil, views: 0, flag_level: 0, ip_address: nil, new_topic_duration_minutes: nil, external_links_in_new_tab: false, enable_quoting: true, moderator: true, blocked: false, dynamic_favicon: false, title: nil, uploaded_avatar_id: nil, email_always: false, mailing_list_mode: false, locale: nil, primary_group_id: nil, registration_ip_address: nil, last_redirected_to_top_at: nil, disable_jump_reply: false, edit_history_public: false, trust_level_locked: false>, @secure_category_ids=[2, 3, 4]>, @errors=#<ActiveModel::Errors:0x007f455624c280 ...>>, @messages={:base=>["Title ei kelpaa; yritä olla kuvailevampi"]}>

I, [2015-06-01T19:50:06.062243 #36]  INFO -- : Terminating async processes
I, [2015-06-01T19:50:06.062569 #36]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main pid: 65
2015-06-01 19:50:06 UTC [65-2] LOG:  received fast shutdown request
2015-06-01 19:50:06 UTC [65-3] LOG:  aborting any active transactions
2015-06-01 19:50:06 UTC [72-2] LOG:  autovacuum launcher shutting down
2015-06-01 19:50:06 UTC [69-1] LOG:  shutting down
I, [2015-06-01T19:50:06.067727 #36]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 188
188:signal-handler (1433188206) Received SIGTERM scheduling shutdown...
188:M 01 Jun 19:50:06.120 # User requested shutdown...
188:M 01 Jun 19:50:06.121 * Saving the final RDB snapshot before exiting.
188:M 01 Jun 19:50:06.129 * DB saved on disk
188:M 01 Jun 19:50:06.129 # Redis is now ready to exit, bye bye...
2015-06-01 19:50:06 UTC [69-2] LOG:  database system is shut down


FAILED
--------------------
RuntimeError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 288 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:105:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
23b06ff362c1f4d1ac3827d894564f26ca0463832e3d5f789d7c0bdebc90923d
FAILED TO BOOTSTRAP

How could I debug this further?


(Kane York) #2

The error message is saying that

is an invalid topic title.


(Jeff Atwood) #3

Looks a bit short to me. What is the English equivalent of that topic title?


(Jouni Seppänen) #4

This is apparently a translation of “About the %{category} category” into “Alueesta %{category}”. Finnish can be concise that way.


(Jouni Seppänen) #5

Oh! I’m actually getting a localized database error: “Title ei kelpaa; yritä olla kuvailevampi” means “Title is invalid; try to be a little more descriptive.” I initially thought that’s part of the data, but it’s the actual error message.

As a native Finn, let me I assure you that “Alueesta” is a perfectly good translation of “About the category”. “Alue” means things like region and area, and it’s a common metaphor for more abstract categories. The word “about” is translated to the “-sta” suffix, and there is no determiner like “the”. I might have preferred “Meta-alueesta” to “Alueesta Meta”, but the orthography of that can get complicated if you allow arbitrary text in the category name.


(Kane York) #6

Which means that the title entropy & length requirements need to be reduced for Finnish, and it needs to happen before the categories are seeded.


(Jouni Seppänen) #7

Thanks for the pointer! Apparently “entropy” means the number of distinct characters, which is not how my statistics teacher would define it, but it’s used as just a label for the property of the title not being something like “abababababab”. I could get a Discourse site up in Finnish with these changes:

diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml
index 76fb51d..74e1bbf 100644
--- a/templates/postgres.template.yml
+++ b/templates/postgres.template.yml
@@ -20,6 +20,7 @@ hooks:
        to: sv start postgres || exit 1
 
 run:
+  - exec: locale-gen fi_FI.UTF-8
   - exec: mkdir -p /shared/postgres_run
   - exec: chown postgres:postgres /shared/postgres_run
   - exec: chmod 775 /shared/postgres_run
diff --git a/templates/web.template.yml b/templates/web.template.yml
index d0b7519..7237b67 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -77,10 +77,11 @@ run:
         - git remote set-branches --add origin master
         - git pull
         - git fetch origin $version
-        - git checkout $version
+        - git checkout origin/$version
         - mkdir -p tmp/pids
         - mkdir -p tmp/sockets
         - touch tmp/.gitkeep
+        - perl -pi -e 's/10$/5/ if /title_min_entropy/' config/site_settings.yml
         - mkdir -p                    /shared/log/rails
         - bash -c "touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log"
         - bash -c "ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log $home/log"

I’m not sure that the locale-gen line is critical, but it suppressed a lot of warnings from perl. The git checkout looks like an oversight in the script: it retrieves origin/$version (where $version is something like tests-passed) but then checks out the local $version without merging in the latest changes. The locale-gen and perl commands are really quick-and-dirty modifications; you folks probably have some better ways of doing that.


(Sam Saffron) #8

We need a proper fix here, there are quite a few settings that need to be changed in various locales. I am moving this to bug so we can track it.

Our site setting file needs to allow us to specify different defaults for different locales. Something like

min_topic_title_length:
    client: true
    default: 15
    fi_FI_default: 5

This issue also hurts us in Chinese