Comments (11)
Maybe option #1, the sleep, and just going into a hover pattern is good enough (combined with increased limit/offset to search deeper). But doesn't really feel right.
from tokenserver.
Are these downed nodes ever going to come back, or are they permanently decommissioned? We want to make sure we don't abandon them permanently in a state where we'll never try to delete the data, but will leave the data hanging around on a node somewhere. If the node is never coming back, we should delete the old records in the db.
I think what you propose here seems fine, don't select them in the first place if we're going to ignore them. We'd have to double-check for other callers of this method to ensure they won't be impacted, but I think it's mostly tests and we can adjust as needed.
from tokenserver.
IIUC the sleep
option might result in just selecting the same set of downed rows over and over again, until some new rows get marked as replaced and become available for cleanup. This in turn would risk ignoring older replaced rows that happen to be "hidden behind" the downed ones.
from tokenserver.
Are these downed nodes ever going to come back, or are they permanently decommissioned?
I don't know right now, but was going to check tomorrow with Erik. It was all the same node.
from tokenserver.
We'd have to double-check for other callers of this method to ensure they won't be impacted, but I think it's mostly tests and we can adjust as needed.
Yeah, I haven't actually written this as a patch and I'll probably have to adjust tests. Question: are there "external" users of this module?
from tokenserver.
IIUC the sleep option might result in just selecting the same set of downed rows over and over again, until some new rows get marked as replaced and become available for cleanup. This in turn would risk ignoring older replaced rows that happen to be "hidden behind" the downed ones.
Yeah, good point. It could get in a state where it was always working (of punting) on the head of the result set, and never reaching into the backlog.
from tokenserver.
Question: are there "external" users of this module?
Note that I know of.
from tokenserver.
Hrm. How does one use with_hint
in our SQLAlchemy sql.py code? Because I can't just make the use index
change I suggested above (tests fail on that syntax).
from tokenserver.
So, I tried this as a simple test of using mysql hints:
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String, BigInteger, Index
from sqlalchemy.sql import select, text as sqltext
engine = create_engine('mysql://root@localhost/test')
conn = engine.connect()
meta = MetaData()
users = Table(
'users',
meta,
Column('uid', BigInteger, primary_key = True),
Column('service', Integer),
Column('email', String(255)),
Column('replaced_at', BigInteger),
)
Index('replaced_at_idx', users.c.service, users.c.replaced_at)
meta.create_all(engine)
query = sqltext('uid, service, replaced_at from users')
stmt = select([query])
stmt = stmt.with_statement_hint('use index (replaced_at_idx)', dialect_name='mysql')
stmt = stmt.where(sqltext('service = 1'))
res = conn.execute(stmt).fetchall()
for row in res:
print row
and I get:
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, "You have an
error in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near 'use index (replaced_at_idx)' at line 2")
[SQL: SELECT uid, service, replaced_at from users
WHERE service = 1 use index (replaced_at_idx)]
Notice that it simply appends the use index
to the end of the query. But I don't grok the documentation for how to use this (and possibly this feature just doesn't work since the sqlalchemy tests do not test for a select with a where clause).
from tokenserver.
Using with_hint
seems to do the job for me, e.g.:
select([users.c.uid, users.c.service, users.c.replaced_at]).with_hint(users, "USE INDEX (replaced_at_idx)", dialect_name="mysql")).where(users.c.service == 1)
IIUC you have to use this variant which accepts the users
table as a additional argument, so that it knows to attach the hint to the appropriate table in the select clause.
from tokenserver.
Thanks. Hmm, I had tried with_hint
, but not with the users.c.*
syntax. I'll work with that to create a patch.
from tokenserver.
Related Issues (20)
- Consider switching UID generation to random number rather than autoincrement value HOT 1
- Convert TokenServer to rust
- Upgrade PyFxA and add tests to confirm that fxa-generation fields are correctly handled. HOT 1
- Cannot build loadtest on 1.5.6 HOT 3
- Cannot start 1.5.6 docker container (ContextualVersionConflict cffi) HOT 11
- CryptographyDeprecationWarning for openssl
- Create a new release with only the pypy upgrade HOT 6
- Figure out caching story for OAuth JWK request HOT 2
- Use sane metric library HOT 1
- Browser id removal - confirm what caused the CPU spike. HOT 2
- Figure out how to include JWT OAuth tokens in the loadtest
- Modify CircleCI config to avoid rate limiting. HOT 1
- Allow specifying the Makefile's python interpreter
- Add Sentry Configuration HOT 2
- Upgrade docker to debian buster
- Travis CI free usage ends Dec 3; mozilla repos should switch to other CI platforms
- Update requirement for Python 3.10
- Makefile:40: local/.install.stamp] Error 137
- how to run docker mozilla/tokenserver?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokenserver.