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

Fix user cache #3161

Merged
merged 1 commit into from
Jun 23, 2021
Merged

Fix user cache #3161

merged 1 commit into from
Jun 23, 2021

Conversation

NelsonVides
Copy link
Collaborator

@NelsonVides NelsonVides commented Jun 23, 2021

As the tables are created per-host-type, a table can have more than one
domain within, and so there's no unique key properly defined,
considering that the same namepart can be used in two different domains,
and the same domain contains many nameparts.

The cache was broken because, as a set where the domain is the key, inserted users would always override previous. If namepart is the key, two users with the same namepart in different domains would also override each other. So the whole pair needed to be made the key as a 1-tuple.

@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #3161 (8dd5ec8) into master (78880e6) will increase coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 8dd5ec8 differs from pull request most recent head 23029ad. Consider uploading reports for the commit 23029ad to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3161      +/-   ##
==========================================
+ Coverage   79.82%   79.84%   +0.02%     
==========================================
  Files         396      396              
  Lines       32255    32255              
==========================================
+ Hits        25748    25755       +7     
+ Misses       6507     6500       -7     
Impacted Files Coverage Δ
src/mongoose_users.erl 95.34% <100.00%> (+2.32%) ⬆️
src/elasticsearch/mongoose_elasticsearch.erl 76.92% <0.00%> (-7.70%) ⬇️
src/mam/mod_mam_elasticsearch_arch.erl 86.60% <0.00%> (-1.79%) ⬇️
src/ejabberd_s2s_out.erl 60.13% <0.00%> (-0.69%) ⬇️
src/mod_muc_log.erl 77.72% <0.00%> (ø)
src/mod_muc_room.erl 77.10% <0.00%> (+0.17%) ⬆️
src/pubsub/mod_pubsub_db_mnesia.erl 92.82% <0.00%> (+0.42%) ⬆️
src/ejabberd_sm.erl 84.59% <0.00%> (+0.65%) ⬆️
src/wpool/mongoose_wpool.erl 85.00% <0.00%> (+1.00%) ⬆️
src/cassandra/mongoose_cassandra_worker.erl 75.00% <0.00%> (+1.88%) ⬆️
... and 2 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 78880e6...23029ad. Read the comment docs.

@NelsonVides NelsonVides changed the title Change cache ets table from set to bag Fix user cache Jun 23, 2021
Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

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

Great. I think it's best to squash these two commits on merge.

As the tables are created per-host-type, a table can have more than one
domain within, and so there's no unique key properly defined,
considering that the same namepart can be used in two different domains,
and the same domain contains many nameparts.

Restore it as a set, and actually fix the key inserted
@chrzaszcz chrzaszcz merged commit 3789a21 into master Jun 23, 2021
@chrzaszcz chrzaszcz deleted the fix_cache branch June 23, 2021 13:39
@Premwoik Premwoik added this to the 5.0.0 milestone Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants