Comments (3)
Got it working OK by splitting it into 16 chunks. For anyone that's interested in future here's some code to roughly split the log file by session ID.
#!/usr/bin/env python3
import hashlib
import argparse
import sys
import os
import csv
CSV_FIELDS = ['log_time', 'user_name', 'database_name', 'process_id', 'connection_from', 'session_id',
'session_line_num', 'command_tag', 'session_start_time', 'virtual_transaction_id',
'transaction_id', 'error_severity', 'sql_state_code', 'message', 'detail', 'hint', 'internal_query', 'internal_query_pos',
'context', 'query', 'query_pos', 'location', 'application_name']
CSV_IDS = { CSV_FIELDS[i] : i for i in range(0, len(CSV_FIELDS) ) }
def main():
parser = argparse.ArgumentParser(description='Split postgres csv log file into roughly equal chunks by session id')
parser.add_argument('--log-file', type=str, help='The log file to parse')
parser.add_argument('--split-count', type=int, help='Number to split the log file into')
args = parser.parse_args()
buckets = [[] for i in range(args.split_count)]
csv.field_size_limit(sys.maxsize)
with open(args.log_file, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
try:
bucket_number = int(hashlib.sha256(row[CSV_IDS['session_id']].encode('utf-8')).hexdigest(), 16) % args.split_count
buckets[bucket_number].append(row)
except IndexError:
print("index error encountered for row:{}".format(row))
continue
for index in range(args.split_count):
split_file_name = 'split_file_{}_{}'.format(index, os.path.basename(args.log_file))
with open(split_file_name, mode='w', encoding='utf-8') as split_file:
writer = csv.writer(split_file, quoting=csv.QUOTE_MINIMAL)
for row in buckets[index]:
writer.writerow(row)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Interrupted')
try:
sys.exit(0)
except SystemExit:
os._exit(0)
from pgreplay.
That's a fundamental limitation of pgreplay because of its single-threaded architecture.
At a certain load pgreplay will not be able to handle just sending queries and receiving the results and fall behind.
If you can split your log, that will work to some extent.
What you will lose is that pgreplay replays the statements in the same order in which they were originally.
If several pgreplay processes run against the same database, one can fall behind, while the other doesn't, and that man change the workload significantly if the statements in different sessions depend on each other.
I'd say that it splitting the log file should work good enough if all you need is an approximation of the actual workload.
from pgreplay.
Thanks for the feedback and the script!
I'll close the issue.
from pgreplay.
Related Issues (20)
- make install fails on Mac OS X HOT 5
- Unable to compile pgreplay on ubuntu 18.04 HOT 2
- pgreplay seems to have stopped suddenly when executing HOT 10
- Generating undo records by using pgreplay HOT 1
- pgreplay not working with RDS csvlog HOT 2
- Replay freezes, all queries stuck in ClientRead state. HOT 3
- replay and uuids HOT 1
- Will the program support pg11 onward? HOT 3
- Transaction Deadlocks on Replay HOT 7
- Invalid free on replaying server-side prepare "ROLLBACK; DEALLOCATE ALL". HOT 4
- Tests are failing after installation HOT 6
- First run always lags behind HOT 3
- connection to database failed for a specific session HOT 1
- Parsing line error HOT 12
- Upgrade from pg 12 to pg 14 HOT 2
- ./configure fails on pg15.0 HOT 2
- Opened connections HOT 2
- Will PQgetResult cause stat_stmt statistics errors? HOT 1
- docker build Fails with Error (from master, commit a2f7c113197ed5623b35f09bfc299aae971d56e8) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgreplay.