Skip to content

Commit ca09149

Browse files
committed
fix(database): keep single-attribute indexes under MariaDB 768-byte limit
- hostname column 1024 -> 255. DNS hostnames are capped at 253 chars, so the wider size never gained anything but pushed the bloom_filter index past the InnoDB/utopia-php-database 768-byte single-attribute index prefix limit. - path column stays at 1024 for data fidelity (URLs with signed query strings exceed 255), but its index entry now uses an explicit lengths=[255] so MariaDB only indexes the first 255 chars. The index validator in utopia/database treats lengths[i] as the indexLength when set, taking the column under the 768 cap while preserving the full column for stored data. Caught by CI when the full Database adapter suite ran against MariaDB — local runs skipped 45 DatabaseTest cases because pdo_mysql wasn't loaded. Verified locally now via docker-compose: 195/195 passing.
1 parent 3639dc9 commit ca09149

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/Usage/Metric.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public static function getEventSchema(): array
617617
$stringColumn('teamInternalId', 255),
618618
$stringColumn('country', 2),
619619
$stringColumn('region', 64),
620-
$stringColumn('hostname', 1024),
620+
$stringColumn('hostname', 255),
621621
$stringColumn('osCode', 256),
622622
$stringColumn('osName', 256),
623623
$stringColumn('osVersion', 255),
@@ -721,11 +721,20 @@ public static function getEventIndexes(): array
721721
];
722722

723723
return array_map(
724-
static fn (string $col): array => [
725-
'$id' => 'index-' . $col,
726-
'type' => 'key',
727-
'attributes' => [$col],
728-
],
724+
static function (string $col): array {
725+
$entry = [
726+
'$id' => 'index-' . $col,
727+
'type' => 'key',
728+
'attributes' => [$col],
729+
];
730+
// path is sized 1024 for data fidelity; cap the index key at
731+
// 255 so the MariaDB single-attribute index stays within the
732+
// 768-byte InnoDB key prefix limit.
733+
if ($col === 'path') {
734+
$entry['lengths'] = [255];
735+
}
736+
return $entry;
737+
},
729738
$indexed,
730739
);
731740
}

0 commit comments

Comments
 (0)