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

ui, sql: fix display of "database dropped" event. #24852

Merged
merged 1 commit into from
Apr 17, 2018

Conversation

vilterp
Copy link
Contributor

@vilterp vilterp commented Apr 16, 2018

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

@vilterp vilterp requested review from a team April 16, 2018 22:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@vilterp vilterp force-pushed the fix-drop-db-event branch from 10e58a2 to e242d28 Compare April 16, 2018 22:35
@vilterp vilterp requested a review from a team April 16, 2018 22:35
@mrtracy
Copy link
Contributor

mrtracy commented Apr 17, 2018

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.

@couchand
Copy link
Contributor

Yeah, I'm a fan of @mrtracy's suggestion. I'd add that we should also handle DroppedTablesAndViews since we shipped a version that's recording that, too.

Copy link
Contributor

@couchand couchand left a 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?

tableDropText = "No tables were dropped.";
} else if (info.DroppedTables.length === 1) {
tableDropText = `1 table was dropped: ${info.DroppedTables[0]}`;
info.DroppedSchemaObjects = info.DroppedSchemaObjects || [];
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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]}`;
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@vilterp vilterp force-pushed the fix-drop-db-event branch from e242d28 to 1b151d0 Compare April 17, 2018 18:54
@vilterp
Copy link
Contributor Author

vilterp commented Apr 17, 2018

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.

@vilterp vilterp force-pushed the fix-drop-db-event branch from 1b151d0 to ca78f0d Compare April 17, 2018 19:00
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`
@vilterp vilterp force-pushed the fix-drop-db-event branch from ca78f0d to d18eb07 Compare April 17, 2018 19:04
} else if (droppedObjects.length === 1) {
return `1 schema object was dropped: ${droppedObjects[0]}`;
}
return `${droppedObjects.length} schema objects were dropped: ${droppedObjects.join(", ")}`;
Copy link
Contributor

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!

@couchand
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ar/are/

@craig
Copy link
Contributor

craig bot commented Apr 17, 2018

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Apr 17, 2018
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]>
@craig
Copy link
Contributor

craig bot commented Apr 17, 2018

Build succeeded

@craig craig bot merged commit d18eb07 into cockroachdb:master Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: odd events log message when dropping database
4 participants