Commit Graph

12577 Commits

Author SHA1 Message Date
Christopher Poile
4bfad26614 MM-26441 - fix for doPluginRequest (#14897)
* merge rawQuery params with provided values

* tests for doPluginRequest

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-26 11:15:04 -03:00
Ibrahim Serdar Acikgoz
f7f1f0d268 [MM-23721] api4/user: add verify user by Id endpoint (#14244)
* api4/user: add verify user by id method

* Update api4/user.go

Co-Authored-By: Miguel de la Cruz <miguel@mcrx.me>

* Update model/client4.go

Co-Authored-By: Miguel de la Cruz <miguel@mcrx.me>

* api4/user: reflect review comments

* Update api4/user_test.go

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-26 16:08:01 +03:00
Claudio Costa
d0e035467c [MM-16473] Make plugins' ServerHTTP http.ResponseWriter hijackable (#14822)
* Make plugins' ServerHTTP http.ResponseWriter hijackable

* Rename brw to align with docs

* Fix error handling
2020-06-26 10:51:23 +02:00
Rodrigo Villablanca
0118db9d23 Migration of AuditStore to return plain errors (#14825)
Automatic Merge
2020-06-26 06:26:35 +02:00
Agniva De Sarker
98d72e51fe MM-26452: Fix flaky test ChannelStore//SearchInTeam/the_in_name (#14899)
The same problem as #14840 plagues this test too.
2020-06-25 22:26:37 +05:30
Miguel de la Cruz
1ef5523b9f [MM-26390] Ensures the generated team name in sampledata is a valid one (#14901) 2020-06-25 16:00:12 +02:00
Elisabeth Kulzer
89c3b3d5a7 Fix webapp checkout part 2 (#14910)
* Fix webapp checkout part 2

* Use trap instead to not trigger fail commands before.

* Rm trap afterwards.
2020-06-25 14:03:19 +02:00
Mario de Frutos Dieguez
05ec3733c0 [MM-25406] Include missing methods in the search layer (#14799)
* Two missing methods to add in the channel layer

* Added delete user/channel posts methods

- Created in both search engines but only implemented in ES
- Add those methods in the search layer
- Included the PermanentDeleteByUser/Channel methods

* Two new delete documents are included in the bleve code with this
change:

- DeleteChannelPosts
- DeleteUserPosts

These two new functions delete post documents from the index-based
in the filed value provided
2020-06-25 13:45:39 +02:00
Siyuan Liu
aaea36a24d MM-25115 - make cacheProvider2 accessible to localcachelayer (#14691)
* make cacheProvider2 accessible to localcachelayer

* migrate localcachelayer

* revert test.sh

* workaround gob deserialization issue

* fix web_test.go

* merge conflicts

* resolve merge conflicts

* revert back test workaround

* fix the wrong merge
2020-06-25 17:08:53 +05:30
Agniva De Sarker
1648b11e82 MM-25507: Remove old migration state marker before running fresh migration (#14768)
While resetting permissions, we were not removing old migration state residue
for the EMOJIS_PERMISSIONS_MIGRATION_KEY and GUEST_ROLES_CREATION_MIGRATION_KEY.
Therefore, during their migration, they got skipped because the code checks
if a migration key is already present or not.

To fix this, we remove the migration key just as we do for ADVANCED_PERMISSIONS_MIGRATION_KEY.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-25 13:36:47 +05:30
Scott Bishel
23e306bc3a add function to LdapInterface (#14761)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-24 10:01:31 -06:00
Agniva De Sarker
3cf05efdd9 MM-25404: Add GetHealthScore metric for the cluster (#14767)
* MM-25404: Add GetHealthScore metric for the cluster

This PR adds the necessary function to the cluster interface
so that they can be called from App code.

* Add mocks

* Remove fakeapp

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-24 18:46:33 +05:30
Rodrigo Villablanca
64d12c08e9 LicenseStore migration to return plain errors (#14837)
Automatic Merge
2020-06-24 05:56:35 +02:00
Maria A Nunez
668a2aa856 Added SearchPostsInTeamForUser for plugin API (#14807)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 21:58:44 -04:00
Martin Kraft
7c4c038a96 MM-11713: Does not require edit_own_posts to edit_others_posts. (#14787)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 16:08:55 -04:00
Scott Bishel
53ef4d120b MM-25544:Update error message for length violations (#14853)
* update error message for length violations

* fix unit test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 10:47:48 -06:00
Christopher Speller
574b48835d MM-26055 Remove session requirement from command args. (#14880)
* Remove session requirement from command args.

* Removing unused server side translation.

* Restoring model.CommandArgs.Session for compatibility.

* Feedback fixes.

* Build fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 08:33:45 -07:00
Mario de Frutos Dieguez
e7aaf0ea6a Activate tests about search terms inside links (#14578) 2020-06-23 16:15:41 +02:00
Agniva De Sarker
b2350774ea MM-25890: Fix deadlock on deleting emoji reactions (#14859)
* MM-19548: Add a deadlock retry function for SaveChannel

A deadlock has been seen to occur in the upsertPublicChannelT method
during bulk import.

Here is a brief excerpt:

*** (1) TRANSACTION:
TRANSACTION 3141, ACTIVE 1 sec inserting
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3141 lock_mode X locks gap before rec insert intention waiting
** (2) TRANSACTION:
TRANSACTION 3140, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 2
MySQL thread id 50, OS thread handle 140641523848960, query id 3226 172.17.0.1 mmuser update
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec insert intention waiting

*** WE ROLL BACK TRANSACTION (1)

Following is my analysis:

From the deadlock output, it can be seen that it's due to a gap lock.
And that's clear because the index is Name which is a multi-column index using Name and TeamId.
But interestingly, both transactions seem to be inserting the same data, which is what is puzzling me.
The multi-column index on Name and TeamId will guarantee that they are always unique. And from looking at the code,
it does not seem possible to me that it will try to insert the same data from 2 different transactions.
But even if they do, why does tx 2 try to acquire the same lock again when it already has that ?

Here is what I think the order of events happening

Tx 2 gets a gap lock.
Tx 1 tries to get the same gap lock.
Tx 2 tries to again get the same gap lock ?

The last step is what is puzzling me. Why does an UPSERT statement acquire 2 gap locks ? From my reading of https://dev.mysql.com/doc/refman/8.0/en/innodb-locks-set.html:

> INSERT ... ON DUPLICATE KEY UPDATE differs from a simple INSERT in that an exclusive lock rather than a shared lock is placed on the row to be updated when a duplicate-key error occurs. An exclusive index-record lock is taken for a duplicate primary key value. An exclusive next-key lock is taken for a duplicate unique key value.

From what I understand, the expectation is that there will be one X lock and one gap lock is taken.
But that's not what the deadlock output seems to say.

The general advice on the internet seems to be that deadlocks will happen and not all of them can be understood.

For now, we add a generic deadlock retry function at the store package which can be reused by other queries too.

P.S.: This is a verbatim copy of my investigation posted at https://dba.stackexchange.com/questions/268652/mysql-deadlock-upsert-query-acquiring-gap-lock-twice

Testing:

This is ofcourse hard to test because it is impossible to reproduce this. I have tested this by manually returning an error
and confirming that it indeed retries.

WARN[2020-06-19T11:18:24.9585676+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.959158+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595072+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595451+05:30] Deadlock happened 3 times. Giving up          caller="sqlstore/channel_store.go:579"
ERRO[2020-06-19T11:18:24.9596426+05:30] Unable to save channel.                       caller="mlog/log.go:175" err_details="Error 1213: mydeadlock" err_where=CreateChannel http_code=500 ip_addr="::1" method=POST path=/api/v4/channels request_id=745bsj13b7f6mnmsbn3t97grbw user_id=xcof1ipipbrfxpfjf6x4p6kx9e

* Fix tests

* MM-25890: Fix deadlock on deleting emoji reactions

A deadlock happens because `UPDATE_POST_HAS_REACTIONS_ON_DELETE_QUERY` is being called from 2 separate places.
1. From `DeleteAllWithEmojiName` where it's called as an independent query.
2. From `deleteReactionAndUpdatePost` where it's called as part of a transaction along with another DELETE query.

The deadlock occurs in such a scenario:

- tx #2 acquires an X lock from the DELETE query.
- tx #1 tries to acquire a S lock with the select query, but it's waiting for the X lock to be released from tx #2
- tx #2 now tries to acquire an S lock, but it can't because it is locked on tx #1.

Deadlock.

I have tested this and it does indeed deadlock. The root of the problem is that the Primary key is a multi-column index,
which means that a next-key lock has to be acquired to get a lock on the gap before the index.
Both the queries try to delete some reactions, and then select the new number of reactions. But they select different rows
due to which this happens.

This might just be an unavoidable deadlock due to the way the indexes are setup and next-key locks.
Unless we change the primary key to be a single-column index, it will be very hard to avoid this.

Therefore we just go with a simple retry.

* fix i18n

* address review comments

* address code review

* Fix scopelint

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 17:32:59 +05:30
Ibrahim Serdar Acikgoz
c6bc7fed6d api4/role: add role endpoints to local mode (#14876) 2020-06-23 12:56:52 +03:00
Ibrahim Serdar Acikgoz
516ceaed8e api4/ldap: add test/sync/getgroups to local mode (#14842)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 11:47:52 +03:00
Rodrigo Villablanca
7bf6565ed2 Migration of SchemeStore to return plain errors (#14836)
Automatic Merge
2020-06-23 06:56:35 +02:00
Agniva De Sarker
a1547cfac5 MM-19548: Add a deadlock retry function for SaveChannel (#14857)
* MM-19548: Add a deadlock retry function for SaveChannel

A deadlock has been seen to occur in the upsertPublicChannelT method
during bulk import.

Here is a brief excerpt:

*** (1) TRANSACTION:
TRANSACTION 3141, ACTIVE 1 sec inserting
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3141 lock_mode X locks gap before rec insert intention waiting
** (2) TRANSACTION:
TRANSACTION 3140, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 2
MySQL thread id 50, OS thread handle 140641523848960, query id 3226 172.17.0.1 mmuser update
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec insert intention waiting

*** WE ROLL BACK TRANSACTION (1)

Following is my analysis:

From the deadlock output, it can be seen that it's due to a gap lock.
And that's clear because the index is Name which is a multi-column index using Name and TeamId.
But interestingly, both transactions seem to be inserting the same data, which is what is puzzling me.
The multi-column index on Name and TeamId will guarantee that they are always unique. And from looking at the code,
it does not seem possible to me that it will try to insert the same data from 2 different transactions.
But even if they do, why does tx 2 try to acquire the same lock again when it already has that ?

Here is what I think the order of events happening

Tx 2 gets a gap lock.
Tx 1 tries to get the same gap lock.
Tx 2 tries to again get the same gap lock ?

The last step is what is puzzling me. Why does an UPSERT statement acquire 2 gap locks ? From my reading of https://dev.mysql.com/doc/refman/8.0/en/innodb-locks-set.html:

> INSERT ... ON DUPLICATE KEY UPDATE differs from a simple INSERT in that an exclusive lock rather than a shared lock is placed on the row to be updated when a duplicate-key error occurs. An exclusive index-record lock is taken for a duplicate primary key value. An exclusive next-key lock is taken for a duplicate unique key value.

From what I understand, the expectation is that there will be one X lock and one gap lock is taken.
But that's not what the deadlock output seems to say.

The general advice on the internet seems to be that deadlocks will happen and not all of them can be understood.

For now, we add a generic deadlock retry function at the store package which can be reused by other queries too.

P.S.: This is a verbatim copy of my investigation posted at https://dba.stackexchange.com/questions/268652/mysql-deadlock-upsert-query-acquiring-gap-lock-twice

Testing:

This is ofcourse hard to test because it is impossible to reproduce this. I have tested this by manually returning an error
and confirming that it indeed retries.

WARN[2020-06-19T11:18:24.9585676+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.959158+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595072+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595451+05:30] Deadlock happened 3 times. Giving up          caller="sqlstore/channel_store.go:579"
ERRO[2020-06-19T11:18:24.9596426+05:30] Unable to save channel.                       caller="mlog/log.go:175" err_details="Error 1213: mydeadlock" err_where=CreateChannel http_code=500 ip_addr="::1" method=POST path=/api/v4/channels request_id=745bsj13b7f6mnmsbn3t97grbw user_id=xcof1ipipbrfxpfjf6x4p6kx9e

* Fix tests

* Address review comments

* Address review comments

* Add forgotten test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 08:44:39 +05:30
Michael Kochell
b8b36e33d6 Fix ResetLastPictureUpdate flaky test (#14856)
* Ensure time is different when second update operation occurs

* Change all sleeps to one ms

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 08:31:28 +05:30
Agniva De Sarker
78d44f3eab MM-25701: Reuse HTTP client in sendAckToPushProxy (#14759)
We reuse the http client made for push notifications.
This leads to reuse of TCP connections rather than
creating a new client every time.
2020-06-23 00:08:06 +05:30
Agniva De Sarker
60b826824a MM-26376: Fix flaky test SearchAllChannels (#14878)
Applying the same fix done in #14840
2020-06-22 22:53:59 +05:30
Scott Bishel
938176be3e MM-24467- Use new ServiceProviderIdentifier in AuthnRequest (#14725)
* add ServiceProviderIdentifier to config

* Update config, add unit test

* fix unit test, update i18n

* add english translation for error

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-22 09:36:08 -06:00
Ibrahim Serdar Acikgoz
124014ad9c [MM-23719] api4/channel: add move channel to a team endpoint (#14246)
* api4: add move channel method

* api4: add tests for move channel, model: add move channel to client4.go

* add api.channel.move_channel.type.invalid message

* model/client4: remove a redundant line

* api4/channel: add tests for gm and private channel types

* app/channel: update move channel comment

* app/channel: add extra check if a users joins to channel during movement

* app/channel: log errors for post move channel

* app/channel: remove deactivated members by default while moving a ch.

* model/client: update move channel command

* fix vet errors

* app/channel: add missing webhook updates

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-22 16:57:49 +03:00
Ashish Bhate
0e714f350a MM-25071: local mode for getPostsForChannel (#14848) 2020-06-22 14:06:37 +05:30
George Goldberg
e5addef19b MM-23574: Remove Segment. (#14712)
* MM-23574: Eliminate Segment.

* Update dependencies.

* Fix review suggestions.
2020-06-22 08:35:03 +01:00
Martin Kraft
6158e91308 MM-25261: Add 'include_deleted' parameter to get all channels API req… (#14721)
* MM-25261: Add 'include_deleted' parameter to get all channels API request.

* MM-25261: Adds test for deleted channels.

* MM-25261: Switches to single liner.

* MM-25261: Adhere to beta config setting for viewing archived channels.

* MM-25261: Test fix.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 16:53:37 -04:00
Rodrigo Villablanca
d391fd6231 Migration of ChannelStore.GetMoreChannels to return plain error (#14811)
Automatic Merge
2020-06-19 20:26:35 +02:00
Mario de Frutos Dieguez
4a974eabea Include response log trace (#14841)
Include the status_code in the log trace
2020-06-19 16:34:49 +02:00
Rodrigo Villablanca
2760497660 Migration of UserTermsOfServiceStore to return plain errors (#14788)
* Migration of UserTermsOfService Store

* Ordering translations file

* Fix imports

* Fix translations]

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 17:49:30 +05:30
Ashish Bhate
d21f1183ab MM-25118: fix teamImport panic and return better error (#14797)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 17:23:26 +05:30
Mario de Frutos Dieguez
0a96ed04a3 ES now supports inactive users filtering (#14463)
* ES now supports inactive users filtering
2020-06-18 21:17:35 +02:00
Agniva De Sarker
22aff2af4a MM-26203: Fix TestChannelStore//SearchAllChannels flake (#14840)
* MM-26203: Fix TestChannelStore//SearchAllChannels flake

Using random strings for channel names creates chances of collisions
when searching for specific strings.

We increase the search space increasing the size of the search string
to be searched. This reduces collisions and makes the tests more reliable.

For the "off-" family of tests, this probably needs more length. But
it would also need the tests to be changed slightly as the "off-" part
acts as a prefix. I accidentally stumbled upon it while running the test
50 times. Adding a "-" is probably good enough for now. We can revisit
if it fails again in CI.

* improved team_store tests too
2020-06-18 15:14:34 -04:00
Martin Kraft
88a6cf0bf1 MM-26231: Reverts plugin API breaking change. (#14852) 2020-06-18 14:17:36 -04:00
Farhan Munshi
4d40226e02 MM-24674 Update channel members by group to look at distinct timezones correctly (#14673)
* MM-24674 Update channel members by group to look at distinct autoTimezone and manualTimezone.

Instead of just doing a blanket distinct on the column since that returns more entries than expected

* Use JSON extract instead of parsing text

* Use single quotes in mysql query too

* Dont need to prepend users on unambiguous column

* Use json extract instead of shorthand

* Dont count timezone if timezone default length

* CI

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-18 12:02:00 -04:00
Farhan Munshi
77bee1d4f1 MM-25263 Add group members to search and get users and create getGroupStats endpoint (#14733)
Add tests for SearchInGroup
2020-06-18 10:22:35 -04:00
Mario de Frutos Dieguez
f6c934d7e0 Create GetOldestEntityCreationTime method (#14515)
This method will be used by the ES index jobs in order
to get the first timestamp to be used as the starting point
when doing indexing tasks
2020-06-18 14:34:23 +02:00
Agniva De Sarker
ef85001523 MM-25710: Use an efficient cache serialization algorithm (#14826)
* MM-25710: Use an efficient cache serialization algorithm

We investigate 3 packages for selecting a suitable replacement
for gob encoding. The algorithm chosen was msgpack which gives
a decent boost over the standard gob encoding.

Any external schema dependent algorithms like protobuf, flatbuffers, avro,
capn'proto were not considered as that would entail converting the model structs
into separate schema objects and then code generating the Go structs.
It could be done theoretically at a later stage specifically for structs
which are in the hot path. This is a general solution for now.

The packages considered were:
- github.com/tinylib/msgp
- github.com/ugorji/go/codec
- github.com/vmihailenco/msgpack/v5

msgp uses code generation to generate encoding/decoding code without the reflection overhead.
Theoretically, therefore this is supposed to give the fastest performance. However, a major
flaw in that package is that it works only at a file/directory level, not at a package level.
Therefore, for structs which are spread across multiple files, it becomes near to impossible
to chase down all transitive dependencies to generate the code. Even if that's done, it fails
on some complex type like xml.Name and time.Time. (See: https://github.com/tinylib/msgp/issues/274#issuecomment-643654611)

Therefore, we are left with 2 choices. Both of them use the same underlying algorithm.
But msgpack/v5 wraps the encoders/decoders in a sync.Pool. To make a perfect apples-apples
comparison, I wrote a sync.Pool for ugorji/go/codec too and compared performance.

msgpack/v5 came out to be the fastest by a small margin.

benchstat master.txt ugorji.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 2%  -34.64%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     9.1µs ± 2%  -76.38%  (p=0.000 n=9+9)
LRU/User=new-8       75.8µs ± 2%    23.5µs ± 2%  -69.01%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 3%  -82.92%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.4µs ± 4%  -80.34%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.97%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.4kB ± 0%  -71.89%  (p=0.000 n=9+10)
LRU/User=new-8       33.5kB ± 0%     9.2kB ± 0%  -72.48%  (p=0.000 n=10+8)
LRU/Post=new-8       38.7kB ± 0%     4.8kB ± 0%  -87.48%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.7kB ± 0%  -83.50%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        48 ± 0%  -85.19%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       108 ± 0%  -82.64%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        74 ± 0%  -91.80%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        22 ± 0%  -90.91%  (p=0.000 n=10+10)

11:31:48-~/mattermost/mattermost-server/services/cache2$benchstat master.txt vmi.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 3%  -34.59%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     8.7µs ± 3%  -77.45%  (p=0.000 n=9+10)
LRU/User=new-8       75.8µs ± 2%    20.9µs ± 1%  -72.45%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 2%  -83.08%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.1µs ± 3%  -81.66%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.89%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.6kB ± 0%  -70.87%  (p=0.000 n=9+8)
LRU/User=new-8       33.5kB ± 0%    10.3kB ± 0%  -69.40%  (p=0.000 n=10+9)
LRU/Post=new-8       38.7kB ± 0%     6.0kB ± 0%  -84.62%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.9kB ± 0%  -82.41%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        46 ± 0%  -85.80%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       106 ± 0%  -82.96%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        89 ± 0%  -90.13%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        23 ± 0%  -90.50%  (p=0.000 n=10+10)

In general, we can see that the time to marshal/unmarshal pays off as the size of the struct
increases.

We can see that msgpack/v5 is faster for CPU but very slightly heavier on memory.
Since we are interested in fastest speed, we choose msgpack/v5.

As a future optimization, we can use a mix of msgpack and msgp for hot structs.
To do that, we would need to shuffle around some code so that for the hot struct,
all its dependencies are in the same file.

Let's use this in production for some time, watch grafana graphs for the hottest caches
and come back to optimizing this more once we have more data.

Side note: we have to do with micro-benchmarks for the time being, because all the caches
aren't migrated to cache2 interface yet. Once that's in, we can actually run some load tests
and do comparisons.

* Bring back missing import

* Fix tests
2020-06-18 17:21:39 +05:30
Maria A Nunez
085ab2c60a MM-25762 - Moved password settings to client limited configuration (#14777)
* Moved password settings to limited configuration

* Added unit test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-18 06:14:03 -04:00
Rodrigo Villablanca
8dc7c5762f Migrate GetDeletedByName from ChannelStore to return error interface (#14709)
Automatic Merge
2020-06-18 06:26:35 +02:00
Agniva De Sarker
1d9c8a490d MM-25700 : Use a counting semaphore for push notifications hub (#14758)
Automatic Merge
2020-06-18 05:56:35 +02:00
Doug Lauder
b317ee5cf2 MM-25394 session expired push notifications (#14732)
* new job type created that checks for expired mobile sessions and pushes notifications.

* only send session expired notifications if ExtendSessionLengthWithActivity is enabled.

* includes schema change:  field added to Sessions table
2020-06-17 14:47:54 -04:00
Martin Kraft
2bb6071f73 MM-26065: Reverts Brotli encoding. (#14834)
* MM-26065: Reverts Brotli encoding.

* MM-26065: Removes package reference.
2020-06-16 18:15:31 -04:00
Jesús Espino
61ff43aef8 Moving back saml to the fakeapp approach (#14833)
* Moving back saml to the fakeapp approach

* Configure sp during initialization

* Configure sp during initialization (with no fake app)
2020-06-16 23:37:06 +02:00
Agniva De Sarker
c58edbf622 MM-26167: improve CreatePostCheckOnlineStatus (#14827)
* Improve CreatePostCheckOnlineStatus

We improve the flakyness of the test by making the websocket
status checks synchronous after making each request.

This makes the status responses more reliable because in very
busy CI environments the goroutine scheduler can indeed send
the response which is made by a later HTTP request before the first one.

* Update api4/post_test.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2020-06-16 17:30:58 +05:30
Attila Molnar
66597d0fcb Expand Plugin and REST APIs to trigger user typing event (#14331) 2020-06-16 11:41:05 +02:00