The Database Constraint Checker

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

During a Confluence upgrade, Hibernate makes some attempt to keep the database schema up to date with what it needs, but it's very conservative - it will never remove or change anything, it will only add new things, such as new columns, constraints or indexes. If an index or constraint already exists with the same name, Hibernate will leave it as it is rather than attempt to redefine it.

This is helpful to allow for customisation, but it means that over time the actual schema can slowly drift away from what it should be. This can manifest itself as columns being nullable when they shouldn't be (or vice versa), missing indexes or constraints, and so on. This can lead to bugs and/or poor performance.

To try and mitigate this, Confluence executes the SchemaComparisonService on startup, which generates a report on how the actual database schema (i.e. tables, indexes, constraints, etc) differs from Hibernate's expected view of that data. This report is then logged to the atlassian-confluence.log. No further action is taken, the information is purely advisory that something might be wrong.

While this is an improvement, it's still pretty conservative, and doesn't generate any warnings when it finds something (e.g. a database index or constraint) that it doesn't recognise. This is because databases decorate tables with their own indexes and constraints as part of their internal plumbing, and reporting them would be a false positive.

Here is an example report:

2014-12-14 19:07:49,320 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Database schema is inconsistent with expectations - %s warnings, see below
2014-12-14 19:07:49,320 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Index [sp_comp_idx] of table [spacepermissions] has mismatched definitions for expected [Index spacepermissions.sp_comp_idx on [permtype, permgroupname] non-unique] and actual [Index spacepermissions.sp_comp_idx on [permtype, permgroupname, permusername] non-unique]
2014-12-14 19:07:49,320 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [labelid] of table [content_label] has mismatched definitions for expected [Column content_label.labelid int8 non-nullable] and actual [Column content_label.labelid int8(19) nullable]
2014-12-14 19:07:49,321 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [username] of table [logininfo] has mismatched definitions for expected [Column logininfo.username varchar(255) non-nullable] and actual [Column logininfo.username varchar(255) nullable]
2014-12-14 19:07:49,321 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [buildnumber] of table [confversion] has mismatched definitions for expected [Column confversion.buildnumber int4 non-nullable] and actual [Column confversion.buildnumber int4(10) nullable]
2014-12-14 19:07:49,321 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [cp_type] of table [content_perm] has mismatched definitions for expected [Column content_perm.cp_type varchar(10) non-nullable] and actual [Column content_perm.cp_type varchar(10) nullable]
2014-12-14 19:07:49,321 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [follower] of table [follow_connections] has mismatched definitions for expected [Column follow_connections.follower varchar(255) nullable] and actual [Column follow_connections.follower varchar(255) non-nullable]
2014-12-14 19:07:49,322 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [followee] of table [follow_connections] has mismatched definitions for expected [Column follow_connections.followee varchar(255) nullable] and actual [Column follow_connections.followee varchar(255) non-nullable]
2014-12-14 19:07:49,364 WARN [main] [core.persistence.schema.StartupSchemaChecker] handleWarnings Column [public_key_id] of table [trustedapp] has mismatched definitions for expected [Column trustedapp.public_key_id int8 non-nullable] and actual [Column trustedapp.public_key_id int8(19) nullable]

ソリューション

Each warning indicates a different condition. Some may need to be treated, whereas others can be safely ignored. Because each will have a different workaround, and will need to be fixed in a different way, we have elected to create individual bug reports for each warning. Please see the bugs below to find your warnings and the mitigation steps for each. If you do not see the warning you are receiving below, please feel free to contact Support. We can advise you on the suggested course of action, and raise a bug report.

キー 要約 T 作成日 更新日 期限 担当者 報告者 P ステータス ソリューション
Loading...
Refresh

 

最終更新日 2017 年 4 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.