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

gaby: support local testing mode #52

Open
hyangah opened this issue Nov 6, 2024 · 8 comments
Open

gaby: support local testing mode #52

hyangah opened this issue Nov 6, 2024 · 8 comments
Assignees

Comments

@hyangah
Copy link
Contributor

hyangah commented Nov 6, 2024

Since CL 605576, gaby always needs database in Cloud.
For read-only features, we can do

cd internal/gaby; go run . -project <gcp-project-name> -firestoredb <devel|prod>

But it's tricky to locally test write functionalities (e.g. cron, etc)

We can consider to revive the local mode.

An alternative idea from @jba:

For read-only operations, use the database in Cloud.
For write-involving operations, write to the local database. That may be useful when we want to run new features or A/B testing against the production data without fully syncing the production database.

@randall77
Copy link
Contributor

It might be nice to have an overlay database package which is backed by the read-only devel db but does writes to the overlay db (and serves up those writes in response to subsequent reads).
Then when the test is over we just throw away the overlay db.

@jba
Copy link
Contributor

jba commented Nov 6, 2024

@randall77 That's better than what I was thinking, which is to adapt the code for 2 dbs.
However, why read from devel when we can read from prod?

@jba jba self-assigned this Nov 6, 2024
@jba
Copy link
Contributor

jba commented Nov 6, 2024

I'm going to write the overlay DB package as a fun distraction.

@hyangah
Copy link
Contributor Author

hyangah commented Nov 6, 2024

However, why read from devel when we can read from prod?

To read the data back written by the local instance. That is not in the prod by design. For example, let's say I added extra data to devel to improve the search page result. I want to visit the search page to check the extra data actually helps.

@randall77
Copy link
Contributor

The overlay DB would just be a local, in-memory database. If you added extra data to it, it would be accessible just by that instance of the Oscar process. So search on that instance would get the additional data, but search on a separate instance also pointed at devel (or also pointed at prod) wouldn't.

@jba
Copy link
Contributor

jba commented Nov 6, 2024

My implementation (https://go-review.googlesource.com/c/oscar/+/626002) always reads and writes from different DBs.

I suppose we want to write to A but read from A first and then B if not found. The problem is, if you delete, you want to observe the deletion. That requires some sort of persistent tombstone in the general case. If the overlay is always in-memory, though, that is easy.

My problem with it being in-memory is that you can't easily inspect it ad-hoc, as with internal/devtools/cmd/dbedit. You have to write code or an HTML endpoint to get its contents.

@randall77
Copy link
Contributor

That requires some sort of persistent tombstone in the general case.

Just keep a set of deleted keys as part of the overlay DB?
Could just be a [][]byte that contains all the deleted keys. Check them all each time. Or convert them to strings and put them in a map.

My problem with it being in-memory is that you can't easily inspect it ad-hoc, as with internal/devtools/cmd/dbedit. You have to write code or an HTML endpoint to get its contents.

True.

@randall77
Copy link
Contributor

It's just a test database - always expose an HTML endpoint for it, at a known high port #?

gopherbot pushed a commit that referenced this issue Nov 8, 2024
Implement a DB that overlays an in-memory DB on top of another
DB (the "base").

Reads happen first on the overlay, then the base.
Writes only happen to the overlay.

For #52.

Change-Id: I60bf9c8ec34319ca52b73145711620103a22e7e6
Reviewed-on: https://go-review.googlesource.com/c/oscar/+/626002
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
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

No branches or pull requests

3 participants