tabletserver: SBR deprecation#5940
Conversation
It was not necessary, and was obfuscating the fact that it's wrapping TxEngine. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
There was an aspiration that applications will use an event token to validate how fresh a replica read was. The feature was neither very usable nor used by anyone. This has now been deleted. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
| qre := newTestQueryExecutor(ctx, tsv, tcase.input, 0) | ||
| _, err := qre.Execute() | ||
| wantErr := "caller id: d: row count exceeded 2 (errno 10001) (sqlstate HY000)" | ||
| if err == nil || err.Error() != wantErr { |
There was a problem hiding this comment.
nit: You could use
require.Error(t, wantErr)
There was a problem hiding this comment.
For some reason, assert didn't work. In any case, I had to change the test to use "Contains".
But assert.Contains can't check if an error contains a string, which is unfortunate.
| getModeSQL = "select @@global.sql_mode" | ||
| getAutocommit = "select @@autocommit" | ||
| getAutoIsNull = "select @@sql_auto_is_null" | ||
| showBinlog = "show variables like 'binlog_format'" |
There was a problem hiding this comment.
should we not verify bin log format. Now it has to be ROW.
There was a problem hiding this comment.
We still want to allow some legacy usage. People transitioning should be able to run SBR. RBR becomes a hard requirement only while resharding.
| var planName = [NumPlans]string{ | ||
| "PASS_SELECT", | ||
| "SELECT_LOCK", | ||
| "NEXTVAL", | ||
| "PASS_DML", | ||
| "DML_PK", | ||
| "DML_SUBQUERY", | ||
| "INSERT_PK", | ||
| "INSERT_SUBQUERY", | ||
| "UPSERT_PK", | ||
| "INSERT_TOPIC", | ||
| "INSERT_MESSAGE", | ||
| "SET", | ||
| "Select", | ||
| "SelectLock", | ||
| "Nextval", | ||
| "SelectImpossible", | ||
| "Insert", | ||
| "InsertTopic", | ||
| "InsertMessage", | ||
| "Update", | ||
| "UpdateLimit", | ||
| "Delete", | ||
| "DeleteLimit", | ||
| "DDL", | ||
| "SELECT_STREAM", | ||
| "OTHER_READ", | ||
| "OTHER_ADMIN", | ||
| "MESSAGE_STREAM", | ||
| "SELECT_IMPOSSIBLE", | ||
| "Set", | ||
| "OtherRead", | ||
| "OtherAdmin", | ||
| "SelectStream", | ||
| "MessageStream", | ||
| } |
There was a problem hiding this comment.
I believe this should not be renamed as this impacts the query stats naming. All metrics will get disjoint.
There was a problem hiding this comment.
This is a good time to rename everything uniformly because this has been announced as one of the breaking changes. People anyway have to deal with all the other new values already.
| flag.BoolVar(&Config.PassthroughDMLs, "queryserver-config-passthrough-dmls", DefaultQsConfig.PassthroughDMLs, "query server pass through all dml statements without rewriting") | ||
| flag.BoolVar(&Config.AllowUnsafeDMLs, "queryserver-config-allowunsafe-dmls", DefaultQsConfig.AllowUnsafeDMLs, "query server allow unsafe dml statements") | ||
| flag.BoolVar(&deprecateAllowUnsafeDMLs, "queryserver-config-allowunsafe-dmls", false, "deprecated") |
There was a problem hiding this comment.
what is the difference between pass through and unsafe dmls?
There was a problem hiding this comment.
Unsafe DMLs are those that were considered unsafe for SBR, like "insert on duplicate key", etc.
| ctx, tsv.QueryTimeout.Get(), | ||
| "CreateTransaction", "create_transaction", nil, | ||
| target, nil, true /* isBegin */, true, /* allowOnShutdown */ | ||
| target, nil, true, /* allowOnShutdown */ |
There was a problem hiding this comment.
for CreateTransaction method: should this be false?
There was a problem hiding this comment.
It either doesn't matter, or it's extremely important that it be true. Changing to false is likely risky without knowing why.
| // This used to be ResultExtras. | ||
| reserved 5; | ||
|
|
||
| repeated Field fields = 1; | ||
| uint64 rows_affected = 2; | ||
| uint64 insert_id = 3; | ||
| repeated Row rows = 4; |
There was a problem hiding this comment.
As this works, I believe ordering is not important.
There was a problem hiding this comment.
Better to follow the rules. Then we don't have to worry about corner cases.
| if err := qre.verifyRowCount(int64(len(qr.Rows)), maxrows); err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
Test exists for DML Limit. Not able to find a test for select limit.
There was a problem hiding this comment.
Good catch. I must have accidentally deleted an existing test.
| case planbuilder.PlanSelectImpossible: | ||
| if qre.plan.Fields != nil { | ||
| return &sqltypes.Result{ | ||
| Fields: qre.plan.Fields, | ||
| RowsAffected: 0, | ||
| InsertID: 0, | ||
| Rows: nil, | ||
| Extras: nil, | ||
| Fields: qre.plan.Fields, | ||
| }, nil | ||
| } | ||
| } |
There was a problem hiding this comment.
case planbuilder.PlanSelect, planbuilder.PlanSelectImpossible also exists below. Why "planbuilder.PlanSelectImpossible" is present in two switch statement?
There was a problem hiding this comment.
If the fields did not get cached, then we have to send the query to mysql. Added a comment.
| if qre.tsv.qe.enableConsolidator || (qre.tsv.qe.enableConsolidatorReplicas && qre.tabletType != topodatapb.TabletType_MASTER) { | ||
| q, original := qre.tsv.qe.consolidator.Create(string(sqlWithoutComments)) |
There was a problem hiding this comment.
consolidator is default to true and hence test does not go in else part. Can a test be added?
There was a problem hiding this comment.
This test requires creating a delay in query execution, which the test framework can't emulate. So, it's covered in the go/vt/vttablet/endtoend/misc_test.go.
| case *sqlparser.DDL: | ||
| plan, err = analyzeDDL(stmt, tables), nil | ||
| plan = &Plan{PlanID: PlanDDL} |
There was a problem hiding this comment.
This does not contain the DDL Query. Could you explain the reason for not adding the query?
There was a problem hiding this comment.
It's because the plan can only store ParsedQuery, but the parsed version of a DDL is incomplete. So, we use the original query at the time of execution. We could add a special-case field for DDLs, but it didn't feel worth it. I've added a comment.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Closes #5920
The planbuilder and query_executor were essentially rewritten. I had to make tweaks in a few other places to accommodate changes in behavior.