Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data too long for column 'commit_sha' at row 1 #14545

Closed
3 of 6 tasks
leo-unglaub opened this issue Feb 2, 2021 · 13 comments · Fixed by #14604
Closed
3 of 6 tasks

Data too long for column 'commit_sha' at row 1 #14545

leo-unglaub opened this issue Feb 2, 2021 · 13 comments · Fixed by #14604
Labels
Milestone

Comments

@leo-unglaub
Copy link

leo-unglaub commented Feb 2, 2021

  • Gitea version (or commit ref): 1.13.1
  • Git version:2.30.0
  • Operating system: OpenBSD, used from ports
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No

Description

When importing a database backup i get the following error message:

Data too long for column 'commit_sha' at row 1

The backup was generated on the same gitea version using the following command converting it from sqlite to mysql:

gitea dump --database mysql -c app.ini

At the time of the issue the table looked like this:

CREATE TABLE `comment` (
	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
	`type` INT(11) NULL DEFAULT NULL,
	`poster_id` BIGINT(20) NULL DEFAULT NULL,
	`original_author` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`original_author_id` BIGINT(20) NULL DEFAULT NULL,
	`issue_id` BIGINT(20) NULL DEFAULT NULL,
	`label_id` BIGINT(20) NULL DEFAULT NULL,
	`old_project_id` BIGINT(20) NULL DEFAULT NULL,
	`project_id` BIGINT(20) NULL DEFAULT NULL,
	`old_milestone_id` BIGINT(20) NULL DEFAULT NULL,
	`milestone_id` BIGINT(20) NULL DEFAULT NULL,
	`assignee_id` BIGINT(20) NULL DEFAULT NULL,
	`removed_assignee` TINYINT(1) NULL DEFAULT NULL,
	`assignee_team_id` BIGINT(20) NOT NULL DEFAULT '0',
	`resolve_doer_id` BIGINT(20) NULL DEFAULT NULL,
	`old_title` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`new_title` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`old_ref` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`new_ref` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`dependent_issue_id` BIGINT(20) NULL DEFAULT NULL,
	`commit_id` BIGINT(20) NULL DEFAULT NULL,
	`line` BIGINT(20) NULL DEFAULT NULL,
	`tree_path` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`content` TEXT NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`patch` TEXT NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`created_unix` BIGINT(20) NULL DEFAULT NULL,
	`updated_unix` BIGINT(20) NULL DEFAULT NULL,
	`commit_sha` VARCHAR(40) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`review_id` BIGINT(20) NULL DEFAULT NULL,
	`invalidated` TINYINT(1) NULL DEFAULT NULL,
	`ref_repo_id` BIGINT(20) NULL DEFAULT NULL,
	`ref_issue_id` BIGINT(20) NULL DEFAULT NULL,
	`ref_comment_id` BIGINT(20) NULL DEFAULT NULL,
	`ref_action` SMALLINT(6) NULL DEFAULT NULL,
	`ref_is_pull` TINYINT(1) NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `IDX_comment_issue_id` (`issue_id`) USING BTREE,
	INDEX `IDX_comment_created_unix` (`created_unix`) USING BTREE,
	INDEX `IDX_comment_updated_unix` (`updated_unix`) USING BTREE,
	INDEX `IDX_comment_ref_repo_id` (`ref_repo_id`) USING BTREE,
	INDEX `IDX_comment_type` (`type`) USING BTREE,
	INDEX `IDX_comment_review_id` (`review_id`) USING BTREE,
	INDEX `IDX_comment_ref_issue_id` (`ref_issue_id`) USING BTREE,
	INDEX `IDX_comment_ref_comment_id` (`ref_comment_id`) USING BTREE,
	INDEX `IDX_comment_poster_id` (`poster_id`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2034
;

The insert statement in question looks like this:

INSERT INTO `comment` (`id`, `type`, `poster_id`, `original_author`, `original_author_id`, `issue_id`, `label_id`, `old_project_id`, `project_id`, `old_milestone_id`, `milestone_id`, `assignee_id`, `removed_assignee`, `assignee_team_id`, `resolve_doer_id`, `old_title`, `new_title`, `old_ref`, `new_ref`, `dependent_issue_id`, `commit_id`, `line`, `tree_path`, `content`, `patch`, `created_unix`, `updated_unix`, `commit_sha`, `review_id`, `invalidated`, `ref_repo_id`, `ref_issue_id`, `ref_comment_id`, `ref_action`, `ref_is_pull`) VALUES (1758,11,25,'',0,530,0,NULL,NULL,0,0,0,false,0,NULL,'','','','',0,0,0,'','','',1591220008,1591220008,'feature/get-unit-and-store-it-in-the-database-version-2',0,false,0,0,0,0,false);

I am not sure why this column contains something that looks like a description instead of a hash, but thats what it tries to do. The system running on sqlite was always used as intended and never manupilated or anything else.

@lunny
Copy link
Member

lunny commented Feb 2, 2021

commit_sha was designered to store Git commit hash. hm

@leo-unglaub
Copy link
Author

Thats what i would have guessed as well. The only thing i noticed is that this always happens in rows where content = ''. Maybe this has something todo with it. The content in the commit_sha seams to be the name of the pull request that got mentioned in the text.

@lunny lunny added the type/bug label Feb 2, 2021
@leo-unglaub
Copy link
Author

Maybe this is helpful or a hint on whats going on.

grafik

@jpraet
Copy link
Member

jpraet commented Feb 2, 2021

The comment for deleting a branch stores the branch name instead of commit_sha:

gitea/models/issue.go

Lines 747 to 753 in d3aa497

var opts = &CreateCommentOptions{
Type: CommentTypeDeleteBranch,
Doer: doer,
Repo: repo,
Issue: issue,
CommitSHA: branchName,
}

@zeripath
Copy link
Contributor

zeripath commented Feb 2, 2021

@jpraet that looks like it would be the cause.

Ok I guess the question is where should the branch name be stored...

@lunny lunny added this to the 1.13.3 milestone Feb 4, 2021
zeripath added a commit to zeripath/gitea that referenced this issue Feb 7, 2021
lunny added a commit that referenced this issue Feb 8, 2021
Fix #14545

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
@richmahn
Copy link
Contributor

richmahn commented Feb 10, 2021

@lunny You removed the back port label from the PR, but will this issue be back ported? Still shows the label here.

@zeripath
Copy link
Contributor

The issue is the migration really. Could make a doctor command to fix it?

@zeripath
Copy link
Contributor

OK if we were to attempt to backport this we'd have to adjust the v169.go migration to only run if the commit_sha != '' otherwise any fixed delete branch comments would get overridden.

So that would mean an additional PR to fix this along with additional doctor commands and or clever template manipulation to make things work.

@6543
Copy link
Member

6543 commented Feb 11, 2021

I think this in any case require a manual step, so backport will be breaking regardles what we do

manipulating template would only break custom templates so if we realy want to backport, we should add more logic to the template

@6543 6543 modified the milestones: 1.13.3, 1.14.0 Feb 11, 2021
@zeripath
Copy link
Contributor

we'd still need a PR on to master to change the migration.

@6543
Copy link
Member

6543 commented Feb 11, 2021

didn't we already have it in #14604 ?!?

the "UPDATE comment SET old_ref = commit_sha, commit_sha = '' WHERE type = 11" ?

@zeripath
Copy link
Contributor

that would need to become

"UPDATE comment SET old_ref = commit_sha, commit_sha = '' WHERE type = 11 AND commit_sha != ''"

@6543
Copy link
Member

6543 commented Feb 11, 2021

yes if we really going to backport it ...

@go-gitea go-gitea locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants