-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: Syncstorage inital sqlite support #1520
base: master
Are you sure you want to change the base?
Conversation
To pass the checks I have the choice between upgrading diesel or ignoring the issue with libsqlite-sys (which tbh is probably a non-issue because we should not be using SQLite printf anyway). |
1047197
to
9d83956
Compare
6927869
to
62774e3
Compare
62774e3
to
5ea3b39
Compare
I choose to ignore the libsqlite3-sys CVE because it's not impacting this project. That should let me run the other tests in the CI. |
clippy_sqlite: | ||
# Matches what's run in circleci | ||
cargo clippy --workspace --all-targets --no-default-features --features=syncstorage-db/sqlite,tokenserver-db/sqlite -- -D warnings | ||
|
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 don't know if you saw #1513, but one of the things we're trying to do is to pull more of tokenserver into syncstorage-rs.
(Weird history lesson: Tokenserver was supposed to support more than just sync, but that never really happened. Having it distinct turned out to be a headache for a lot of reasons, so we're folding as much of Tokenserver as we can into the main syncstorage)
As a side note, this also means that the tokenserver storage stuff can probably live along-side the syncstorage data fairly easily. Possibly as just a bunch of other tables.
It's a bit more complicated for us since we have yet to migrate tokenserver over to spanner, but that's on our internal roadmap. When we get to doing that, however, is unknown.
We also have a few crate refactoring tickets open. I'll update those to indicate that we should really put the data handlers for both syncstorage and tokenserver into their own distinct crate.
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 did not saw that PR.
You want to remove tokenserver completely. Is that right ?
I don't understand what it means for my PR.
Should I change how I handle tokenserver ?
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 don't believe that it impacts much of your PR, since you're only focused on the Storage part. There may be a few opportunities for folk running their own "Stand Alone" version to have just one database running instead of two, and depending on how we decide to do this for Spanner, there may be some additional functions we introduce to the database layer. We'll try to isolate and highlight those so that we don't cause more work.
331d54f
to
cd814d9
Compare
I'm really jazzed about this PR, thanks for all the work on it! I noticed this in the PR desc:
If this is a question of building a Docker container from this codebase that bundles all the SQLite deps and nothing more, I'm happy to take on that work. |
Something like that yes. There might be some docker-compose configuration files to make too. That would leave me to clean up my code |
Sounds good, I'll give it a shot! |
Okay, I think I've got something approximately working in Eragonfr/syncstorage-rs@syncstorage-sqlite...bcspragu:syncstorage-rs:syncstorage-sqlite E.g. docker build -t mozsync-sqlite --build-arg DATABASE_BACKEND=sqlite .
# The --userns line is a rootless Podman thing, can be ignored mostly
docker run --rm -it \
--userns=keep-id:uid=10001,gid=10001 \
-v $PWD/temp-data-do-not-submit:/data \
-e "SYNC_HOST=0.0.0.0" \
-e "SYNC_MASTER_SECRET=secret0" \
-e "SYNC_SYNCSTORAGE__DATABASE_URL=sqlite:///data/syncdb.sqlite" \
-e "SYNC_TOKENSERVER__DATABASE_URL=sqlite:///data/tokenserverdb.sqlite" \
-e "SYNC_TOKENSERVER__RUN_MIGRATIONS=true" \
mozsync-sqlite Seems to start up successfully, but I'm not brave enough to connect it to my real Firefox sync yet |
Thanks @bcspragu ! |
For sure! Also, looking at the current syncstorage-rs/.circleci/config.yml Line 67 in 4a503f8
Not sure what the team would prefer here, but there's two options:
Unrelated, one thing I forgot to mention is that regardless of which features are enabled, MySQL client libs are required on the host (e.g. there are places where it isn't gated behind the feature flag, it gets linked in regardless). I started adding the relevant |
I thought of dropping the default flags because the user should choose their storage backend instead of relying on a default one. We want to have the proper |
63942fe
to
f781fc2
Compare
5e2b64c
to
22d3aaf
Compare
The ci fails on sqlite e2e tests. I think it is because the /data/ folder is missing, which means that the database can't be created and that makes the ci to fail. The checks are unrelated and are probably failing on the master branch too. |
🤦♀️ I'm dumb the e2e tests can't work because they require a connection to the database from the python script and syncserver at the same time. Which is not possible with sqlite. |
7ca1578
to
1c08e86
Compare
Hi @Eragonfr , thanks for your hard work! I am trying to get this to run locally, but I can't execute this query against the token database, because the database file is empty. Am I doing something wrong? Could you try running the server with a missing token database and check if the server correctly sets it up? Thanks again! I am really looking forward to this! |
@JulianWgs I also have the issue. I think that I broke the auto migration when doing some refactor. EDIT: Can't reproduce that bug anymore… wtf |
ff5be44
to
a8dda23
Compare
I GOT THE TESTS TO RUN!!! Also, none of them failed. |
Finger crossed… this might fail because of python and test lib version mismatch |
2fb4432
to
2264ead
Compare
74cf7fd
to
c3cabd5
Compare
c3cabd5
to
d5b8203
Compare
d5b8203
to
7940055
Compare
Oops… the
|
db5b1dc Will fail I haven't managed to get the ORM system to work exactly as needed to pass the tests |
There are three errors, one that shows in all e2e tests, one in the checks and one in the SQLite one:
Traceback (most recent call last):
File "/app/tools/integration_tests/run.py", line 11, in <module>
from tokenserver.run import run_end_to_end_tests, run_local_tests
File "/app/tools/integration_tests/tokenserver/run.py", line 6, in <module>
from tokenserver.test_authorization import TestAuthorization
File "/app/tools/integration_tests/tokenserver/test_authorization.py", line 5, in <module>
from tokenserver.test_support import TestCase
File "/app/tools/integration_tests/tokenserver/test_support.py", line 28, in <module>
from tokenserver.tables import Users, Nodes, Services
File "/app/tools/integration_tests/tokenserver/tables.py", line 1, in <module>
from sqlalchemy import Integer, String, Null, BigInteger, Index
ImportError: cannot import name 'Null' from 'sqlalchemy' (/usr/local/lib/python3.9/dist-packages/sqlalchemy/__init__.py) As far as I can see it the used SQLAlchemy version does not have a type called Maybe that's already it?
Does the patch upgrade from
Might this be to a read-only filesystem on the CI runner? To the contrary, the databases in the other tests boot up just fine. |
Interesting, this one might be related to version mismatch between my dev env and our test env I think.
I already knew that
docker FS is not read only |
Description
Re-implementation of #935 on the newer codebase.
Thanks for @mqus for the first implementation.
Issue(s)
Partially fixes #498
Todo
Current state is that it runs on my computer, but it's probably not clean at all, there's still a lot of duplicate code, and some SQL queries are still in MySQL-flavored SQL but could be used by the SQLite backend.