From 9a4f175f2c1ccf4f111ae0c3b4ad548b0dc72d55 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:40:56 +0000 Subject: [PATCH 1/4] CI: stop the macOS PostgreSQL E2E from hanging until the job is cancelled Both macOS E2E jobs on c46b4a5 stalled inside the PostgreSQL suite (right after a test's setup began its TRUNCATEs) and were cancelled after 10 minutes. The same suite passes in 13 s on the same runner image, PostgreSQL and gem versions, so this is a nondeterministic stall, not a regression of the gem bump. * turn off fsync / synchronous_commit / full_page_writes on the CI database: the tests need no durability and TRUNCATE is fsync-heavy (the probable cause) * tests/hang_watchdog.rb: a test running longer than E2E_TEST_TIMEOUT (120 s) prints its thread backtraces and the PostgreSQL sessions / ungranted locks, then exits 1, so a hang fails with a diagnosis * a timeout-minutes per E2E step, so a stall fails its own step instead of the job being cancelled * docs/Testing.md describes the watchdog Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01FskpZCiq2EczacwHZtE6Uo --- .github/workflows/cross-platform.yml | 14 +++++ docs/Testing.md | 6 ++ tests/end2end_mysql2.rb | 1 + tests/end2end_pg.rb | 17 ++++++ tests/end2end_sqlite3.rb | 1 + tests/hang_watchdog.rb | 82 ++++++++++++++++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 tests/hang_watchdog.rb diff --git a/.github/workflows/cross-platform.yml b/.github/workflows/cross-platform.yml index 96d63d1..289579f 100644 --- a/.github/workflows/cross-platform.yml +++ b/.github/workflows/cross-platform.yml @@ -153,6 +153,16 @@ jobs: - name: Generate the E2E examples with the WASM run: ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.ci.yaml --generate-gemfile + # the tests TRUNCATE a dozen tables in every setup and need no durability: with fsync on, a flush that stalls on a + # macOS runner freezes the suite (both macOS E2E jobs hung inside a setup's TRUNCATEs and were cancelled after 10 minutes) + - name: Turn off PostgreSQL durability (tests only) + run: | + psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" \ + -c 'ALTER SYSTEM SET fsync = off' \ + -c 'ALTER SYSTEM SET synchronous_commit = off' \ + -c 'ALTER SYSTEM SET full_page_writes = off' \ + -c 'SELECT pg_reload_conf()' + - name: Create the schemas (and allow LOAD DATA LOCAL INFILE for :copyfrom) run: | psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql @@ -184,24 +194,28 @@ jobs: - name: End-to-End tests (SQLite) if: ${{ !cancelled() }} + timeout-minutes: 4 env: EXAMPLES_DRIVER: sqlite3 run: bundle install && bundle exec rake end2end_sqlite3 - name: End-to-End tests (PostgreSQL ${{ matrix.postgres-version }}) if: ${{ !cancelled() }} + timeout-minutes: 4 env: EXAMPLES_DRIVER: pg run: bundle install && bundle exec rake end2end_pg - name: End-to-End tests (MySQL 8.4) if: ${{ !cancelled() }} + timeout-minutes: 5 env: EXAMPLES_DRIVER: mysql2 run: bundle install && bundle exec rake end2end_mysql2 - name: Generator options E2E if: ${{ !cancelled() }} + timeout-minutes: 3 env: BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.options.e2e # default gem path (only prebuilt gems): with BUNDLE_PATH, the test's nested `bundle install` on Windows Ruby diff --git a/docs/Testing.md b/docs/Testing.md index 0459f7f..1260d35 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -57,6 +57,12 @@ The servers are configured with `DB_NAME`, `DB_USER`, `DB_PASS`, `POSTGRES_HOST` `*_PORT`). The MySQL tests connect without a password (`DB_PASS` is only used for PostgreSQL), so use a MySQL user that has none. +A test that runs longer than `E2E_TEST_TIMEOUT` seconds (default 120; the slowest real test takes a few seconds) is +reported by `tests/hang_watchdog.rb`: the test, every thread's backtrace and, for PostgreSQL, the server's sessions and +the locks nobody got. The process then exits with status 1, so a stuck suite fails with a diagnosis instead of CI +cancelling the whole job. The cross-platform workflow also gives each E2E step its own `timeout-minutes` and turns off +PostgreSQL's `fsync` / `synchronous_commit` / `full_page_writes` (the tests need no durability). + What each test proves is listed in [Coverage](Coverage.md). ## CI workflows (`.github/workflows/`) diff --git a/tests/end2end_mysql2.rb b/tests/end2end_mysql2.rb index 1c0ec72..50ecf00 100755 --- a/tests/end2end_mysql2.rb +++ b/tests/end2end_mysql2.rb @@ -13,6 +13,7 @@ require_relative 'consts' require_relative 'rbs_types' require_relative 'app_helpers' +require_relative 'hang_watchdog' require 'delegate' require File.join(EXAMPLES_DIR, 'mysql2/query_sql') RbsTypes.install(Object.const_get("#{ENV.fetch('EXAMPLES_MODULE', 'Mysql2Codegen')}::QuerySql"), diff --git a/tests/end2end_pg.rb b/tests/end2end_pg.rb index fb8a8ac..c8b4755 100755 --- a/tests/end2end_pg.rb +++ b/tests/end2end_pg.rb @@ -14,6 +14,7 @@ require_relative 'consts' require_relative 'rbs_types' require_relative 'app_helpers' +require_relative 'hang_watchdog' require 'delegate' require 'json' require 'uri' @@ -21,6 +22,22 @@ RbsTypes.install(Object.const_get("#{ENV.fetch('EXAMPLES_MODULE', 'PgCodegen')}::QuerySql"), File.join(EXAMPLES_DIR, 'pg/query_sql.rbs')) +# a hanging test also reports the server's sessions and the locks nobody got (see hang_watchdog.rb) +HangWatchdog.diagnose do + params = { dbname: ENV.fetch('DB_NAME', nil), host: ENV.fetch('POSTGRES_HOST', nil), port: ENV.fetch('POSTGRES_PORT', nil), + user: ENV.fetch('DB_USER', nil), password: ENV.fetch('DB_PASS', nil), connect_timeout: 5 }.compact + PG.connect(**params) do |admin| + queries = { + 'pg_stat_activity (pid | state | wait | in state | query)' => + "SELECT pid, state, wait_event_type || '/' || wait_event, now() - state_change, left(query, 100) FROM pg_stat_activity " \ + 'WHERE datname = current_database() AND pid <> pg_backend_pid() ORDER BY pid', + 'locks not granted (pid | mode | type | relation)' => + 'SELECT pid, mode, locktype, relation::regclass FROM pg_locks WHERE NOT granted' + } + queries.map { |title, sql| "#{title}:\n" + admin.exec(sql).values.map { |row| " #{row.join(' | ')}" }.join("\n") }.join("\n") + end +end + # End-to-end tests of the code generated for examples/authors/postgresql, against a real PostgreSQL server. class TestPg < Minitest::Test include Object.const_get(ENV.fetch('EXAMPLES_MODULE', 'PgCodegen')) diff --git a/tests/end2end_sqlite3.rb b/tests/end2end_sqlite3.rb index 2f0fb9d..ade0073 100644 --- a/tests/end2end_sqlite3.rb +++ b/tests/end2end_sqlite3.rb @@ -12,6 +12,7 @@ require_relative 'consts' require_relative 'rbs_types' require_relative 'app_helpers' +require_relative 'hang_watchdog' require 'delegate' require 'json' require File.join(EXAMPLES_DIR, 'sqlite3/query_sql') diff --git a/tests/hang_watchdog.rb b/tests/hang_watchdog.rb new file mode 100644 index 0000000..893e146 --- /dev/null +++ b/tests/hang_watchdog.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require 'minitest' + +# Turns a hanging end-to-end test into a failure that says where it hangs. +# +# Without it a stuck test (a blocked query, a lock, a child process that never exits) shows nothing in the log +# until CI cancels the whole job after its timeout. With it, a test that runs for more than E2E_TEST_TIMEOUT seconds +# (default 120; the slowest real test takes a few seconds) prints the test, every thread's backtrace and what the +# registered diagnostics report (the PostgreSQL suite adds the server's sessions and ungranted locks), then exits +# with status 1. +module HangWatchdog + LIMIT = Integer(ENV.fetch('E2E_TEST_TIMEOUT', '120')) + + @mutex = Mutex.new + @running = nil + @diagnostics = [] + @thread = nil + + class << self + # block: returns a String (or lines) describing the database's state; it runs when a test hangs + def diagnose(&block) + @mutex.synchronize { @diagnostics << block } + end + + def started(test) + watch + @mutex.synchronize { @running = [test, clock] } + end + + def finished + @mutex.synchronize { @running = nil } + end + + private + + def clock = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) + + def watch + @thread ||= ::Thread.new do + ::Thread.current.report_on_exception = false + loop do + sleep 1 + test, since = @mutex.synchronize { @running } + report(test, clock - since) if test && clock - since > LIMIT + end + end + end + + def report(test, seconds) + out = ["", "HANG: #{test} has been running for #{seconds.round}s (limit #{LIMIT}s, E2E_TEST_TIMEOUT)"] + ::Thread.list.each do |thread| + out << "#{thread.inspect} (#{thread == ::Thread.main ? 'main' : 'other'})" + out.concat((thread.backtrace || []).first(40).map { |line| " #{line}" }) + end + diagnostics.each do |block| + out << block.call + rescue ::StandardError, ::Timeout::Error => e + out << "diagnostics failed: #{e.class}: #{e.message}" + end + warn out.join("\n") + $stderr.flush + exit!(1) + end + + def diagnostics = @mutex.synchronize { @diagnostics.dup } + end + + # Minitest::Test calls these around every test. + def before_setup + HangWatchdog.started("#{self.class}##{name}") + super + end + + def after_teardown + super + ensure + HangWatchdog.finished + end +end + +Minitest::Test.include(HangWatchdog) From ca716d18e57d600b7d18aab68a224027a7951184 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:44:28 +0000 Subject: [PATCH 2/4] TEMPORARY: stress the macOS PostgreSQL E2E to see whether the hang reproduces Runs the suite 4 x 20 times on macOS with the old settings and 4 x 20 with the tuned ones. Deleted again before the PR is merged. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01FskpZCiq2EczacwHZtE6Uo --- .github/stress/Gemfile | 12 ++++ .github/workflows/stress-macos-pg.yml | 97 +++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 .github/stress/Gemfile create mode 100644 .github/workflows/stress-macos-pg.yml diff --git a/.github/stress/Gemfile b/.github/stress/Gemfile new file mode 100644 index 0000000..4fbfcaa --- /dev/null +++ b/.github/stress/Gemfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# TEMPORARY (stress-macos-pg.yml): the gems the PostgreSQL E2E suite needs, nothing else. +source 'https://rubygems.org' + +gem 'async', '>= 2.7' +gem 'bigdecimal' +gem 'connection_pool' +gem 'logger' +gem 'minitest' +gem 'pg' +gem 'rake' diff --git a/.github/workflows/stress-macos-pg.yml b/.github/workflows/stress-macos-pg.yml new file mode 100644 index 0000000..15a4ddb --- /dev/null +++ b/.github/workflows/stress-macos-pg.yml @@ -0,0 +1,97 @@ +name: Stress macOS PostgreSQL E2E (temporary) + +# TEMPORARY, only on the branch that investigates the macOS E2E hang (never merged): runs the PostgreSQL E2E suite +# many times on macOS with the old settings (default durability, as in the failing run) and with the tuned ones, +# to see whether the hang reproduces and whether the tuning removes it. A hang is reported by tests/hang_watchdog.rb. +on: + push: + branches: [ci/macos-e2e-hang] + paths: + - .github/workflows/stress-macos-pg.yml + - .github/stress/** + +defaults: + run: + shell: bash + +permissions: + contents: read + +concurrency: + group: stress-macos-pg-${{ github.ref }} + cancel-in-progress: true + +jobs: + stress: + name: ${{ matrix.variant }} #${{ matrix.shard }} + runs-on: macos-latest + timeout-minutes: 25 + + strategy: + fail-fast: false + matrix: + variant: [old-settings, tuned] + shard: [1, 2, 3, 4] + + env: + DB_NAME: tests + DB_USER: root + DB_PASS: pass + POSTGRES_HOST: 127.0.0.1 + EXAMPLES_DRIVER: pg + BUNDLE_GEMFILE: ${{ github.workspace }}/.github/stress/Gemfile + E2E_TEST_TIMEOUT: '45' + ITERATIONS: '20' + + steps: + - uses: actions/checkout@v7 + + - uses: ankane/setup-postgres@b1a598d92f86cb2ed364411898d150d4eac6d5ca # v1 + with: + postgres-version: '16' + database: ${{ env.DB_NAME }} + user: ${{ env.DB_USER }} + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '4.0' + + - name: Create the schema + run: psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql + + - name: Turn off PostgreSQL durability (tuned only) + if: matrix.variant == 'tuned' + run: | + psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" \ + -c 'ALTER SYSTEM SET fsync = off' \ + -c 'ALTER SYSTEM SET synchronous_commit = off' \ + -c 'ALTER SYSTEM SET full_page_writes = off' \ + -c 'SELECT pg_reload_conf()' + + - name: Show the server settings + run: psql -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -c 'SELECT name, setting FROM pg_settings WHERE name IN ($$fsync$$, $$synchronous_commit$$, $$full_page_writes$$, $$max_connections$$, $$wal_sync_method$$) ORDER BY name' + + - run: bundle install + + - name: Run the PostgreSQL suite ${{ env.ITERATIONS }} times + run: | + mkdir -p logs + hangs=0 + failures=0 + for i in $(seq 1 "${ITERATIONS}"); do + start=$(date +%s) + if bundle exec ruby tests/end2end_pg.rb > "logs/run-${i}.log" 2>&1; then + status=ok + elif grep -q '^HANG:' "logs/run-${i}.log"; then + status=HANG + hangs=$((hangs + 1)) + echo "::group::iteration ${i}: HANG"; grep -A60 '^HANG:' "logs/run-${i}.log" | head -150; echo "::endgroup::" + else + status=FAILED + failures=$((failures + 1)) + echo "::group::iteration ${i}: FAILED"; tail -60 "logs/run-${i}.log"; echo "::endgroup::" + fi + echo "iteration ${i}: ${status} in $(( $(date +%s) - start ))s ($(grep -o 'seed [0-9]*' "logs/run-${i}.log" | head -1))" + done + echo "### ${{ matrix.variant }} #${{ matrix.shard }}: ${hangs} hangs, ${failures} other failures in ${ITERATIONS} runs" | tee -a "$GITHUB_STEP_SUMMARY" + [ "${hangs}" -eq 0 ] && [ "${failures}" -eq 0 ] From 006c2bf3c7a0611f95b5e9ff8e95a2cec0f9e99c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:54:40 +0000 Subject: [PATCH 3/4] TEMPORARY: stress the real macOS E2E job, with and without the PostgreSQL tuning Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01FskpZCiq2EczacwHZtE6Uo --- .github/workflows/stress-macos-real.yml | 204 ++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 .github/workflows/stress-macos-real.yml diff --git a/.github/workflows/stress-macos-real.yml b/.github/workflows/stress-macos-real.yml new file mode 100644 index 0000000..84fddc8 --- /dev/null +++ b/.github/workflows/stress-macos-real.yml @@ -0,0 +1,204 @@ +name: Stress the real macOS E2E job (temporary) + +# TEMPORARY, only on the branch that investigates the macOS E2E hang (never merged): the real cross-platform macOS +# E2E job (MySQL installed next to PostgreSQL, SQLite suite first, gem cache, generated examples), repeated, with and +# without the PostgreSQL tuning of this branch. +on: + push: + branches: [ci/macos-e2e-hang] + paths: + - .github/workflows/stress-macos-real.yml + +defaults: + run: + shell: bash + +permissions: + contents: read + +concurrency: + group: stress-macos-real-${{ github.ref }} + cancel-in-progress: true + +env: + DB_NAME: tests + DB_USER: root + DB_PASS: pass # ignored by the servers below (trust / empty-password root), required by the pg tests' env + POSTGRES_HOST: 127.0.0.1 + MYSQL_HOST: 127.0.0.1 + +jobs: + build-wasm: + name: Build (WASM) + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v7 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + # the plugin (pure Ruby) + the prebuilt ruby.wasm interpreter, packed into one self-contained module + - name: Build WASM plugin + run: ./scripts/wasm/build.sh + + - name: upload wasm plugin as artifact + uses: actions/upload-artifact@v7 + with: + name: wasm-file + path: dist/plugin.wasm + + + end2end: + name: real job, ruby ${{ matrix.ruby-version }}, tuned=${{ matrix.tune }} #${{ matrix.rep }} + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + + needs: [build-wasm] + strategy: + fail-fast: false + matrix: + ruby-version: ['3.1', '4.0'] + tune: [false, true] + rep: [1, 2, 3] + include: + - { os: macos-latest, os-name: macOS, postgres-version: '16' } + + env: + EXAMPLES_DIR: ${{ github.workspace }}/.examples-ruby-${{ matrix.ruby-version }} + BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.e2e + BUNDLE_PATH: ${{ github.workspace }}/.e2e-gems + + steps: + - uses: actions/checkout@v7 + + - name: Load tool versions + run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" + + - uses: sqlc-dev/setup-sqlc@bac53b7fb28c039a6c7f5736fd1e89744021bdd6 # v5.0.0 + with: + sqlc-version: '${{ env.SQLC_VERSION }}' + + - uses: ankane/setup-postgres@b1a598d92f86cb2ed364411898d150d4eac6d5ca # v1 + with: + postgres-version: ${{ matrix.postgres-version }} + database: ${{ env.DB_NAME }} + user: ${{ env.DB_USER }} + + - uses: ankane/setup-mysql@4aa1b08412d4c8bf537fea5bc412e4e831d839d7 # v1 + if: runner.os != 'Windows' + with: + mysql-version: '8.4' + database: ${{ env.DB_NAME }} + user: ${{ env.DB_USER }} + + # windows-2025 ships MySQL 8.4 (on PATH); setup-mysql only treats 8.0 as preinstalled there and fails to + # reinstall 8.4 over it, so start the image's server the same way the action does + - name: Start the preinstalled MySQL 8.4 (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + $bin = 'C:\Program Files\MySQL\MySQL Server 8.4\bin' + & "$bin\mysqld" --initialize-insecure + & "$bin\mysqld" --install + net start MySQL + & "$bin\mysqladmin" -u $env:DB_USER create $env:DB_NAME + + # after the databases: their bin dirs (PostgreSQL ships its own zlib/iconv DLLs) must come after Ruby's MSYS2 + # toolchain on PATH, or gcc fails silently on Windows and no native gem builds + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - uses: actions/download-artifact@v8 + with: + name: wasm-file + path: dist + + - name: Updating plugin sha + run: ./scripts/wasm/update_sha.sh sqlc.ci.yaml + + # the E2E suites below run this WASM output, with the Gemfile it generates + - name: Generate the E2E examples with the WASM + run: ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.ci.yaml --generate-gemfile + + # the tests TRUNCATE a dozen tables in every setup and need no durability: with fsync on, a flush that stalls on a + # macOS runner freezes the suite (both macOS E2E jobs hung inside a setup's TRUNCATEs and were cancelled after 10 minutes) + - name: Turn off PostgreSQL durability (tests only) + if: matrix.tune + run: | + psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" \ + -c 'ALTER SYSTEM SET fsync = off' \ + -c 'ALTER SYSTEM SET synchronous_commit = off' \ + -c 'ALTER SYSTEM SET full_page_writes = off' \ + -c 'SELECT pg_reload_conf()' + + - name: Create the schemas (and allow LOAD DATA LOCAL INFILE for :copyfrom) + run: | + psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql + mysql -h "${MYSQL_HOST}" -u "${DB_USER}" -e 'SET GLOBAL local_infile = 1' + mysql -h "${MYSQL_HOST}" -u "${DB_USER}" --default-character-set=utf8mb4 "${DB_NAME}" < examples/authors/mysql/schema.sql + + - name: Native build settings for mysql2 + run: | + if [ "${RUNNER_OS}" = Windows ]; then + ridk.cmd exec pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-libmariadbclient + # mysql2's extconf can't glob for mariadb_config.exe through Windows PATH entries, so point at it + mariadb_config=$(cygpath -m "${RI_DEVKIT}/ucrt64/bin/mariadb_config.exe") + test -x "${mariadb_config}" + echo "BUNDLE_BUILD__MYSQL2=--with-mysql-config=${mariadb_config}" >> "$GITHUB_ENV" + else + echo "BUNDLE_BUILD__MYSQL2=--with-opt-dir=$(brew --prefix openssl@3):$(brew --prefix zstd)" >> "$GITHUB_ENV" + fi + + # prism (minitest 6), mysql2 and date compile from source on Windows (~2 min): keep the installed E2E gems, per runner + # image (the native extensions link against its libraries) + - name: Runner image + id: image + run: echo "version=${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT" + + - uses: actions/cache@v6 + with: + path: ${{ env.BUNDLE_PATH }} + key: e2e-gems-${{ steps.image.outputs.version }}-ruby${{ matrix.ruby-version }}-${{ hashFiles('Gemfile.e2e') }} + + - name: End-to-End tests (SQLite) + if: ${{ !cancelled() }} + timeout-minutes: 4 + env: + EXAMPLES_DRIVER: sqlite3 + run: bundle install && bundle exec rake end2end_sqlite3 + + - name: End-to-End tests (PostgreSQL ${{ matrix.postgres-version }}) + if: ${{ !cancelled() }} + timeout-minutes: 4 + env: + EXAMPLES_DRIVER: pg + run: bundle install && bundle exec rake end2end_pg + + - name: End-to-End tests (MySQL 8.4) + if: ${{ !cancelled() }} + timeout-minutes: 5 + env: + EXAMPLES_DRIVER: mysql2 + run: bundle install && bundle exec rake end2end_mysql2 + + - name: Generator options E2E + if: ${{ !cancelled() }} + timeout-minutes: 3 + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.options.e2e + # default gem path (only prebuilt gems): with BUNDLE_PATH, the test's nested `bundle install` on Windows Ruby + # 3.1 trips over setup-ruby's newer Bundler next to the default 2.3 one + run: | + unset BUNDLE_PATH + bundle install && bundle exec ruby tests/end2end_options.rb + + - name: Native extension build logs + if: failure() + run: find "$(ruby -e 'print Gem.dir')" -name mkmf.log -exec sh -c 'echo "== $1"; cat "$1"' _ {} \; From 1802d2b49bd6d781d66f52edc6b395e1df619e59 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 14:13:15 +0000 Subject: [PATCH 4/4] Remove the temporary stress workflows They ran the macOS PostgreSQL suite 160 times and the real macOS E2E job 12 times with and without the PostgreSQL tuning; nothing reproduced the hang. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01FskpZCiq2EczacwHZtE6Uo --- .github/stress/Gemfile | 12 -- .github/workflows/stress-macos-pg.yml | 97 ----------- .github/workflows/stress-macos-real.yml | 204 ------------------------ 3 files changed, 313 deletions(-) delete mode 100644 .github/stress/Gemfile delete mode 100644 .github/workflows/stress-macos-pg.yml delete mode 100644 .github/workflows/stress-macos-real.yml diff --git a/.github/stress/Gemfile b/.github/stress/Gemfile deleted file mode 100644 index 4fbfcaa..0000000 --- a/.github/stress/Gemfile +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -# TEMPORARY (stress-macos-pg.yml): the gems the PostgreSQL E2E suite needs, nothing else. -source 'https://rubygems.org' - -gem 'async', '>= 2.7' -gem 'bigdecimal' -gem 'connection_pool' -gem 'logger' -gem 'minitest' -gem 'pg' -gem 'rake' diff --git a/.github/workflows/stress-macos-pg.yml b/.github/workflows/stress-macos-pg.yml deleted file mode 100644 index 15a4ddb..0000000 --- a/.github/workflows/stress-macos-pg.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Stress macOS PostgreSQL E2E (temporary) - -# TEMPORARY, only on the branch that investigates the macOS E2E hang (never merged): runs the PostgreSQL E2E suite -# many times on macOS with the old settings (default durability, as in the failing run) and with the tuned ones, -# to see whether the hang reproduces and whether the tuning removes it. A hang is reported by tests/hang_watchdog.rb. -on: - push: - branches: [ci/macos-e2e-hang] - paths: - - .github/workflows/stress-macos-pg.yml - - .github/stress/** - -defaults: - run: - shell: bash - -permissions: - contents: read - -concurrency: - group: stress-macos-pg-${{ github.ref }} - cancel-in-progress: true - -jobs: - stress: - name: ${{ matrix.variant }} #${{ matrix.shard }} - runs-on: macos-latest - timeout-minutes: 25 - - strategy: - fail-fast: false - matrix: - variant: [old-settings, tuned] - shard: [1, 2, 3, 4] - - env: - DB_NAME: tests - DB_USER: root - DB_PASS: pass - POSTGRES_HOST: 127.0.0.1 - EXAMPLES_DRIVER: pg - BUNDLE_GEMFILE: ${{ github.workspace }}/.github/stress/Gemfile - E2E_TEST_TIMEOUT: '45' - ITERATIONS: '20' - - steps: - - uses: actions/checkout@v7 - - - uses: ankane/setup-postgres@b1a598d92f86cb2ed364411898d150d4eac6d5ca # v1 - with: - postgres-version: '16' - database: ${{ env.DB_NAME }} - user: ${{ env.DB_USER }} - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '4.0' - - - name: Create the schema - run: psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql - - - name: Turn off PostgreSQL durability (tuned only) - if: matrix.variant == 'tuned' - run: | - psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" \ - -c 'ALTER SYSTEM SET fsync = off' \ - -c 'ALTER SYSTEM SET synchronous_commit = off' \ - -c 'ALTER SYSTEM SET full_page_writes = off' \ - -c 'SELECT pg_reload_conf()' - - - name: Show the server settings - run: psql -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -c 'SELECT name, setting FROM pg_settings WHERE name IN ($$fsync$$, $$synchronous_commit$$, $$full_page_writes$$, $$max_connections$$, $$wal_sync_method$$) ORDER BY name' - - - run: bundle install - - - name: Run the PostgreSQL suite ${{ env.ITERATIONS }} times - run: | - mkdir -p logs - hangs=0 - failures=0 - for i in $(seq 1 "${ITERATIONS}"); do - start=$(date +%s) - if bundle exec ruby tests/end2end_pg.rb > "logs/run-${i}.log" 2>&1; then - status=ok - elif grep -q '^HANG:' "logs/run-${i}.log"; then - status=HANG - hangs=$((hangs + 1)) - echo "::group::iteration ${i}: HANG"; grep -A60 '^HANG:' "logs/run-${i}.log" | head -150; echo "::endgroup::" - else - status=FAILED - failures=$((failures + 1)) - echo "::group::iteration ${i}: FAILED"; tail -60 "logs/run-${i}.log"; echo "::endgroup::" - fi - echo "iteration ${i}: ${status} in $(( $(date +%s) - start ))s ($(grep -o 'seed [0-9]*' "logs/run-${i}.log" | head -1))" - done - echo "### ${{ matrix.variant }} #${{ matrix.shard }}: ${hangs} hangs, ${failures} other failures in ${ITERATIONS} runs" | tee -a "$GITHUB_STEP_SUMMARY" - [ "${hangs}" -eq 0 ] && [ "${failures}" -eq 0 ] diff --git a/.github/workflows/stress-macos-real.yml b/.github/workflows/stress-macos-real.yml deleted file mode 100644 index 84fddc8..0000000 --- a/.github/workflows/stress-macos-real.yml +++ /dev/null @@ -1,204 +0,0 @@ -name: Stress the real macOS E2E job (temporary) - -# TEMPORARY, only on the branch that investigates the macOS E2E hang (never merged): the real cross-platform macOS -# E2E job (MySQL installed next to PostgreSQL, SQLite suite first, gem cache, generated examples), repeated, with and -# without the PostgreSQL tuning of this branch. -on: - push: - branches: [ci/macos-e2e-hang] - paths: - - .github/workflows/stress-macos-real.yml - -defaults: - run: - shell: bash - -permissions: - contents: read - -concurrency: - group: stress-macos-real-${{ github.ref }} - cancel-in-progress: true - -env: - DB_NAME: tests - DB_USER: root - DB_PASS: pass # ignored by the servers below (trust / empty-password root), required by the pg tests' env - POSTGRES_HOST: 127.0.0.1 - MYSQL_HOST: 127.0.0.1 - -jobs: - build-wasm: - name: Build (WASM) - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v7 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.3' - bundler-cache: true - - # the plugin (pure Ruby) + the prebuilt ruby.wasm interpreter, packed into one self-contained module - - name: Build WASM plugin - run: ./scripts/wasm/build.sh - - - name: upload wasm plugin as artifact - uses: actions/upload-artifact@v7 - with: - name: wasm-file - path: dist/plugin.wasm - - - end2end: - name: real job, ruby ${{ matrix.ruby-version }}, tuned=${{ matrix.tune }} #${{ matrix.rep }} - runs-on: ${{ matrix.os }} - timeout-minutes: 10 - - needs: [build-wasm] - strategy: - fail-fast: false - matrix: - ruby-version: ['3.1', '4.0'] - tune: [false, true] - rep: [1, 2, 3] - include: - - { os: macos-latest, os-name: macOS, postgres-version: '16' } - - env: - EXAMPLES_DIR: ${{ github.workspace }}/.examples-ruby-${{ matrix.ruby-version }} - BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.e2e - BUNDLE_PATH: ${{ github.workspace }}/.e2e-gems - - steps: - - uses: actions/checkout@v7 - - - name: Load tool versions - run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" - - - uses: sqlc-dev/setup-sqlc@bac53b7fb28c039a6c7f5736fd1e89744021bdd6 # v5.0.0 - with: - sqlc-version: '${{ env.SQLC_VERSION }}' - - - uses: ankane/setup-postgres@b1a598d92f86cb2ed364411898d150d4eac6d5ca # v1 - with: - postgres-version: ${{ matrix.postgres-version }} - database: ${{ env.DB_NAME }} - user: ${{ env.DB_USER }} - - - uses: ankane/setup-mysql@4aa1b08412d4c8bf537fea5bc412e4e831d839d7 # v1 - if: runner.os != 'Windows' - with: - mysql-version: '8.4' - database: ${{ env.DB_NAME }} - user: ${{ env.DB_USER }} - - # windows-2025 ships MySQL 8.4 (on PATH); setup-mysql only treats 8.0 as preinstalled there and fails to - # reinstall 8.4 over it, so start the image's server the same way the action does - - name: Start the preinstalled MySQL 8.4 (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $true - $bin = 'C:\Program Files\MySQL\MySQL Server 8.4\bin' - & "$bin\mysqld" --initialize-insecure - & "$bin\mysqld" --install - net start MySQL - & "$bin\mysqladmin" -u $env:DB_USER create $env:DB_NAME - - # after the databases: their bin dirs (PostgreSQL ships its own zlib/iconv DLLs) must come after Ruby's MSYS2 - # toolchain on PATH, or gcc fails silently on Windows and no native gem builds - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - - - uses: actions/download-artifact@v8 - with: - name: wasm-file - path: dist - - - name: Updating plugin sha - run: ./scripts/wasm/update_sha.sh sqlc.ci.yaml - - # the E2E suites below run this WASM output, with the Gemfile it generates - - name: Generate the E2E examples with the WASM - run: ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.ci.yaml --generate-gemfile - - # the tests TRUNCATE a dozen tables in every setup and need no durability: with fsync on, a flush that stalls on a - # macOS runner freezes the suite (both macOS E2E jobs hung inside a setup's TRUNCATEs and were cancelled after 10 minutes) - - name: Turn off PostgreSQL durability (tests only) - if: matrix.tune - run: | - psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" \ - -c 'ALTER SYSTEM SET fsync = off' \ - -c 'ALTER SYSTEM SET synchronous_commit = off' \ - -c 'ALTER SYSTEM SET full_page_writes = off' \ - -c 'SELECT pg_reload_conf()' - - - name: Create the schemas (and allow LOAD DATA LOCAL INFILE for :copyfrom) - run: | - psql -v ON_ERROR_STOP=1 -h "${POSTGRES_HOST}" -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql - mysql -h "${MYSQL_HOST}" -u "${DB_USER}" -e 'SET GLOBAL local_infile = 1' - mysql -h "${MYSQL_HOST}" -u "${DB_USER}" --default-character-set=utf8mb4 "${DB_NAME}" < examples/authors/mysql/schema.sql - - - name: Native build settings for mysql2 - run: | - if [ "${RUNNER_OS}" = Windows ]; then - ridk.cmd exec pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-libmariadbclient - # mysql2's extconf can't glob for mariadb_config.exe through Windows PATH entries, so point at it - mariadb_config=$(cygpath -m "${RI_DEVKIT}/ucrt64/bin/mariadb_config.exe") - test -x "${mariadb_config}" - echo "BUNDLE_BUILD__MYSQL2=--with-mysql-config=${mariadb_config}" >> "$GITHUB_ENV" - else - echo "BUNDLE_BUILD__MYSQL2=--with-opt-dir=$(brew --prefix openssl@3):$(brew --prefix zstd)" >> "$GITHUB_ENV" - fi - - # prism (minitest 6), mysql2 and date compile from source on Windows (~2 min): keep the installed E2E gems, per runner - # image (the native extensions link against its libraries) - - name: Runner image - id: image - run: echo "version=${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT" - - - uses: actions/cache@v6 - with: - path: ${{ env.BUNDLE_PATH }} - key: e2e-gems-${{ steps.image.outputs.version }}-ruby${{ matrix.ruby-version }}-${{ hashFiles('Gemfile.e2e') }} - - - name: End-to-End tests (SQLite) - if: ${{ !cancelled() }} - timeout-minutes: 4 - env: - EXAMPLES_DRIVER: sqlite3 - run: bundle install && bundle exec rake end2end_sqlite3 - - - name: End-to-End tests (PostgreSQL ${{ matrix.postgres-version }}) - if: ${{ !cancelled() }} - timeout-minutes: 4 - env: - EXAMPLES_DRIVER: pg - run: bundle install && bundle exec rake end2end_pg - - - name: End-to-End tests (MySQL 8.4) - if: ${{ !cancelled() }} - timeout-minutes: 5 - env: - EXAMPLES_DRIVER: mysql2 - run: bundle install && bundle exec rake end2end_mysql2 - - - name: Generator options E2E - if: ${{ !cancelled() }} - timeout-minutes: 3 - env: - BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.options.e2e - # default gem path (only prebuilt gems): with BUNDLE_PATH, the test's nested `bundle install` on Windows Ruby - # 3.1 trips over setup-ruby's newer Bundler next to the default 2.3 one - run: | - unset BUNDLE_PATH - bundle install && bundle exec ruby tests/end2end_options.rb - - - name: Native extension build logs - if: failure() - run: find "$(ruby -e 'print Gem.dir')" -name mkmf.log -exec sh -c 'echo "== $1"; cat "$1"' _ {} \;