Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refectoring transaction handling #204

Merged
merged 8 commits into from
Jul 26, 2019

Conversation

mmd-osm
Copy link
Collaborator

@mmd-osm mmd-osm commented Jul 25, 2019

  • Change pqxx transaction ownership from readonly_pgsql_selection to dedicated class (subclass of Transaction_Owner_Base). A new transaction is started by calling get_default_transaction, and is passed to factory->make_selection as:
    auto default_transaction = factory->get_default_transaction();
    auto selection = factory->make_selection(*default_transaction);

This way, both pgsql_update and readonly_pgsql_selection can use the same transaction (and thereby the same database connection), which is important in some scenarios.

Changes to readonly_pgsql_selection:

  • Move all SQL prepared statements to the respective method where the statement is executed. This way, methods are self-contained and don't depend on common constructor prepared statement calls.
  • Use Transaction_Manager (using a reference to Transaction_Owner_Base) instead of pqxx::work directly, allows for new syntax and enhanced logging (runtime measurements)
    Example:
[2019-07-26T18:45:27 #19328] Started request for map(2.3412,48.8276,2.35828,48.8364) from 127.0.0.1
[2019-07-26T18:45:27 #19328] Executed prepared statement visible_node_in_bbox in 118 ms, returning 13622 rows, 13622 affected rows
[2019-07-26T18:45:27 #19328] Filling sel_ways (from nodes)
[2019-07-26T18:45:27 #19328] Executed prepared statement ways_from_nodes in 184 ms, returning 1626 rows, 1626 affected rows
[2019-07-26T18:45:27 #19328] Executed prepared statement nodes_from_ways in 27 ms, returning 14225 rows, 14225 affected rows
[2019-07-26T18:45:27 #19328] Filling sel_relations (from ways)
[2019-07-26T18:45:27 #19328] Executed prepared statement relation_parents_of_ways in 17 ms, returning 119 rows, 119 affected rows
[2019-07-26T18:45:27 #19328] Executed prepared statement relation_parents_of_nodes in 37 ms, returning 0 rows, 0 affected rows
[2019-07-26T18:45:27 #19328] Executed prepared statement relation_parents_of_relations in 0 ms, returning 0 rows, 0 affected rows
[2019-07-26T18:45:27 #19328] Executed prepared statement extract_changesets in 61 ms, returning 0 rows, 0 affected rows
[2019-07-26T18:45:27 #19328] Fetching nodes
[2019-07-26T18:45:27 #19328] Executed prepared statement extract_nodes in 118 ms, returning 14225 rows, 14225 affected rows
[2019-07-26T18:45:27 #19328] Fetching ways
[2019-07-26T18:45:27 #19328] Executed prepared statement extract_ways in 58 ms, returning 1626 rows, 1626 affected rows
[2019-07-26T18:45:27 #19328] Fetching relations
[2019-07-26T18:45:27 #19328] Executed prepared statement extract_relations in 12 ms, returning 119 rows, 119 affected rows
[2019-07-26T18:45:27 #19328] Completed request for map(2.3412,48.8276,2.35828,48.8364) from 127.0.0.1 in 813 ms returning 3202813 bytes
  • Use read-only transaction by default

@mmd-osm mmd-osm force-pushed the patch/standalone_ro branch from 3d18b6e to 966a354 Compare July 26, 2019 18:40
@mmd-osm mmd-osm merged commit d944fdd into zerebubuth:master Jul 26, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant