From 870f914552b4b223bddba6841ab0e9be23b9eec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ma=C5=82ysa?= Date: Mon, 14 Oct 2024 00:44:37 +0200 Subject: [PATCH 1/2] ci: fix CI builds on Ubuntu 24.04 images --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceadf80b..2e2ad223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ jobs: image: debian:bookworm options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -27,6 +28,7 @@ jobs: image: ubuntu:24.04 options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -46,6 +48,7 @@ jobs: image: fedora:39 options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -64,6 +67,7 @@ jobs: image: archlinux options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -82,6 +86,7 @@ jobs: image: debian:bookworm options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -102,6 +107,7 @@ jobs: image: debian:bookworm options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -121,6 +127,7 @@ jobs: image: ubuntu:24.04 options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -140,6 +147,7 @@ jobs: image: fedora:39 options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -158,6 +166,7 @@ jobs: image: archlinux options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup @@ -176,6 +185,7 @@ jobs: image: debian:bookworm options: --security-opt seccomp=unconfined --privileged --security-opt systempaths=unconfined # needed to make clone3() work in the container, and mount cgroup2 read-write, and /proc mountable steps: + - run: echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns - run: mount -t cgroup2 -o nsdelegate,remount none /sys/fs/cgroup - run: useradd tester - run: chown -R tester:tester /sys/fs/cgroup From f66103bc4cb0540a7dac37d59b475650ea77fa0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ma=C5=82ysa?= Date: Fri, 1 Nov 2024 14:00:28 +0100 Subject: [PATCH 2/2] sim: add missing indexes for fast ranking generation --- subprojects/sim/src/sim/db/schema.cc | 7 +++++++ subprojects/sim/src/sim_upgrader.cc | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/subprojects/sim/src/sim/db/schema.cc b/subprojects/sim/src/sim/db/schema.cc index 86086e10..70b53c01 100644 --- a/subprojects/sim/src/sim/db/schema.cc +++ b/subprojects/sim/src/sim/db/schema.cc @@ -322,6 +322,13 @@ const DbSchema& get_schema() { " KEY `for_contest_initial_problem_final_by_score_and_full_status` (`initial_final_candidate`,`user_id`,`contest_problem_id`,`score` DESC,`full_status`,`id` DESC)," // Needed to efficiently query contest view coloring " KEY `initial_final` (`user_id`,`contest_problem_id`,`contest_problem_initial_final`)," + // For ranking + " KEY `contest_final` (`contest_id`,`contest_problem_final`)," + " KEY `contest_initial_final` (`contest_id`,`contest_problem_initial_final`)," + " KEY `contest_round_final` (`contest_round_id`,`contest_problem_final`)," + " KEY `contest_initial_round_final` (`contest_round_id`,`contest_problem_initial_final`)," + " KEY `contest_problem_final` (`contest_problem_id`,`contest_problem_final`)," + " KEY `contest_initial_problem_final` (`contest_problem_id`,`contest_problem_initial_final`)," // For foreign keys " KEY `file_id` (`file_id`)," " CONSTRAINT `submissions_ibfk_1` FOREIGN KEY (`file_id`) REFERENCES `internal_files` (`id`) ON UPDATE CASCADE," diff --git a/subprojects/sim/src/sim_upgrader.cc b/subprojects/sim/src/sim_upgrader.cc index df97cdc0..882d4b22 100644 --- a/subprojects/sim/src/sim_upgrader.cc +++ b/subprojects/sim/src/sim_upgrader.cc @@ -40,7 +40,7 @@ run_command(const vector& args, const Spawner::Options& options = {}) { // Update the below hash and body of the function do_perform_upgrade() constexpr StringView NORMALIZED_SCHEMA_HASH_BEFORE_UPGRADE = - "bffaa77f52297395cf099de1afdc67b919d37a5e0143a64d6f046583037915d8"; + "935264658c3a283d37e125526d67102dd03f4596fdfb704d970cd227c48d8bda"; static void do_perform_upgrade( [[maybe_unused]] const string& sim_dir, [[maybe_unused]] sim::mysql::Connection& mysql @@ -48,9 +48,19 @@ static void do_perform_upgrade( STACK_UNWINDING_MARK; // Upgrade here - mysql.execute("ALTER TABLE add_problem_jobs DROP COLUMN added_problem_id"); - mysql.execute("ALTER TABLE reupload_problem_jobs DROP COLUMN problem_id"); - mysql.execute("ALTER TABLE problem_tags MODIFY is_hidden tinyint(1) NOT NULL AFTER problem_id"); + mysql.execute( + "ALTER TABLE submissions ADD KEY `contest_final` (`contest_id`,`contest_problem_final`)" + ); + mysql.execute("ALTER TABLE submissions ADD KEY `contest_initial_final` (`contest_id`," + "`contest_problem_initial_final`)"); + mysql.execute("ALTER TABLE submissions ADD KEY `contest_round_final` (`contest_round_id`," + "`contest_problem_final`)"); + mysql.execute("ALTER TABLE submissions ADD KEY `contest_initial_round_final` " + "(`contest_round_id`,`contest_problem_initial_final`)"); + mysql.execute("ALTER TABLE submissions ADD KEY `contest_problem_final` (`contest_problem_id`," + "`contest_problem_final`)"); + mysql.execute("ALTER TABLE submissions ADD KEY `contest_initial_problem_final` " + "(`contest_problem_id`,`contest_problem_initial_final`)"); } enum class LockKind {