Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Conversation

@emidoots
Copy link
Member

In our DB testing code we make an assumption that we can run all database migrations against a single testing database. This holds true for frontend and codeintel migrations, because we intentionally designed codeintel migrations to be ran in the same DB for testing/dev purposes only - but this does not hold true for Code Insights which runs a separate TimescaleDB instance (it is easier to run it separately in Docker than install it as a Postgres extension in all of our dev/testing environments.)

This change merely makes it so we don't run TimescaleDB migrations against our singleton testing/dev Postgres DB.

Signed-off-by: Stephen Gutekanst stephen@sourcegraph.com

@emidoots emidoots requested review from asdine and efritz January 22, 2021 22:54
@emidoots emidoots mentioned this pull request Jan 22, 2021
27 tasks
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Jan 22, 2021

Notifying subscribers in CODENOTIFY files for diff e45ae86...5fb7f14.

Notify File(s)
@asdine internal/database/dbconn/migration.go
@beyang enterprise/cmd/precise-code-intel-worker/main.go
@efritz enterprise/cmd/frontend/internal/codeintel/services.go
enterprise/cmd/precise-code-intel-worker/main.go
internal/database/dbconn/migration.go
internal/database/dbtest/dbtest.go
internal/database/dbtesting/dbtesting.go
internal/database/schemadoc/main.go

@emidoots emidoots added code-insights Issues related to the Code Insights product team/internal-contributor labels Jan 22, 2021
@emidoots emidoots added this to the 3.25 milestone Jan 22, 2021
@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #17585 (5fb7f14) into main (e45ae86) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main   #17585      +/-   ##
==========================================
- Coverage   51.53%   51.53%   -0.01%     
==========================================
  Files        1717     1717              
  Lines       85401    85390      -11     
  Branches     7709     7709              
==========================================
- Hits        44013    44003      -10     
+ Misses      37511    37509       -2     
- Partials     3877     3878       +1     
Flag Coverage Δ *Carryforward flag
go 50.40% <0.00%> (-0.01%) ⬇️
integration 30.72% <ø> (ø) Carriedforward from e45ae86
storybook 30.62% <ø> (ø) Carriedforward from e45ae86
typescript 54.24% <ø> (ø) Carriedforward from e45ae86
unit 34.60% <ø> (ø) Carriedforward from e45ae86

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
cmd/frontend/internal/cli/serve_cmd.go 1.60% <0.00%> (ø)
internal/database/dbconn/migration.go 0.00% <0.00%> (-17.40%) ⬇️
.../internal/codeintel/resolvers/graphql/locations.go 83.50% <0.00%> (-2.07%) ⬇️

Copy link
Contributor

@efritz efritz left a comment

Choose a reason for hiding this comment

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

Would it be a better solution to separate postgres from the code intel database rather than making exclusions to new things (that are probably more probably likely to act like code insights database than a code intelligence database)?

@emidoots
Copy link
Member Author

@efritz Im not sure I understand what you mean exactly, can you elaborate?

@efritz
Copy link
Contributor

efritz commented Jan 25, 2021

Should we also separate Postgres and codeintel-db here? Instead of making timescale the odd one out, we can make the main "Postgres" db less of a "main" store and all three dbs would have equal tooling.

@emidoots
Copy link
Member Author

emidoots commented Jan 25, 2021

Ahh, got it. I do think that is something we should do, I'll take a stab at that.

…base

In our DB testing code we make an assumption that we can run all database
migrations against a single testing database. This holds true for frontend
and codeintel migrations, because we intentionally designed codeintel
migrations to be ran in the same DB for testing/dev purposes - but this
does not hold true for Code Insights which runs a separate TimescaleDB
instance (it is easier to run it separately in Docker than install it as
a Postgres extension in all of our dev/testing environments.)

This change merely makes it so we don't run TimescaleDB migrations against
our singleton testing/dev Postgres DB.

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
@emidoots emidoots force-pushed the sg/insights-dbtesting branch from 1167cdb to 600a856 Compare January 25, 2021 22:46
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
@emidoots
Copy link
Member Author

@efritz PTAL, I think this is likely a better step in the right direction?

for _, database := range []*dbconn.Database{
dbconn.Frontend,
dbconn.CodeIntel,
} {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: Still using a few lists like this in some places to use "the same DB for frontend and codeintel" but I will start fixing that in subsequent PRs where I aim to add code-insights-equivilents to these locations.

For now, it at least makes this "we use multiple DBs here which is kinda clunky" clear & explicit

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this is worlds better than tacking a third one on and doing retroactive edge case fixes.

Copy link
Contributor

@efritz efritz left a comment

Choose a reason for hiding this comment

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

Ain't no confusion here!

for _, migrationTable := range dbconn.MigrationTables {
conds = append(conds, fmt.Sprintf("table_name != '%s'", migrationTable))
}
conds = append(conds, fmt.Sprintf("table_name != '%s'", dbconn.Frontend.MigrationsTable))
Copy link
Contributor

Choose a reason for hiding this comment

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

lol but what if code intel wants a legit table named codeinsights_schema_migrations????

@efritz
Copy link
Contributor

efritz commented Jan 26, 2021

Thanks for the effort here, @slimsag! Separating the codeintel db and the frontend db is a very very low priority at this point as it only affects dev and we have checks on startup to ensure it doesn't actually happen.

This PR really minimizes additional muck so I think we can 🚀 with this guy now.

Stephen Gutekanst added 2 commits January 25, 2021 19:11
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Stephen Gutekanst added 4 commits January 26, 2021 20:04
@emidoots emidoots merged commit 7252a70 into main Jan 27, 2021
@emidoots emidoots deleted the sg/insights-dbtesting branch January 27, 2021 08:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

code-insights Issues related to the Code Insights product slimsag-basic-scaffolding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants