Skip to content

Commit fcb7399

Browse files
committed
Scope temp_store=MEMORY workaround to the failing temp-table tests
Setting `PRAGMA temp_store = MEMORY` at connection setup unblocks the temp-table I/O tests but crashes testReconstructTable in Turso's hypersensitive pager (testReconstructTable hangs and the process dumps core ~5s after the test starts). Move the PRAGMA into the two failing test methods directly: testCreateTemporaryTable testTemporaryTableHasPriorityOverStandardTable This way only those tests' connections route temp tables through MemoryIO, and testReconstructTable is unaffected.
1 parent 5fe9618 commit fcb7399

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

.github/workflows/phpunit-tests-turso.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,34 +1901,38 @@ jobs:
19011901
# page N` from the pager. With the default temp_store
19021902
# setting Turso creates a per-connection temp database on
19031903
# disk (via `tempfile::tempdir()` in core/connection.rs).
1904-
# The CI probe of the same SQL on a fresh PDO passes because
1905-
# the test order/state in the suite hits a code path the
1906-
# probe doesn't. Force `temp_store = MEMORY` at connection
1907-
# setup so temp tables go through MemoryIO instead, bypassing
1908-
# the buggy disk-temp pager path.
1909-
path = 'src/sqlite/class-wp-sqlite-connection.php'
1904+
# The CI probe of the same SQL on a fresh PDO passes, so
1905+
# the bug is state-dependent — likely accumulated test state
1906+
# interacts with the disk temp pager.
1907+
#
1908+
# Setting `PRAGMA temp_store = MEMORY` at connection setup
1909+
# fixes these tests but crashes testReconstructTable in
1910+
# Turso's pager (it's hypersensitive to small Turso state
1911+
# changes — see project_turso_testreconstructtable_fragile).
1912+
# Instead, opt into `temp_store = MEMORY` only at the start
1913+
# of the two failing tests so testReconstructTable is
1914+
# unaffected.
1915+
path = 'tests/WP_SQLite_Driver_Tests.php'
19101916
src = open(path).read()
1911-
old_jm = (
1912-
"\t\tif ( $journal_mode && in_array( $journal_mode, self::SQLITE_JOURNAL_MODES, true ) ) {\n"
1913-
"\t\t\t$this->query( 'PRAGMA journal_mode = ' . $journal_mode );\n"
1914-
"\t\t}\n"
1915-
"\t}"
1917+
inject_at = "\tpublic function testCreateTemporaryTable() {\n"
1918+
inject = (
1919+
"\tpublic function testCreateTemporaryTable() {\n"
1920+
"\t\t// Force in-memory temp store: Turso's default disk temp pager has\n"
1921+
"\t\t// a state-dependent `short read on page N` bug that surfaces here.\n"
1922+
"\t\t$this->engine->get_connection()->query( 'PRAGMA temp_store = MEMORY' );\n"
19161923
)
1917-
new_jm = (
1918-
"\t\tif ( $journal_mode && in_array( $journal_mode, self::SQLITE_JOURNAL_MODES, true ) ) {\n"
1919-
"\t\t\t$this->query( 'PRAGMA journal_mode = ' . $journal_mode );\n"
1920-
"\t\t}\n"
1921-
"\n"
1922-
"\t\t// Force in-memory temp store under Turso. The default disk-backed\n"
1923-
"\t\t// temp pager has a state-dependent `short read on page N` bug that\n"
1924-
"\t\t// breaks testCreateTemporaryTable mid-suite.\n"
1925-
"\t\t$this->query( 'PRAGMA temp_store = MEMORY' );\n"
1926-
"\t}"
1924+
assert inject_at in src and src.count(inject_at) == 1, 'testCreateTemporaryTable opener not found uniquely'
1925+
src = src.replace(inject_at, inject, 1)
1926+
inject_at_2 = "\tpublic function testTemporaryTableHasPriorityOverStandardTable(): void {\n"
1927+
inject_2 = (
1928+
"\tpublic function testTemporaryTableHasPriorityOverStandardTable(): void {\n"
1929+
"\t\t// Same Turso temp-pager workaround as testCreateTemporaryTable.\n"
1930+
"\t\t$this->engine->get_connection()->query( 'PRAGMA temp_store = MEMORY' );\n"
19271931
)
1928-
assert old_jm in src, 'connection __construct journal_mode block not found'
1929-
src = src.replace(old_jm, new_jm, 1)
1932+
assert inject_at_2 in src and src.count(inject_at_2) == 1, 'testTemporaryTableHasPriorityOverStandardTable opener not found uniquely'
1933+
src = src.replace(inject_at_2, inject_2, 1)
19301934
open(path, 'w').write(src)
1931-
print('patched connection setup to set PRAGMA temp_store = MEMORY')
1935+
print('patched testCreateTemporaryTable + testTemporaryTableHasPriorityOverStandardTable to set PRAGMA temp_store = MEMORY')
19321936
PY
19331937
19341938
- name: Run PHPUnit tests against Turso DB

0 commit comments

Comments
 (0)