Daniele Varrazzo [Tue, 20 Dec 2022 20:19:23 +0000 (20:19 +0000)]
ci: configure the database to run two-phase-commit tests
We can't use the Github Actions PostgreSQL service because it doesn't
seem possible to configure the server for stored transactions:
- the service yaml definition doesn't take args to pass to run
- we can't overwrite the entry point with a script of ours because the
service starts before actions/checkout
- the postgres image doesn't allow to pass extra parameters to the
server via an env var
Rafi Shamim [Mon, 12 Dec 2022 21:47:33 +0000 (16:47 -0500)]
Run tests against CockroachDB v22.2
v22.2 was released recently, so we can test it. This upgrade revealed a
regression in CRDB that we must workaround
(https://github.com/cockroachdb/cockroach/issues/93739).
This also removes testing for v21.2, since it is no longer supported.
Daniele Varrazzo [Thu, 15 Dec 2022 11:03:44 +0000 (11:03 +0000)]
fix(copy): don't create a row maker on copy
A COPY_OUT result has columns, but no names for the columns. This case
must be handled in cur.description (see #235) but we don't need to
handle it in copy. If we did handle it in copy, we would need a column
name fallback, which we forgot to handle, hence the problem in #460.
Daniele Varrazzo [Tue, 13 Dec 2022 03:05:39 +0000 (03:05 +0000)]
test: ignore error looking for leaks
The leaks counter frequently reports a leak between run 1 and 2 of the
tests. It turns out to be a Decimal Context whose items() method reports
no content. So the problem is related to Python, not psycopg, and it is
not an unbound leak.
Can't reproduce it in CI, but it happens on my laptop, since switching
to Ubuntu 22.04 with Python 3.10.
Daniele Varrazzo [Tue, 13 Dec 2022 04:25:46 +0000 (04:25 +0000)]
fix: don't re-export TypeAlias from _compat module
Pyright special-cases that type and requires to import it from typing or
typing_extensions only (see https://github.com/microsoft/pyright/issues/4197).
Drop conditional dependency on typing_extension and always import
TypeAlias from there.
Daniele Varrazzo [Mon, 17 Oct 2022 02:12:24 +0000 (03:12 +0100)]
feat: add wait_select() function
A few tests show that using select() from Python has a lower overhead.
See #414.
Use this function wherever defined and epoll() is the default select
strategy instead. This is mostly a draft to figure out where this
strategy can be used with success.
Daniele Varrazzo [Mon, 17 Oct 2022 09:42:33 +0000 (10:42 +0100)]
test: add simple test to compare performances in refactoring
This test is inspired to the problem open in #411, and is pretty much a
simple operation in a tight loop. It is used, at the moment, to compare
different ways to test I/O completion strategies with simple and fast
queries under no concurrency.
Daniele Varrazzo [Sun, 27 Nov 2022 14:20:10 +0000 (15:20 +0100)]
perf(c/array): add C implementation of array loader
With this change we get to load an array without the transformer calling
any Python code (if the element loader is a CLoader as well).
We don't need to subclass the binary loader anymore because all the
required info is now taken from the loaded data. As a consequence, we
don't need a BaseArrayLoader anymore.
Daniele Varrazzo [Thu, 20 Oct 2022 21:41:03 +0000 (23:41 +0200)]
fix: get element oid from the array itself in binary format
Getting it from the type was causing problems in CRDB because they seem
to have a different interpretation of what Int2 and Int4 are. Refactor
the binary parser to take a transformer, instead of a loader function,
in order to look up the loader from the oid parsed from the array.
Also refactor the text array parser to take the whole loader instead of
the load function only, which will be useful in order to optimize the
use of C loaders.
This implementation can be still improved: we always call the Python
loader to decode the single elements; we can try and call the C loader
if available.
fix(pool): make sure to throw a RuntimeError opening async pool without a loop
The error would be thrown anyway downstream, when tasks are created, but
other spurious warning might be raised too because certain tasks are not
awaited.
lint: fix type hints with disabled bytearray/memoryview/bytes equivalience
This changeset makes the code compatible with the current Mypy 0.981,
but passes most of the checks that Mypy 0.990 enforces if the byte
strings equivalence is disabled.
This change is backward compatible because bytes has a superset of the
memoryview interface and, in Python, to make pretty much any use of it,
it must be converted to bytes beforehand.