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

Identical schema alterations results in two different columns with same tag error on merge #2335

Closed
liuqianhong6007 opened this issue Nov 3, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@liuqianhong6007
Copy link

liuqianhong6007 commented Nov 3, 2021

Using detached head mode, I try to merge branch but get an error two different columns with the same tag.
Executing SELECT * FROM dolt_conflicts get no rows.
And executing SELECT * FROM dolt_conflicts_mycolor also get no rows.

image

And in non detached head mode, it seems the same.

image

In fact the branch feature3 and main should have a conflict of column float_val

So is this a bug or is there problem of my operation ?

@liuqianhong6007 liuqianhong6007 changed the title Merging branch does't work in detach head mode Miss of conflict rows when merging branch failed Nov 3, 2021
@zachmu
Copy link
Member

zachmu commented Nov 3, 2021

This is probably a bug, but we need some more information.

Can you walk us through the steps that reproduce the problem?

@liuqianhong6007
Copy link
Author

This is probably a bug, but we need some more information.

Can you walk us through the steps that reproduce the problem?

  1. In branch main, create a new table named mycolor. It owns 3 columns.
CREATE TABLE `mycolor` (
  `color` varchar(50) NOT NULL,
  `desc` varchar(16383) NOT NULL,
  `value` smallint NOT NULL,
  PRIMARY KEY (`color`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

table rows:

liuqianhong@liuqianhongdeMac-mini game_server % dolt sql -q "select * from mycolor"
+-------+---------------------+-------+
| color | desc                | value |
+-------+---------------------+-------+
| green | This is green color | 20    |
| red   | This is red color   | 10    |
+-------+---------------------+-------+
  1. Create two branches named feature1 and feature2 based on main.
liuqianhong@liuqianhongdeMac-mini game_server % dolt branch
  feature1
  feature2
* main
  1. In branch feature1, modify mycolor table schema and some data as follows. It drops column desc, add column remark and float_val.
CREATE TABLE `mycolor` (
  `color` varchar(50) NOT NULL,
  `value` smallint NOT NULL,
  `remark` varchar(64) NOT NULL,
  `float_val` varchar(16383) NOT NULL,
  PRIMARY KEY (`color`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

table rows:

liuqianhong@liuqianhongdeMac-mini game_server % dolt sql -q "select * from mycolor"
+-------+-------+-----------------------+-----------+
| color | value | remark                | float_val |
+-------+-------+-----------------------+-----------+
| black | 200   | This is black color   | 200.01    |
| red   | 100   | This is new red color | 100.01    |
+-------+-------+-----------------------+-----------+
  1. In branch feature2, apply the same changes like step 3 but only table rows a little different. It has different float_val of 200.01 and 200.11
liuqianhong@liuqianhongdeMac-mini game_server % dolt sql -q "select * from mycolor"
+-------+-------+-----------------------+-----------+
| color | value | remark                | float_val |
+-------+-------+-----------------------+-----------+
| black | 200   | This is black color   | 200.11    |
| red   | 100   | This is new red color | 100.01    |
+-------+-------+-----------------------+-----------+
  1. Merge feature1 into main. It acts normal.
    dolt log as follows
liuqianhong@liuqianhongdeMac-mini game_server % dolt log
commit d66j4ul5qvh280dekg76h5vkuqhh38kt
Author: liuqianhong <549280405@qq.com>
Date:   Thu Nov 04 10:48:14 +0800 2021

	Merge branch feature1 into main

commit q0ncj6u0luptuhh3ofm1aeks8oor3cd1
Author: liuqianhong <liuqianhong@xmfunny.com>
Date:   Thu Nov 04 10:28:15 +0800 2021

	Update table mycolor

commit 3pvk7gb19r95u5s6l9gb18lv67evr9tp
Author: liuqianhong <549280405@qq.com>
Date:   Thu Nov 04 10:19:27 +0800 2021

	Merge branch dev into main

commit a1mml9lv6sso3bsgmc691o511g842mia
Author: liuqianhong <liuqianhong@xmfunny.com>
Date:   Thu Nov 04 10:19:20 +0800 2021

	Create table mycolor

commit sefqcma883geh0u5ft122otqc7t61doc
Author: liuqianhong <liuqianhong@xmfunny.com>
Date:   Thu Nov 04 10:18:05 +0800 2021

	Initialize data repository
  1. Merge feature2 into main. Now it is expected to get conflicts because there is a different row data between feature1 and feature2.
game_server> set @@game_server_head=HASHOF('feature2');
game_server> set @@game_server_head=MERGE('main');
two different columns with the same tag
game_server> select * from dolt_conflicts;
+-------+---------------+
| table | num_conflicts |
+-------+---------------+
+-------+---------------+
game_server> select * from dolt_conflicts_mycolor;
+-------------+------------+----------------+------------+------------+-----------+---------------+-----------+--------------+-------------+-----------------+-------------+
| base_remark | base_color | base_float_val | base_value | our_remark | our_color | our_float_val | our_value | their_remark | their_color | their_float_val | their_value |
+-------------+------------+----------------+------------+------------+-----------+---------------+-----------+--------------+-------------+-----------------+-------------+
+-------------+------------+----------------+------------+------------+-----------+---------------+-----------+--------------+-------------+-----------------+-------------+

@liuqianhong6007
Copy link
Author

This is probably a bug, but we need some more information.

Can you walk us through the steps that reproduce the problem?

Any update ?

@zachmu
Copy link
Member

zachmu commented Nov 10, 2021

Hi @liuqianhong6007,

The bug here is that error message: two different columns with the same tag. You will find the same problem if you run dolt merge feature2 on the command line, where it might be more obvious. There are no conflicts because the merge itself didn't go through, and the working set is unchanged.

This appears to be a bug in how we merge schemas. Dolt should consider the two tables, after identical schema changes, to be the same, but doesn't. I'm going to have someone look into this.

In the meantime, please make the schema change before branching, and your merge should work and pick up the data conflict as expected.

One additional note: you should generally use dolt_checkout and dolt_merge instead of setting @@game_server_head directly, unless you have some reason you need to be in detached head mode for your session. Are you following docs that told you to do it this way?

@zachmu zachmu changed the title Miss of conflict rows when merging branch failed Identical schema alterations results in two different columns with same tag error on merge Nov 10, 2021
@zachmu zachmu added the bug Something isn't working label Nov 10, 2021
@liuqianhong6007
Copy link
Author

liuqianhong6007 commented Nov 11, 2021

Thanks for your reply.

In the meantime, please make the schema change before branching, and your merge should work and pick up the data conflict as expected.

It indeed works if there are no schema change, but it does't suit my case because there are no acknowledge of schema change between two independent branches both based on main. Unless I fetch the latest main branch before every merging ?...

One additional note: you should generally use dolt_checkout and dolt_merge instead of setting @@game_server_head directly, unless you have some reason you need to be in detached head mode for your session. Are you following docs that told you to do it this way?

In the beginning, I definitely followed the the official docs to use dolt, but sometimes it didn't work, and there are some issues about dolt_FUNCTION, and it even made my working set dirty.

Then I found two blog dolt sql-server Concurrency and Merging and Resolving Conflicts Programmatically with SQL. It describes what I want.

The idea of wrapping complex logic into well-known function like git is great and the dolt_FUNCTION is in development. I choose the detached head mode instead of using dolt_FUNCTION due to the deadline of my work.

@timsehn
Copy link
Sponsor Contributor

timsehn commented Aug 30, 2022

The merge workflow has been improved a lot lately. You should not run into these issues again.

@timsehn timsehn closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants