Bitbucket Server upgrade fails due to "Incorrect string value for column 'comment_text'"

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

The upgrade to Bitbucket Server 5.+ fails.

The following appears in the user interface:

The database schema could not be updated

The following appears in the atlassian-bitbucket.log

ERROR [spring-startup] liquibase classpath:liquibase/master.xml: liquibase/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios: Change Set liquibase/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios failed. Error: Incorrect string value: '<character>' for column 'comment_text' at row <row_number> [Failed SQL: insert into bb_comment (
id,
author_id,
comment_text,
created_timestamp,
entity_version,
thread_id,
updated_timestamp
)
select
id,
author_id,
comment_text,
created_timestamp,
entity_version,
id,
updated_timestamp
from sta_comment
where root_id is null]

Diagnosis

Environment

  • MySQL as database

Diagnostic Steps

  • Check the database encoding and collation:

    USE <database_name>;
    SELECT @@character_set_database, @@collation_database
    • The results don't match the expected results of using utf8 as encoding and utf8_bin as collation

  • The database dump for the sta_comment table returns the expected values (utf8 as encoding and utf8_bin as collation)

Cause

When upgrading Bitbucket Server, SQL commands are run to update the database schema.

If the default encoding or collation are not correct (e.g. latin1), the new tables with the configured encoding (latin1) in this case.

If special characters are stored in the database and cannot be converted, the data migration from the sta_comment table to the bb_comment fails due to different encoding.

Resolution

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  • Take a backup of Bitbucket Server (see Data recovery and backups)
  • Stop Bitbucket Server
  • Change the database encoding to utf8 by running

    USE <database_name>;
    ALTER DATABASE <database_name> CHARACTER SET utf8;
  • Perform the upgrade

Last modified on Mar 1, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.