-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
ui, sql: fix display of "database dropped" event. #24852
Conversation
10e58a2
to
e242d28
Compare
Could you make just the UI backwards compatible? It could test for the presence of either the old DroppedTables info field or the new DroppedSchemaObjects. |
Yeah, I'm a fan of @mrtracy's suggestion. I'd add that we should also handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way to make sure this sort of bug doesn't happen again? Can we write a test that breaks for someone if they change the schema without updating the UI?
pkg/ui/src/util/events.ts
Outdated
tableDropText = "No tables were dropped."; | ||
} else if (info.DroppedTables.length === 1) { | ||
tableDropText = `1 table was dropped: ${info.DroppedTables[0]}`; | ||
info.DroppedSchemaObjects = info.DroppedSchemaObjects || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this defensiveness suspicious. If we don't have an array here at all, doesn't that mean we just don't have the information? I'd be inclined to just not include the second sentence in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pkg/ui/src/util/events.ts
Outdated
if (info.DroppedSchemaObjects.length === 0) { | ||
tableDropText = "No schema objects were dropped."; | ||
} else if (info.DroppedSchemaObjects.length === 1) { | ||
tableDropText = `1 schema objects was dropped: ${info.DroppedSchemaObjects[0]}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar, or maybe just use pluralize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
e242d28
to
1b151d0
Compare
Made the UI backwards-compatible, per @mrtracy's suggestion, and added a JS unit test to show that it can handle all three formats. PTAL. However, don't know how to write a test that would fail if someone changes the key on the Go side, other than an integration test which uses both Go and JS. This is what protobufs are for — maybe the event info should be a protobuf, that's serialized as JSON into a column in the table, or something. This problem will come up again as we display richer data in the admin UI from other tables that have JSON in them, e.g. the range log. |
1b151d0
to
ca78f0d
Compare
The DROP_DATABASE event in `system.eventlog` was changed from having the key `DroppedTables` to having the key `DroppedTablesAndViews`. The corresponding UI code which displays the dropped tables was not changed, creating bug cockroachdb#18523. This commit fixes cockroachdb#18523 by renaming the key to `DroppedSchemaObjects`, both in the event and in the UI code. The term "Schema Objects" accounts for the existence of sequences in addition to views and tables. Release note (admin ui change): display the names of dropped schema objects on `DROP DATABASE ... CASCADE`
ca78f0d
to
d18eb07
Compare
} else if (droppedObjects.length === 1) { | ||
return `1 schema object was dropped: ${droppedObjects[0]}`; | ||
} | ||
return `${droppedObjects.length} schema objects were dropped: ${droppedObjects.join(", ")}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but your fancy pluralize thing!
bors r+ |
SettingName?: string; | ||
Value?: string; | ||
// The following are three names for the same key (it was renamed twice). | ||
// All ar included for backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ar/are/
Build failed (retrying...) |
24845: rpc: ConnHealth now kicks off a connection attempt r=tschottdorf a=bdarnell When #22658 changed ConnHealth to be pessimistic instead of optimistic, it meant that distsql could theoretically get stuck in a state without connections to the necessary nodes (distsql would never initiate connections on its own; it only attempts to use connections for which ConnHealth returns true so it was effectively relying on raft/kv to initiate these connections). Now ConnHealth will attempt to start a connection process if none is in flight to ensure that we will eventually discover the health of any address we are concerned about. Updated the ConnHealth docstring to reflect this change and the change to pessimistic behavior. Fixes #23829 Release note: None 24852: ui, sql: fix display of "database dropped" event. r=couchand a=vilterp The DROP_DATABASE event in `system.eventlog` was changed from having the key `DroppedTables` to having the key `DroppedTablesAndViews`. The corresponding UI code which displays the dropped tables was not changed, creating bug #18523. This commit fixes #18523 by renaming the key to `DroppedSchemaObjects`, both in the event and in the UI code. The term "Schema Objects" accounts for the existence of sequences in addition to views and tables. Q: is it worth adding a migration to change old events from `DroppedTablesAndViews` to `DroppedSchemaObjects`? I'm leaning toward no, since (a) it doesn't look like we added a migration when we renamed `DroppedTables` to `DroppedTablesAndViews`, and (b) without the migration, you'll still see the "drop database" event in the UI, just not the table names (but they'll be in `system.eventlog` under the old key). Release note (admin ui change): display the names of dropped schema objects on `DROP DATABASE ... CASCADE` Co-authored-by: Ben Darnell <[email protected]> Co-authored-by: Pete Vilter <[email protected]>
Build succeeded |
The DROP_DATABASE event in
system.eventlog
was changed from having the keyDroppedTables
to having the keyDroppedTablesAndViews
. The corresponding UI code which displays the dropped tables was not changed, creating bug #18523.This commit fixes #18523 by renaming the key to
DroppedSchemaObjects
, both in the event and in the UI code. The term "Schema Objects" accounts for the existence of sequences in addition to views and tables.Q: is it worth adding a migration to change old events from
DroppedTablesAndViews
toDroppedSchemaObjects
? I'm leaning toward no, since (a) it doesn't look like we added a migration when we renamedDroppedTables
toDroppedTablesAndViews
, and (b) without the migration, you'll still see the "drop database" event in the UI, just not the table names (but they'll be insystem.eventlog
under the old key).Release note (admin ui change): display the names of dropped schema objects on
DROP DATABASE ... CASCADE