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

Create DB session provider(based on xorm) #13031

Merged
merged 22 commits into from
Feb 15, 2021

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Oct 4, 2020

This PR creates a Xorm session provider which creates
the appropriate Session table for macaron/session.

Fix #7137

Signed-off-by: Andrew Thornton art27@cantab.net

This PR creates a Xorm session provider which creates
the appropriate Session table for macaron/session.

Fix go-gitea#7137

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Oct 4, 2020
@zeripath zeripath added this to the 1.14.0 milestone Oct 4, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@lafriks
Copy link
Member

lafriks commented Oct 5, 2020

lint failure ;)

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 5, 2020
@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2020

Codecov Report

Merging #13031 into master will decrease coverage by 0.06%.
The diff coverage is 2.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13031      +/-   ##
==========================================
- Coverage   42.62%   42.55%   -0.07%     
==========================================
  Files         672      675       +3     
  Lines       73785    73933     +148     
==========================================
+ Hits        31448    31460      +12     
- Misses      37247    37387     +140     
+ Partials     5090     5086       -4     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.46% <ø> (ø)
models/migrations/v153.go 0.00% <0.00%> (ø)
models/session.go 0.00% <0.00%> (ø)
modules/session/xorm.go 2.63% <2.63%> (ø)
models/models.go 56.15% <100.00%> (+0.21%) ⬆️
modules/indexer/stats/db.go 52.17% <0.00%> (-17.40%) ⬇️
models/unit.go 46.57% <0.00%> (-2.74%) ⬇️
models/gpg_key.go 53.33% <0.00%> (-0.58%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e1c51c...602be9c. Read the comment docs.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
models/migrations/v153.go Outdated Show resolved Hide resolved
Co-authored-by: 6543 <6543@obermui.de>
@lafriks
Copy link
Member

lafriks commented Oct 15, 2020

conflicts ;)

@zeripath
Copy link
Contributor Author

done

@lunny
Copy link
Member

lunny commented Oct 15, 2020

But this still don't resolve the mysql session provider unavailable problem? Could we change mysql as an alias of xorm provider?

@codecov-io
Copy link

codecov-io commented Oct 15, 2020

Codecov Report

Merging #13031 (39f1565) into master (487f2ee) will increase coverage by 0.02%.
The diff coverage is 45.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13031      +/-   ##
==========================================
+ Coverage   42.21%   42.23%   +0.02%     
==========================================
  Files         767      770       +3     
  Lines       81624    81888     +264     
==========================================
+ Hits        34458    34586     +128     
- Misses      41531    41674     +143     
+ Partials     5635     5628       -7     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.59% <ø> (ø)
models/migrations/v172.go 0.00% <0.00%> (ø)
models/session.go 0.00% <0.00%> (ø)
modules/session/virtual.go 60.20% <0.00%> (-1.26%) ⬇️
modules/structs/issue.go 0.00% <ø> (ø)
modules/session/db.go 2.63% <2.63%> (ø)
modules/queue/unique_queue_disk_channel.go 55.22% <50.00%> (+1.37%) ⬆️
models/models.go 57.42% <100.00%> (+0.21%) ⬆️
modules/setting/session.go 89.47% <100.00%> (ø)
modules/setting/setting.go 49.03% <100.00%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e5b063...39f1565. Read the comment docs.

@zeripath
Copy link
Contributor Author

well the idea would be that the other db session providers would be considered deprecated.

@lafriks
Copy link
Member

lafriks commented Oct 31, 2020

Imho we should just remove them and add breaking change here. Also we could make it a default one.
Would it be possible to add user id column somehow?

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

Imho we should just remove them and add breaking change here.

So removing the mysql and postgres providers may be a little aggressive - happy to remove them if wanted though.

Also we could make it a default one.

In terms of making it the default I think there is still a place for the filesystem based sessions.

Would it be possible to add user id column somehow?

Adding the User ID would be a breaking change from the macaron session provider stuff - we'd have to change the API considerably.

@lafriks
Copy link
Member

lafriks commented Oct 31, 2020

I don't see much need for options duplicating functionality.
If no user id can be added than probably type should be renamed to SessionData or something like that to keep Session reserved for actual user session management in future

@zeripath
Copy link
Contributor Author

The tablename session is required to maintain compatibility with the original mysql/postgres provider tables.

@lafriks
Copy link
Member

lafriks commented Oct 31, 2020

I don't think thats much of the problem that we lose session data, it's not critical

@stale
Copy link

stale bot commented Dec 31, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@stale stale bot removed the issue/stale label Jan 3, 2021
@zeripath
Copy link
Contributor Author

zeripath commented Jan 3, 2021

conflicts fixed

@lunny
Copy link
Member

lunny commented Jan 4, 2021

Since macaron will be replaced by chi, I would like to merge this after macaron has been replaced.

@lunny
Copy link
Member

lunny commented Jan 26, 2021

Please resolve the conflicts.

@zeripath
Copy link
Contributor Author

@lunny I've updated.

I don't think there's any changes with chi-session but you might be more aware of these.

models/session.go Outdated Show resolved Hide resolved
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I would like name it DB session.

models/session.go Outdated Show resolved Hide resolved
models/session.go Outdated Show resolved Hide resolved
models/session.go Outdated Show resolved Hide resolved
@zeripath
Copy link
Contributor Author

zeripath commented Feb 13, 2021

You mean from XormSession to DBSession? Done

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 14, 2021
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 15, 2021
@lunny lunny changed the title Create Xorm session provider Create DB session provider(based on xorm) Feb 15, 2021
@techknowlogick
Copy link
Member

🚀

@techknowlogick techknowlogick merged commit 0a9a484 into go-gitea:master Feb 15, 2021
@zeripath zeripath deleted the xorm-session-provider branch February 15, 2021 07:02
@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gitea can't automatically create table for session storage in MySQL database
8 participants