-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Precalculate expiry timestamp #14625
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
Conversation
dosten
commented
May 13, 2015
Q | A |
---|---|
Bug fix? | no |
New feature? | no |
BC breaks? | yes |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #13955 |
License | MIT |
Doc PR | - |
3.0.0 | ||
----- | ||
|
||
* PdoSessionHandler: removed the `lifetime` and `timestamp` columns in favor of `expiry` column |
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.
This would need to be added to the update file.
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've added more info in the UPGRADE-3.0.md
file, see above.
); | ||
$insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); | ||
$insertStmt->bindValue(':data', '', \PDO::PARAM_LOB); | ||
$insertStmt->bindValue(':lifetime', 0, \PDO::PARAM_INT); | ||
$insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); | ||
$insertStmt->bindValue(':expiry', time(), \PDO::PARAM_INT); |
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.
you can just put 0
here since this is only dummy data that will be updated by the write operation later anyway
@Tobion done |
|
||
- Rename the `sess_time` to `sess_expiry`. In MySQL this would be: | ||
``` | ||
ALTER TABLE `session` CHANGE `sess_time` `sess_expiry` INTEGER UNSIGNED NOT NULL; |
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.
This will result in wrong expiry time.
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.
Yes, maybe the steps must be:
- Create a new
sess_expiry
column. - Migrate the old data:
UPDATE session SET sess_expiry = sess_time + sess_lifetime;
- Remove the
sess_time
andsess_lifetime
columns.
What do you think?
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.
ping @Tobion
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.
yes
@Tobion updated the UPGRADE-3.0.md file. |
👍 |
ping @symfony/deciders |
Can we in a way provide a smoother upgrade path (ie. by offering a deprecation message in Symfony 2.8)? |
I agree. I think we should create a new class for this and deprecate the old class. We already messed this up in 2.6 with the new |
I agree is would be nicer. But how would we name the new PdoSessionHandler? If the name sucks, we have to change the name again in 3.0 which will not make the upgrade easier. |
@Tobion ha, so true - we don't want something like And I'm really not sure - I think about this question a lot, but I don't know a good, global answer. How about |
Is there a necessity of removing the Since this For a smoother migration path, I would create a feature flag to enable the extra |
IMO the only factible way to introduce this in 2.8 is the idea proposed by @GromNaN. What do you think? If all agree, i can make the necessary changes. |
I think @GromNaN's idea would certainly work, though we'd need to have a lot of if statements inside the class to use different queries. But we could deprecate the old way and remove it in 3.0 (meaning only 1 version would need to have all these ugly if statements). But yea, I would like to fix this - other than the BC part, it sounds like a great win! |
Ok, i will work on this. |
@dosten you rock :) |
I think the index on the expiry column is really necessary for high loads: #15020 (comment) |
I'm not a database expert, if someone knows how to create an index in mysql, sqlite, pgsql, oci or sqlsrv.. help is welcome :) |
@dosten the syntax is SQL standard : https://dev.mysql.com/doc/refman/5.0/en/create-index.html CREATE INDEX idx_sess_expiry ON session (sess_expiry); |
Closing this because i'm going to create another PR over the 2.8 branch. |
no news about this? |
Removed timestamp and lifetime columns in favor of expiry column. Based on the work done in symfony#14625. Fix symfony#13955.
Removed timestamp and lifetime columns in favor of expiry column. Based on the work done in symfony#14625. Fix symfony#13955. Implemented CR suggestions from nicolas-grekas
… (azjezz) This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] Precalculate session expiry timestamp | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #13955, #21423, #14625 | License | MIT Continued work from the original PR #21423 / #21857 Commits ------- 066000a [HttpFoundation] Precalculate session expiry timestamp