Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions db/migrations/postgres/000092_add_pin_namespace.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE pins DROP COLUMN namespace;
COMMIT;
5 changes: 5 additions & 0 deletions db/migrations/postgres/000092_add_pin_namespace.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE pins ADD COLUMN namespace VARCHAR(64);
UPDATE pins SET namespace = 'ff_system';
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added a migration_consideration tag, as we've chosen ff_system really only because it's a reserved namespace name that can be used to query these values back (definitely not because these pre-upgrade pins were all for the ff_system namespace).

So we should document that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, originally I was going to leave it blank but then realized the API would give you no way to query them (and that seemed bad).

Pins were treated as "global" in 1.0, and the aggregator loop that processes pins even logs them as if they are part of ff_system (see here), so it didn't feel terribly wrong to pick ff_system for this purpose. But it was always a bit inaccurate, as they are specific to a namespace even if they weren't treated that way.

Anyway, bit of a ramble but I agree we need to document it.

ALTER TABLE pins ALTER COLUMN namespace SET NOT NULL;
COMMIT;
1 change: 1 addition & 0 deletions db/migrations/sqlite/000092_add_pin_namespace.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE pins DROP COLUMN namespace;
2 changes: 2 additions & 0 deletions db/migrations/sqlite/000092_add_pin_namespace.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE pins ADD COLUMN namespace VARCHAR(64);
UPDATE pins SET namespace = "ff_system";
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should we update the indexes to have namespace as a dimension?

I've noticed we did that elsewhere when we introduced a namespace, and I guess it should help with isolation of performance considerations between namespaces in the case of a shared DB.

Copy link
Contributor

Choose a reason for hiding this comment

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

As part of answering this, I think it would be good to look at this code:

func (ag *aggregator) getPins(ctx context.Context, filter database.Filter, offset int64) ([]core.LocallySequenced, error) {
log.L(ctx).Tracef("Reading page of pins > %d (first pin would be %d)", offset, offset+1)
pins, _, err := ag.database.GetPins(ctx, filter)
ls := make([]core.LocallySequenced, len(pins))
for i, p := range pins {
ls[i] = p
}
return ls, err
}

If the event aggregator is to become namespace aware, then I would expect the filter passed into this function by the parent to include a namespace filter. I'm not sure if that's true today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, and I think this should be rolled into #855 where the aggregator becomes namespace-aware.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do that without introducing yet another migration file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, can do. We've said migrations aren't guaranteed to be stable in mainline (only between releases).

Copy link
Contributor Author

@awrichar awrichar Jun 13, 2022

Choose a reason for hiding this comment

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

See here

Loading