Skip to content

Fix vertx-web-kotlinx-r2dbc-postgresql update test by consuming batch Result publishers - #7

Merged
ShreckYe merged 2 commits into
vertx-web-kotlinx-exposedfrom
copilot/fix-update-test-failure
Jan 11, 2026
Merged

ShreckYe merged 2 commits into
vertx-web-kotlinx-exposedfrom
copilot/fix-update-test-failure

Conversation

Copilot AI commented Jan 10, 2026 •

Copy link
Copy Markdown

The update test fails because R2DBC batch statement results aren't properly consumed, causing timeouts.

Changes

  • Fixed updateSortedWorlds in r2dbc MainVerticle: Changed from statement.execute().awaitFirst() to properly iterate and consume all batch Result publishers

Technical Details

R2DBC batch statements with .add() return Publisher<Result> emitting multiple Results. Each Result's rowsUpdated Publisher must be consumed for the operation to complete.

Before:

statement.execute().awaitFirst()  // Only consumes first Result, ignores rowsUpdated

After:

statement.execute().collect { result ->
    result.rowsUpdated.awaitFirst()  // Consumes all Results and their rowsUpdated publishers
}

This matches the R2DBC spec and patterns used in other implementations (e.g., ktor-r2dbc).

Original prompt

The update test of vertx-web-kotlinx-r2dbc-postgresql fails now. Analyze the cause and fix it. You should be able to run the test with ./tfb --test vertx-web-kotlinx-r2dbc-postgresql --type update to verify the fix. Possible causes might be too many concurrent db update requests, deadlocks, incorrect R2DBC pooling config, etc. as I can think of now. You can also compare with the update test of vertx-web-kotlinx-exposed-r2dbc-postgresql, looking into the corresponding implementation in Exposed to see why it works there. Don't break the other test types while fixing this, you can verify this with ./tfb --test vertx-web-kotlinx-r2dbc-postgresql. See the CI results at https://github.com/huanshankeji/FrameworkBenchmarks/actions/runs/20884682547/job/60006122001 for more details. Also see a related submitted issue at TechEmpower#10432. Prefer minimal change limited to this framework’s implementation.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix update test failure in vertx-web-kotlinx-r2dbc-postgresql Fix vertx-web-kotlinx-r2dbc-postgresql update test by consuming batch Result publishers Jan 10, 2026
Copilot AI requested a review from ShreckYe January 10, 2026 22:12
@ShreckYe

Copy link
Copy Markdown
Member

Model: Claude Sonnet 4.5

