GithubHelp home page GithubHelp logo

demo-single-roundtrip-statement-timeout's Introduction

demo-single-1rt-statement-timeout

This is a demo with how hack PostgreSQL statement_timeout with single round trip

Описание

Внутри simple query нельзя устанавливать statement_timeout:

$ psql -U postgres -c "set local statement_timeout = '100ms'; select pg_sleep(2);"
 pg_sleep 
----------
 
(1 row)

Это потому, что любой simple query оборачивается в xact_command: https://github.com/postgres/postgres/blob/REL9_6_STABLE/src/backend/tcop/postgres.c#L923

Если xact_started == true, таймер StatementTimeout не взводиться https://github.com/postgres/postgres/blob/REL9_6_STABLE/src/backend/tcop/postgres.c#L2443

xact_started = false устанавливается в 2-х случаях:

хак чтобы statement_timeout работал внутри simple query:

$ psql -U postgres -c "set local statement_timeout = '100ms'; BEGIN; select pg_sleep(2);"
ERROR:  canceling statement due to statement timeout

demo-single-roundtrip-statement-timeout's People

Contributors

chobostar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.