mattermost/server/channels/app/platform
Ben Schumacher 7739b349a0
[MM-68578] Add support packet DB performance diagnostics (#36324)
* Add support packet DB diagnostics for pool and pg_stat

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Fix support packet mock store for new DB diagnostics

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Add context timeouts to support packet pg diagnostics

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Move support packet DB diagnostics queries into sqlstore

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Fix support packet diagnostics lint and partial data handling

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Stabilize support packet pool idle assertion

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Relax live support packet DB counter assertions

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Fix deterministic pool diagnostics test wiring

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Mock support packet diagnostics in app test store

Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>

* Move SupportPacketDatabaseDiagnostics out of public model

The struct is an internal store→platform transport (no yaml tags, never
serialized directly) so it doesn't belong in server/public/model where
it would form a public API contract for plugins. Move it into the store
package as the natural return type of GetSupportPacketDatabaseDiagnostics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Describe SupportPacketDatabaseDiagnostics by content, not history

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* wording

* Align store diagnostics with sqlstore conventions

- Rename Store.GetSupportPacketDatabaseDiagnostics to Store.GetDiagnostics
  and rename the holding files to diagnostics{,_test}.go.
- Drop the queryRowScanner / rowScanner / sqlQueryRowScanner test seam.
  The collectors now use the sqlxDBWrapper master handle and bind result
  rows into local structs via sqlx GetContext, matching how the rest of
  the sqlstore package talks to Postgres.
- Replace the hand-rolled mock-based unit tests for the Postgres
  collector with an integration test driven through StoreTest, the
  pattern used by the other sqlstore tests (e.g. schema_dump_test.go).
  The pure pool-stats unit test (TestApplyDBPoolStats) is kept.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Drop MasterDBStats/ReplicaDBStats from the Store interface

After GetDiagnostics moved into the store layer, no caller outside the
sqlstore package itself reads MasterDBStats/ReplicaDBStats through the
Store interface — the diagnostics collector calls them on the concrete
*SqlStore receiver. Remove them from the interface, the retry/timer
layer wrappers, the storetest fake, and the generated mock; drop the
now-redundant fixedDBStatsStore shim methods and mock setups in the
support packet tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Rename SupportPacketDatabaseDiagnostics to DatabaseDiagnostics

Now that the type lives in the store package and is returned by
Store.GetDiagnostics, the SupportPacket prefix is just legacy framing —
support packets are one consumer of the data, not its identity. Rename
to store.DatabaseDiagnostics for consistency with the package and method
name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Inline diagnostics SQL into the collector functions

Each pg_stat query has a single caller, so a package-level constant just
adds indirection between the function and the SQL it owns. Move the
query strings to local consts inside the collectors that use them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Fix Connectios typo to Connections

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Fix sqlstore diagnostics build: call GetMaster().DB() method

The recent rebase brought in a change that turned the SqlStore DB
field into a method, so passing ss.GetMaster().DB to
collectPostgresDatabaseDiagnostics (which expects *sqlx.DB) no longer
compiles. Call the method instead.

* Fix gofmt alignment in SupportPacketDiagnostics

The post-merge struct had extra spaces on MasterConnections /
ReplicaConnections that broke gofmt alignment.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ben Schumacher <hanzei@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 12:45:18 +02:00
..
mocks [MM-68183] Permission policies (#36003) 2026-04-16 04:02:12 +03:00
.mockery.yaml Migrate mockery to packages feature (#29013) 2024-11-07 12:48:11 +01:00
busy.go MM-53032: Fix module path after repo rename (#23689) 2023-06-11 10:54:35 +05:30
busy_test.go [MM-62408] Server Code Coverage with Fully Parallel Tests (#30078) 2025-05-30 13:58:26 +02:00
cluster.go MM-66944 Change PlatformService.IsLeader to always be true when license doesn't support clustering (#35577) 2026-03-20 11:15:16 -04:00
cluster_discovery.go MM-53032: Fix module path after repo rename (#23689) 2023-06-11 10:54:35 +05:30
cluster_discovery_test.go Fix errcheck linter errors in helpers (#31578) 2025-11-12 13:00:51 +01:00
cluster_handlers.go MM-68543 Invalidate active WebConn session cache on global session revocation (#36332) 2026-05-07 09:01:36 -04:00
cluster_handlers_revoke_test.go MM-68543 Invalidate active WebConn session cache on global session revocation (#36332) 2026-05-07 09:01:36 -04:00
cluster_handlers_test.go MM-68543 Invalidate active WebConn session cache on global session revocation (#36332) 2026-05-07 09:01:36 -04:00
cluster_test.go MM-66944 Change PlatformService.IsLeader to always be true when license doesn't support clustering (#35577) 2026-03-20 11:15:16 -04:00
config.go MM-66789 Restrict log downloads to a root path for support packets (#35014) 2026-01-29 13:29:55 -05:00
config_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
container_limits_linux.go [MM-67975] Add container CPU and memory limits to support packet diagnostics (#35835) 2026-04-23 13:25:34 +00:00
container_limits_linux_test.go [MM-67975] Add container CPU and memory limits to support packet diagnostics (#35835) 2026-04-23 13:25:34 +00:00
container_limits_other.go [MM-67975] Add container CPU and memory limits to support packet diagnostics (#35835) 2026-04-23 13:25:34 +00:00
disk_darwin.go MM-67974: Add disk space info to Support Packet for local file store (#36300) 2026-04-28 13:34:56 +00:00
disk_linux.go MM-67974: Add disk space info to Support Packet for local file store (#36300) 2026-04-28 13:34:56 +00:00
disk_other.go MM-67974: Add disk space info to Support Packet for local file store (#36300) 2026-04-28 13:34:56 +00:00
enterprise.go [MM-68576] Add SAML connectivity status to support packet diagnostics (#36321) 2026-05-21 10:21:34 +02:00
errors.go Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
fd_darwin.go [MM-67978] Add open file descriptor count to support packet diagnostics (#35834) 2026-04-21 09:54:32 +00:00
fd_linux.go [MM-67978] Add open file descriptor count to support packet diagnostics (#35834) 2026-04-21 09:54:32 +00:00
fd_other.go [MM-67978] Add open file descriptor count to support packet diagnostics (#35834) 2026-04-21 09:54:32 +00:00
fd_test.go [MM-67978] Add open file descriptor count to support packet diagnostics (#35834) 2026-04-21 09:54:32 +00:00
feature_flags.go GH-29265: Fix errcheck errors in server/channels/app/platform/feature_flags.go (#29269) 2024-11-15 09:32:11 +01:00
goroutines.go Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
helper_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
license.go Add single-channel guest tracking and reporting (#35451) 2026-03-10 10:31:10 -04:00
license_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
link_cache.go [MM-61766] Fix errcheck issues in server/channels/app/platform/link_cache.go (#29363) 2024-11-25 13:41:16 +01:00
log.go ci: enable fullyparallel mode for server tests (#35816) 2026-04-08 20:48:36 -04:00
log_test.go ci: enable fullyparallel mode for server tests (#35816) 2026-04-08 20:48:36 -04:00
main_test.go MM-63368: Remove MySQL (#33458) 2025-07-22 20:40:55 +05:30
memory_darwin.go [MM-66840] Add CPU cores and total memory to Support Packet (#34658) 2026-01-13 16:23:32 +01:00
memory_linux.go [MM-66840] Add CPU cores and total memory to Support Packet (#34658) 2026-01-13 16:23:32 +01:00
memory_other.go [MM-66840] Add CPU cores and total memory to Support Packet (#34658) 2026-01-13 16:23:32 +01:00
metrics.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
metrics_test.go MM Build 2025 - Skadoosh - Serve plugin metrics to standard /metrics endpoint (#34678) 2026-04-22 15:04:13 +00:00
options.go Disable morph logging during TestMain (#30948) 2025-05-21 17:31:18 +00:00
search_backfill.go MM-67540 - Allow searching public channel messages without channel membership (#35298) 2026-03-09 14:07:44 -04:00
search_backfill_test.go MM-67540 - Allow searching public channel messages without channel membership (#35298) 2026-03-09 14:07:44 -04:00
searchengine.go MM-67433: Elasticsearch health monitor (#35747) 2026-04-13 11:51:32 +02:00
searchengine_test.go MM-68532: default EnableSearchPublicChannelsWithoutMembership to true for new installations (#36399) 2026-05-06 09:13:58 -04:00
searchengine_watcher.go MM-66612: Add health flag to fast-fail when ES is offline (#35843) 2026-04-13 22:43:14 +02:00
service.go [MM-68576] Add SAML connectivity status to support packet diagnostics (#36321) 2026-05-21 10:21:34 +02:00
service_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
session.go MM-68543 Invalidate active WebConn session cache on global session revocation (#36332) 2026-05-07 09:01:36 -04:00
session_test.go Fix errcheck linter errors in helpers (#31578) 2025-11-12 13:00:51 +01:00
shared_channel_notifier.go MM-57326: [Shared Channels] Message priority, acknowledgement and persistent notifications need to be synced (#30736) 2025-06-16 02:30:21 +02:00
shared_channel_notifier_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
shared_channel_service_iface.go MM-67616: Refactor shared channel membership sync to use ChannelMemberHistory (#35619) 2026-03-23 10:12:17 -04:00
status.go [AI assisted] MM-64298: Process setting status offline in batches (#31065) 2025-06-17 09:20:34 +05:30
status_test.go Fix errcheck linter errors in helpers (#31578) 2025-11-12 13:00:51 +01:00
support_packet.go [MM-68578] Add support packet DB performance diagnostics (#36324) 2026-05-21 12:45:18 +02:00
support_packet_test.go [MM-68578] Add support packet DB performance diagnostics (#36324) 2026-05-21 12:45:18 +02:00
uptime_darwin.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
uptime_darwin_test.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
uptime_linux.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
uptime_linux_test.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
uptime_other.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
uptime_other_test.go [MM-67976] Add server uptime to support packet (#35838) 2026-04-21 10:52:10 +00:00
utils.go [MM-64654] Migrate to modern Go features (#31820) 2025-07-18 12:54:51 +02:00
web_broadcast_hook.go [MM-61775] Fix errcheck issues in server/channels/app/platform/web_broadcast_hook.go (#29514) 2025-01-27 11:26:28 +00:00
web_broadcast_hook_test.go Introduce model.AssertNotSameMap (#34058) 2025-10-27 13:16:59 -03:00
web_conn.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
web_conn_test.go Update msgpack fork dependency (#35988) 2026-04-10 15:26:36 -05:00
web_hub.go MM-68150: Upgrade golangci-lint to v2.12.2 (#36554) 2026-05-14 17:29:37 -04:00
web_hub_test.go Fix errcheck linter errors in helpers (#31578) 2025-11-12 13:00:51 +01:00
websocket_reliable.go [AI assisted] MM-63304: Wrap around dqPtr while unmarshalling (#30371) 2025-03-04 13:36:04 +05:30
websocket_reliable_test.go [MM-64654] Migrate to modern Go features (#31820) 2025-07-18 12:54:51 +02:00
websocket_router.go MM-61130: Use a channelMember map at web_hub level (#28810) 2024-11-08 09:57:54 +05:30