@ShreckYe
ShreckYe marked this pull request as ready for review January 11, 2026 10:34
@ShreckYe
ShreckYe merged commit 65d5d4f into vertx-web-kotlinx-exposed Jan 11, 2026
ShreckYe added a commit that referenced this pull request Jan 30, 2026
…nt modules and adding new benchmark portions for the Expesed Vert.x SQL Client along with R2DBC and Exposed R2DBC as comparisons (TechEmpower#10560)

* Bump all dependencies and toolchains to the latest

* Migrate to Vert.x 5 APIs and bump Kotlin to 2.3.0-RC2 to support Java 25

* Update catching the "connection" reset exceptions

* Try setting `date` with kotlinx-datetime but it doesn't work as expected

Got `java.lang.IllegalStateException: Field offsetHours is not set`.

* Remove the kotlinx-datetime dependency and update the comment

See commit 9cf28f1 for a failed attempt to try using kotlinx-datetime.

* Get setting `date` with `kotlinx-datetime` to work

ref: #1

* Review and port some of the changes in `FrameworkBenchmarks/frameworks/Java/vertx/` from commit 057c25b to commit 1838aa5, and fix some typos

Some changes are not ported.

There is about 5% performance improvement in the JSON test as tested on my device.

* Increase the io_uring completion queue size to resolve warnings and improve the plaintext test performance

```
io.netty.channel.uring.IoUringIoHandler processCompletionsAndHandleOverflow
vertx: WARNING: CompletionQueue overflow detected, consider increasing size: 4096
```

This is still one warning when the value is set to 8192 as tested on my device, instead of many for the default 4096.

* Benchmark Approach 1 and Approach 3 in `jsonResponseCoHandler` again and fix capitalization BTW

The "Requests/sec" result of Approach 1 is only 40% of Approach 3 as tested on my device.

* Remove an outdated comment as found by Gemini Code Assist

* Use the "connection reset" error code from Netty instead of hard-coding it and also catch Java NIO `SocketException` for developing on other OSs such as macOS and Windows

Tested with the `tfb` command on both macOS and Linux.

* Run `./tfb --new` and update manually

* Copy files from `frameworks/Kotlin/vertx-web-kotlinx`, merge, and update

* Fix some errors and keep things updated in benchmark_config.json and README.md

* Add the exposed-vertx-sql-client dependencies

* Initially adapt the benchmark with some code copied from `frameworks/Kotlin/ktor/ktor-exposed`

The following exception occurs when running the benchmark:

```
org.postgresql.util.PSQLException: Transaction isolation level 0 not supported.
```

* Fix `org.postgresql.util.PSQLException: Transaction isolation level 0 not supported.` with huanshankeji/exposed-vertx-sql-client@bb69856 published to Maven local, and fix some remaining issues in the benchmark code debugging with `tfb`

Here are some results with max parameters (threads, connections, number of queries) of interest as benchmarked on my device. The "single query" result is only 65% of that of `vertx-web-kotlinx`, which is not ideal. The "updates" result exceeds that of `vertx-web-kotlinx` by about 10%-15%, which needs to be looked into further. Setting `validateBatch = false` does not make noticeable difference.

* Use lower case table names

PostgreSQL table names are case-insensitive.

* Port commit e487900 of `vertx-web-kotlinx` here, using one Kotlin `XorWowRandom` `Random` instance every `Verticle

* Rename the project directory to `vertx-web-kotlinx-exposed-vertx-sql-client` to more explicitly compare with the `vertx-web-kotlinx` portion

* Update the project configuration files correspondingly

* Remove the `hasDb` command-line argument

Tests without the database are not needed here in this portion.

* Update the benchmark name in code

* Copy the optimized kotlinx-serialization `Json` configuration from the `ktor` portion

* Merge the `vertx-web-kotlinx-exposed-vertx-sql-client` portion project into the `vertx-web-kotlinx` portion and update the project structure

Changes:
* Split the project into multiple modules/subprojects.
* Update the project structure following a new project generated with `gradle init`.
* Partially adapt to Gradle version catalog (putting only the versions).
* Bump Kotlin to 2.3.0 which is just released BTW.

Common code is not extracted yet.

* Put the serialization plugin in the version catalog too

* Extract common code and refactor for better abstraction

Bump the Vert.x version to 5.0.6 BTW.

* Inline `initDbResources`

* Rename project ":with-db:common" to ":with-db:with-db-common" to resolve jar name conflicts

* Fix Gradle errors of projects without directories

```
Configuring project '...' without an existing directory is not allowed. The configured projectDirectory '...' does not exist, can't be written to or is not a directory.
```

Add an `r2dbc` module BTW.

* Set the main class for the `vertx-web-kotlinx` portion which was forgotten

* Apply Kotlin JVM 2.3.0 explicitly in `buildSrc` to resolve the `Kotlin does not yet support 25 JDK target, falling back to Kotlin JVM_24 JVM target` warning

* Initially complete the `r2dbc` and `exposed-r2dbc` portions

Add a comment for commit effc46a BTW. Update README.md BTW.

* Set username and password which was forgotten and extract the common constants

* Call `suspendTransaction` in the `exposed-r2dbc` portion

* Disable `strictThreadMode` to resolve `java.lang.IllegalStateException: Only the context thread can write a message in the R2DBC portions

* Put all the dependencies in `libraries` of the Gradle version catalog

First performed by Copilot and updated by me to fix some minor issues, reorder, and adjust the format.

* Move the R2DBC `connectionFactory` to the `r2dbc-common` module and share it for the `exposed` module as well, and set `reactor.bufferSize.small` to try resolving `io.r2dbc.postgresql.client.ReactorNettyClient$RequestQueueException: [08006] Cannot exchange messages because the request queue limit is exceeded`

* Set the explicit dialect which is necessary

* Fix `java.lang.IllegalStateException: Bound parameter count does not match parameters in SQL statement` in the `r2dbc` `updates` test with Copilot

* Fix a bug where `awaitLast` should be called instead of `awaitSingle`

* Fix `io.r2dbc.postgresql.client.ReactorNettyClient$RequestQueueException: [08006] Cannot exchange messages because the request queue limit is exceeded` alternatively by not using pipelining

* Update the comments

* Remove the TODO as it's tried in commit 4602312f7c9e6575a5c3dfb75cb78e226aa4c9a1

* Move a comment's location

* Fix the `update` test timeout issue

* Close the R2DBC connection

This doesn't fix the `r2dbc` `update` failure though.

* Fix some warnings

* Use an R2DBC connection pool each `Verticle` in `exposed-r2dbc`, and run the test several times to determine the optimal pool size

* Share one transaction for all the queries in a request in `exposed-r2dbc`, refactoring `CommonWithDbVerticle` to support optional transactions

* Fix format

* Benchmark the `vertx-web-kotlinx` `json` test and `vertx-web-kotlinx-postgresql` `db` test several times with different (original and reverted) code before and after abstraction (introducing abstract classes and interfaces), Kotlin and Vert.x versions, and kotlinx-serialization `Json` configurations to investigate possible performance regressions

Results show no noticeable performance regressions. I first noticed some in the `db` test but they appear to be just measurement errors. The optimized `Json` improves the `json` test throughput with max parameters by about 5% as tested on my device but there is no noticeable difference in the `db` test.

* Use the newly released version 0.7.0 of `exposed-vertx-sql-client`

* Temporarily remove 'update_url' from benchmark_config.json whose corresponding test fails

See TechEmpower#10432 which is not fixed yet.

* Revert "Temporarily remove 'update_url' from benchmark_config.json whose corresponding test fails"

This reverts commit 3f1e03e.

The wrong `update_url` was removed.

* Fix vertx-web-kotlinx-r2dbc-postgresql update test by consuming batch Result publishers (#7)

* Initial plan

* Fix updateSortedWorlds to properly consume R2DBC batch update results

Co-authored-by: ShreckYe <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: ShreckYe <[email protected]>

* Update endpoint URLs to match the code as suggested by Copilot

* Comment out `mavenLocal()`

* Update an outdated relative path as suggested by Copilot

* Fix the `orm` field of `r2dbc-postgresql` which was copied here

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: ShreckYe <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants