Open timvaillancourt opened 2 weeks ago
A bit unrelated, but maybe time to fix this too:
ReadInstanceClusterAttributes(ctx context.Context, primaryHost string, primaryPort int)
and
ReadReplicaInstances(ctx context.Context, primaryHost string, primaryPort int) ([]*Instance, error)
..should just use a *topodatapb.TabletAlias
of the primary, but FullStatus
doesn't include it, so VTOrc doesn't have it in the backend database
Related to this, it seems we have no indices on hostname
and port
(but we sometimes query/join on it) - I'm on the fence if I should add that index or fix it properly now (return/store alias
of the primary)
cc @GuptaManan100 for 💡s
I like the idea of the RFC, just one thing I'd like to correct.
but FullStatus doesn't include it, so VTOrc doesn't have it in the backend database
This is not true. We have all the information that we store in a tablet record in vitess_tablet
table. Look at SaveTablet
for more information. We store the entire tablet record by marshaling it from proto into string. We also store individual fields that we deem worthy of reading without needing to deserialize the marshalled proto string. We store the alias as a string, and the cell in the table. If we want, we can also store the UID, and that gives us all the infomration to construct the *topodatapb.TabletAlias
back. (We can still do that by unmarshaling the info
field, but we can store uid explicitly too).
A refactor that makes things more testable is always welcome! I have always thought that the way VTOrc DB code is written was a little bit hard to test. I had introduced an interface for testing before as well. It is present in db.go
-
type DB interface {
QueryVTOrc(query string, argsArray []any, onRow func(sqlutils.RowMap) error) error
}
but your proposal is way better.
This is not true. We have all the information that we store in a tablet record in
vitess_tablet
table. Look atSaveTablet
for more information.
@GuptaManan100 great, good to know! Another refactor I'd like to do is stop using the unindexed hostname
and port
columns in queries. I assume those were indexed but they aren't anymore. It seems hostname
/port
is used to join to the primary tablet in some cases, so I thought alias just wasn't available and we were stuck
If we JOIN
on the primary alias there would be an index
We store the alias as a string, and the cell in the table.
To be clear, I mean storing the alias of each tablet's current primary. I'll review where it's available
Feature Description
This RFC proposes a new golang interface is added to
go/vt/vtorc/db
to allow:go/vt/vtorc/logic
has some database logic in itThe move to this would involve:
type DB interface
I've done a quick scan over the code, and I probably missed something, but here is a rough draft interface that should support the existing code. There are some small tweaks such as:
struct
s*topodatapb.TabletAlias
vs the opinionatedtabletAlias string
ctx context.Context
to everythingcc @GuptaManan100 for thoughts 🙇
Rough draft:
Use Case(s)
Developers and indirectly users of vtorc