Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions core/Command/Db/DbInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OC\Core\Command\Db;

use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand Down Expand Up @@ -76,11 +77,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

private function getMySQLInfo(): array {
$result = $this->connection->executeQuery(
'SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
try {
return $this->getMySQLInfoUsingQuery(
'SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
@@max_connections AS max_conn, @@character_set_database AS charset,
@@transaction_isolation AS tx_isolation'
);
);
} catch (DriverException $e) {
return $this->getMySQLInfoUsingQuery('SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
@@max_connections AS max_conn, @@character_set_database AS charset,
@@tx_isolation AS tx_isolation');
}
}

private function getMySQLInfoUsingQuery(string $query): array {
$result = $this->connection->executeQuery($query);
$info = $result->fetchAssociative();

$bufferPoolGB = round(($info['buffer_pool'] / 1024 / 1024 / 1024), 2);
Expand Down
12 changes: 11 additions & 1 deletion core/Command/Db/DbLocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OC\Core\Command\Db;

use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use OC\DB\Connection;
Expand Down Expand Up @@ -74,7 +75,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}

$rows = $this->connection->executeQuery($sql)->fetchAllAssociative();
try {
$rows = $this->connection->executeQuery($sql)->fetchAllAssociative();
} catch (DriverException $e) {
if ($e->getCode() === 1227) {
$output->writeln('<comment>The configured database user doesn\'t have permissions to query active locks, PROCESS privilege required.</comment>');
} else {
$output->writeln('<comment>Failed to query active locks: ' . $e->getMessage() . '.</comment>');
}
return Command::FAILURE;
}

if (empty($rows)) {
$output->writeln('<info>No active locks or blocking transactions detected.</info>');
Expand Down
2 changes: 1 addition & 1 deletion core/Command/Db/DbSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
ROUND((data_length + index_length) / 1024 / 1024, 2) AS total_mb,
ROUND(data_length / 1024 / 1024, 2) AS data_mb,
ROUND(index_length / 1024 / 1024, 2) AS index_mb,
table_rows AS rows,
table_rows AS `rows`,
IF(table_rows > 0, ROUND((data_length + index_length) / table_rows, 0), 0) AS avg_row_bytes
FROM information_schema.tables
WHERE table_schema = DATABASE()
Expand Down
Loading