Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

"SET synchronous_commit TO OFF" should not be allowed (fasthttp-postgresql) #1947

Closed

Description

@kostya-sh

fasthttp-postgresql came first in Data Updates benchmark in Round 12. When browsing its code I found the following snippet:

    // Disable synchronous commit for the current db connection
    // as a performance optimization.
    // See http://www.postgresql.org/docs/current/static/runtime-config-wal.html
    // for details.
    if _, err := conn.Exec("SET synchronous_commit TO OFF"); err != nil {
        log.Fatalf("Error when disabling synchronous commit")
    }

I am not sure how much this affected the benchmark results however I beleive such code should not be allowed. As result of disabling synchronous commits fasthttp-postgresql behaves differently from other benchmarks, in particular data loss is possible in some cases.

Activity

  1. zloster commented on Mar 1, 2016

    @zloster
    Contributor

    About transactions and data loss: the rules for Database updates test doesn't mandate the use of transactions. Check Rule 10.
    IMO this "tweak" for the transactions doesn't break the rules in general - it gives fasthttp-postgresql advantage over the other frameworks that are using PostgreSQL and not using this tweak.

    However I've got curious about how MySQL and PostgreSQL are configured. And here it is what I've found (it is always possible that I've missed something):

    1. MySQL config enables defacto asynchronous transaction log write to the disk. With the current setting it is possible to loose data from latest committed transactions before crash.
    2. PostgreSQL config seems to use the production safe defaults. With the current setting It is not possible to loose data from the latest committed transactions before crash.

    So fasthttp-postgresql just sets PostgreSQL and MySQL behaviour (regarding the transaction log flushing) on equal ground.

    Techempower team should think about a restriction and/or clarification on this matter. IMO the setting for MySQL should be reverted to the safer transaction log flush mode (the default full ACID compliant innodb_flush_log_at_trx_commit = 1), the fasthttp-postgresql code to be fixed not to use the tweak and the override of this kind of settings to be forbidden. My arguments are:

    • Most people will expect and use the default ACID-compliant configuration with RDBMS;
    • I expect the tests to work with production-grade settings for data protection (at least for the RDBMS) - developers choose to use RDBMS over NoSQL because of the ACID and data protection guarantees.(Otherwise we all could use Redis and hope not to have power outage :)).

    The commit introducing this change is recent one. I don't know if this topic has been explored before. @bhauer @msmith-techempower Please, can you check this?

  2. methane commented on Mar 2, 2016

    @methane
    Contributor

    Since EBS performance is unstable, I'm +1 to not wait fsync.
    This is a "Framework" benchmark, not "Disk" benchmark or "Database" benchmark.

    But optimize like this should be done in global config.
    Otherwise, you can't compare performance of frameworks using PostgreSQL.

  3. kostya-sh commented on Mar 2, 2016

    @kostya-sh
    ContributorAuthor

    Production-grade systems are more likely to be configured to flush on commit so I think numbers with fsync are more interesting. However it is not that important as long as all frameworks use the same configuration.

  4. valyala commented on Mar 2, 2016

    @valyala
    Contributor

    +1 for enabling async commit in global postgresql.conf . Otherwise update test measures fsync performance on db server instead of web framework performance.

    BTW, postgresql docs say that async commit is quite safe:

    Unlike fsync, setting this parameter to off does not create any risk of database inconsistency: an operating system or database crash might result in some recent allegedly-committed transactions being lost, but the database state will be just the same as if those transactions had been aborted cleanly. So, turning synchronous_commit off can be a useful alternative when performance is more important than exact certainty about the durability of a transaction.

  5. zloster commented on Mar 3, 2016

    @zloster
    Contributor

    @valyala That's right. The same goes for MySQL:

    Because the flush to disk operation only occurs approximately once per second, you can lose up to a second of transactions in an operating system crash or a power outage.

    My understanding is that they will not damage the data as a whole: there is possibility to loose some very recent changes to the data in case of a crash. And that is the reason why I stated this:

    So fasthttp-postgresql just sets PostgreSQL and MySQL behaviour (regarding the transaction log flushing) on equal ground.

    I agree with the point you and @methane made about the EBS performance and async-commit and the framework focus of the test.

    The common ground so far is the RDBMS settings should be tweaked to be more equal. I'm OK with turning on async commit but I would expect than the docs/results page to contain some type of warning/disclaimer about this.

    The ideal solution will be to have two sets of benchmarks results (for the db updates test): one with asynchronous transaction commit off and second set with on. However I don't know how feasible this idea is. It will lead to inconsistent results on cloud environments, but on real iron it makes sense (to me) to have the two sets.

  6. methane commented on Mar 3, 2016

    @methane
    Contributor

    there is possibility to loose some very recent changes to the data in case of a crash.

    Even if flushed data, there is possibility to loose all data in case of a disk crash.
    RAID have possibility to loose data by firmware bug.
    Sync replication (including semi-sync replication in MySQL) is better for production.

    But I don't think this project should teach "How to save your data from crash" to people.

    The ideal solution will be to have two sets of benchmarks results (for the db updates test): one with asynchronous transaction commit off and second set with on.

    I don't think so. Framework performance and DB tx/sec performance is not related.
    To measure Framework performance, DB should reply ASAP.
    To measure "DB" performance, you shouldn't use Web framework, HTTP server and client. There are several tools like sysbench.

    And this project is "Framework Benchmark."

    I would expect than the docs/results page to contain some type of warning/disclaimer about this.

    Warning should be in config file to avoid people copy the config into there production environment.

  7. added 4 commits that reference this issue on Mar 15, 2016
  8. bhauer commented on Mar 17, 2016

    @bhauer
    Contributor

    I'm joining this conversation late, but I really appreciate the informative and helpful comments in this thread. I believe the consensus here aligns very well with my own point of view. But for what it's worth I wanted to add the following:

    • Not to belabor the obvious point, but @methane and @valyala are correct that our project is focused on measuring the performance of web application frameworks. We include test types with database connectivity because database usage is so common for web applications. But we do not intend the data to be used as a measurement of database performance.
    • Our guidance for test implementations is to target "production-grade." This has been, by necessity, a rather fuzzy rule since the interpretation of production-grade is open to debate. I do think most of us agree on the general concept.
    • However, in contrast to the above item, on the database configuration side, we've accepted configuration changes that (to many observers) may not be suitable for a production environment. While we don't want to strip the database servers down to the bare-bones minimum, we are comfortable turning off some durability features to reduce the amount of time spent waiting on the database server. In fact, we ran Round 7 with a ramdisk when the SSD we had used for testing failed.
    • Put another way, I want the overhead of communicating to the database to be realistic but not time-consuming to the point that high-performance frameworks are rate-limited and indistinguishable from low-performance frameworks. This is also why the database queries are so lightweight. Note that future test types could certainly be added that include more expensive and durable database operations, but I feel the results data would be predictable (rate limited by the database server, at least for a majority of frameworks) and not very useful.
    • Most importantly for this thread, as @kostya-sh and @zloster point out, the implementations are inconsistent and that is what we need to address. I agree with the consensus to turn off synchronous commits in Postgres globally. This mirrors the already-accepted similar configuration change in MySQL. And applying the change globally avoids the situation where one test implementation is clever enough to do so while others are not.
    • In general, a clever tuning change such as the one cited by @kostya-sh should not be included in the implementations. I would prefer that configuration changes to the database servers happen as the result of a Github issue proposing the change globally. Thank you @kostya-sh for bringing this to the attention of everyone else.
    • It may be impossible to reach a unanimous consensus about the proper database configuration. As with all of these matters, I am happy to roll back this change if the general consensus shifts or if a particularly good argument is made by someone.

    Thanks again to everyone in this thread!

  9. added a commit that references this issue on Mar 17, 2016
  10. msmith-techempower commented on Mar 17, 2016

    @msmith-techempower
    Member

    Closed with #1970

  11. zloster commented on Mar 18, 2016

    @zloster
    Contributor

    Thanks for the good and clean summary.

  12. added a commit that references this issue on Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions