Tag Archives: Failure

MySQL failed to add foreign key error 1452

MySQL failed to add foreign keys, error 1452
For example:
Two tables user table: User class table: Grade
Each user in the user table corresponds to a class ID, namely gradeId
Namely: The primary key of the User table gradeId is the Id in the Grade table
The user table is called the primary table and the Grade table is called the slave table
[SQL]

alter table user

Add Foreign Key (gradeId) References Grade (Id);  

[error]

ERROR 1452 : Cannot add or update a child row: a foreign key constraint fails

“Why”
Some gradeId in the User table do not belong to the ID in the Grade table
【 Solution 】
Modify the data so that all gradeId in the User table belong to ids in the Grade table

Git push failed, prompt unpack error / unpack failed solution

after you execute the command git commit -amend to amend the commit, then execute git push review HEAD:refs/for/ XXXX to submit the code to Gerrit, but the commit failed and print out the following prompt:

qidi.huang@droid10$ git push review HEAD:refs/for/xxxx

Writing objects: 100% (1/1), 258 bytes | 0 bytes/s, done.  
Total 1 (delta 0), reused 0 (delta 0)  
error: unpack failed: error Missing tree a0abf7e9827e74b7d729485fcd3714bc6a1ce898  
fatal: Unpack error, check server log  
To ssh://[email protected]:29418/kernel/common  
 ! [remote rejected] HEAD -> refs/for/xxxx (n/a (unpacker error))   

we can solve this problem by adding the --no-thin parameter to the submission. In other words, we can use the following command to submit:

$ git push --no-thin review HEAD:refs/for/xxxx

Git push –help) git push –help

--[no-]thin
    These options are passed to git-send-pack(1). A thin 
transfer significantly reduces the amount of sent data when 
the sender and receiver share many of the same objects in 
common. The default is --thin.

failure should be analyzed from the log of Gerrit server. I didn’t check the log (as if I didn’t have permission), but according to other colleagues, the problem may be “Gerrit is not compatible with git. This is because when Git is committed, an open review request is generated in Gerrit, but this request does not belong to any of the commits.

[reference]
[1] git flow and gerrit
[2] git push error: unpack failed: index-pack abnormal exit