-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TPC-DS stress tests #17
Merged
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
957d83f
Transfer tests to python3
ololobus bbc89f5
Try TPC-DS test
ololobus 459a060
Use committed TPC-DS queries for now
ololobus 37bedbe
Prepare TPC-DS data
ololobus 166ead3
New tests refactoring
ololobus 91d7754
Add comment
ololobus 5bc7769
Set stress_in_progress as global
ololobus 8c1a8d7
Some formatting and new queries
ololobus 7118ea2
Remove committed TCP-DS queries
ololobus 7bb3c33
README.md updated to reflect recent changes
ololobus 087b0c8
Support only Python 3+ for running tests
ololobus 4d4734a
Use copy_from from psycopg2 for TPC-DS data load
ololobus 80a5e1a
Segregate stress test based on TPC-DS from common ones
maksm90 302350c
Fix tests runner script
maksm90 18f5a38
Try to fix usage of USE_TPCDS variable in test script
ololobus 02049e1
Pass USE_TPCDS env variable to Docker container
ololobus a4a2ec3
Create pg_query_state extension in the case of TPC-DS test
ololobus ba34af1
Do not run TPC-DS on 9.6
ololobus b2f8e82
Split common tests and tpc-ds stress test on different modules
772062a
Segregate setup and running of stress test
maksm90 2ac1f8a
Make periodic pg_query_state calls to backend running TPC-DS bench
maksm90 61cf837
Refactor the main cycle of tpc-ds stress test
maksm90 c1776bc
Make light refactoring after review from ololobus
maksm90 8545705
Light refactoring regarding constants in run_tpcds function
maksm90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ pg_query_state--*.sql | |
cscope.out | ||
tags | ||
Dockerfile | ||
tmp_stress | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
''' | ||
common.py | ||
Copyright (c) 2016-2019, Postgres Professional | ||
''' | ||
|
||
import psycopg2 | ||
import psycopg2.extensions | ||
import select | ||
import time | ||
|
||
BACKEND_IS_IDLE_INFO = 'INFO: state of backend is idle\n' | ||
BACKEND_IS_ACTIVE_INFO = 'INFO: state of backend is active\n' | ||
|
||
def wait(conn): | ||
"""wait for some event on connection to postgres""" | ||
while 1: | ||
state = conn.poll() | ||
if state == psycopg2.extensions.POLL_OK: | ||
break | ||
elif state == psycopg2.extensions.POLL_WRITE: | ||
select.select([], [conn.fileno()], []) | ||
elif state == psycopg2.extensions.POLL_READ: | ||
select.select([conn.fileno()], [], []) | ||
else: | ||
raise psycopg2.OperationalError("poll() returned %s" % state) | ||
|
||
def n_async_connect(config, n=1): | ||
"""establish n asynchronious connections to the postgres with specified config""" | ||
|
||
aconfig = config.copy() | ||
aconfig['async'] = True | ||
|
||
result = [] | ||
for _ in range(n): | ||
conn = psycopg2.connect(**aconfig) | ||
wait(conn) | ||
result.append(conn) | ||
return result | ||
|
||
def n_close(conns): | ||
"""close connections to postgres""" | ||
|
||
for conn in conns: | ||
conn.close() | ||
|
||
def pg_query_state(config, pid, verbose=False, costs=False, timing=False, \ | ||
buffers=False, triggers=False, format='text'): | ||
""" | ||
Get query state from backend with specified pid and optional parameters. | ||
Save any warning, info, notice and log data in global variable 'notices' | ||
""" | ||
|
||
conn = psycopg2.connect(**config) | ||
curs = conn.cursor() | ||
|
||
curs.callproc('pg_query_state', (pid, verbose, costs, timing, buffers, triggers, format)) | ||
result = curs.fetchall() | ||
notices = conn.notices[:] | ||
conn.close() | ||
|
||
return result, notices | ||
|
||
def onetime_query_state(config, async_conn, query, args={}, num_workers=0): | ||
""" | ||
Get intermediate state of 'query' on connection 'async_conn' after number of 'steps' | ||
of node executions from start of query | ||
""" | ||
|
||
acurs = async_conn.cursor() | ||
|
||
set_guc(async_conn, 'enable_mergejoin', 'off') | ||
set_guc(async_conn, 'max_parallel_workers_per_gather', num_workers) | ||
acurs.execute(query) | ||
|
||
# extract current state of query progress | ||
MAX_PG_QS_RETRIES = 10 | ||
DELAY_BETWEEN_RETRIES = 0.1 | ||
pg_qs_args = { | ||
'config': config, | ||
'pid': async_conn.get_backend_pid() | ||
} | ||
for k, v in args.items(): | ||
pg_qs_args[k] = v | ||
n_retries = 0 | ||
while True: | ||
result, notices = pg_query_state(**pg_qs_args) | ||
n_retries += 1 | ||
if len(result) > 0: | ||
break | ||
if n_retries >= MAX_PG_QS_RETRIES: | ||
# pg_query_state callings don't return any result, more likely run | ||
# query has completed | ||
break | ||
time.sleep(DELAY_BETWEEN_RETRIES) | ||
wait(async_conn) | ||
|
||
set_guc(async_conn, 'enable_mergejoin', 'on') | ||
return result, notices | ||
|
||
def set_guc(async_conn, param, value): | ||
acurs = async_conn.cursor() | ||
acurs.execute('set %s to %s' % (param, value)) | ||
wait(async_conn) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can put 2020 everywhere already :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done