Comments (5)
@Hu1-Li I see where this issue is coming from. Ordering the links by created_at desc and then picking the top link as latest will cause this. As for high load websites with many concurrent requests at a time will have many rows with the same created_at time. Wrong ordering is causing while loop and eventually select
queries in MySQL to execute many more times than expected.
This can be fixed by ordering by id
instead of created_at
in latest_default_link
method.
I am bit busy right now, I will fix and test this when I get some time. Would you like to make necessary changes and the above tests and open a PR?
from pygmy.
OK, I will try.
from pygmy.
Update:
[USING MYSQL]
In my test on the fixed code, which change ordering from created_at
to id
, the test comes with A99
, then it got stucks. As expect, the next short code should be Baa
, as the below line
link_manager.find(short_code=base_str)
it got baa
In Mysql, String compare is case-insensitive, thus, causing the server down ,since it needs to loop a really big cycle, from baa
to A99
then starts over and over again.
So when creating table, the field short_code
should be
short_code
varchar(10) COLLATE utf8_bin DEFAULT NULL,`
In SQLAchemy, This can be achieved by
short_code = Column(Unicode(6, collation="utf8_bin"), unique=True, index=True, default=None)
from pygmy.
Pull request #17 fixes this problem, As for test, i get no idea how to achieve the test for the above problem @amitt001
// Update
For sqlite, it should be
Column(Unicode(6, collation="BINARY"), unique=True, index=True, default=None)
For mysql, it should be
Column(Unicode(6, collation="utf8_bin"), unique=True, index=True, default=None)
emmmm,
from pygmy.
Fixed in commit: 67260ba
@Hu1-Li Thanks for fixing this bug and contributing 🍰
from pygmy.
Related Issues (20)
- Make website responsive and mobile friendly HOT 3
- Handle duplicate custom link error gracefully
- Add support for secret link stats HOT 1
- Add docker support and publish the image to hub HOT 3
- Feature request - randomised ids
- Disable Vanity HOT 2
- Secure the homepage to prevent access from outside HOT 1
- Link with an expiry time, shown as expired = False on dashboard even after expiry time
- When logged in user's token is expired, automatically logout the user
- Improve logging for raw and docker run
- Feature Request - Simplified Flask Implementation HOT 2
- Show country with country code on URL stats page HOT 1
- Improve "Already shortened URL" message HOT 1
- Feature Request - Word-specific URLs
- How to migrate DB? HOT 3
- 400: Malicious Attacks HOT 4
- python3 run.py: infinite loop
- Production config files example HOT 1
- changing shorturl direction link
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 pygmy.