Skip to content

Commit

Permalink
try testing tx q
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Jul 11, 2023
1 parent ce99b79 commit 4cb5edc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ jobs:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_HOST_AUTH_METHOD: trust
command: postgres -c track_commit_timestamp=true

- image: cimg/redis:<< parameters.redis_version >>
# - image: cimg/rust:1.65
Expand Down Expand Up @@ -233,6 +234,7 @@ jobs:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_HOST_AUTH_METHOD: trust
command: postgres -c track_commit_timestamp=true

- image: cimg/redis:<< parameters.redis_version >>
# - image: cimg/rust:1.65
Expand Down Expand Up @@ -271,6 +273,7 @@ jobs:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_HOST_AUTH_METHOD: trust
command: postgres -c track_commit_timestamp=true

- image: cimg/redis:<< parameters.redis_version >>
# - image: cimg/rust:1.65
Expand Down Expand Up @@ -310,6 +313,7 @@ jobs:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_HOST_AUTH_METHOD: trust
command: postgres -c track_commit_timestamp=true

- image: cimg/redis:<< parameters.redis_version >>
# - image: cimg/rust:1.65
Expand Down
6 changes: 5 additions & 1 deletion irrd/storage/database_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def delete_rpsl_object(
table.c.prefix,
table.c.object_text,
)
results = self._connection.execute(stmt)
results = self.execute_statement(stmt)

if not self._check_single_row_match(results, user_identifier=f"{rpsl_pk}/{source}"):
return None
Expand Down Expand Up @@ -817,6 +817,10 @@ def set_force_reload(self, source):
"current settings, actual reload process wll take place in next scheduled importer run"
)

def timestamp_last_committed_transaction(self) -> datetime:
result = self.execute_statement("SELECT timestamp FROM pg_last_committed_xact()")
return result.fetchone()["timestamp"]

def record_serial_newest_mirror(self, source: str, serial: int) -> None:
"""
Record that a mirror was updated to a certain serial.
Expand Down
3 changes: 3 additions & 0 deletions irrd/storage/tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_object_writing_and_status_checking(self, monkeypatch, irrd_db_mock_prel
self.dh.upsert_rpsl_object(rpsl_object_route_v6, JournalEntryOrigin.auth_change, source_serial=43)

self.dh.commit()
initial_tx_timestamp = self.dh.timestamp_last_committed_transaction()
self.dh.refresh_connection()

# There should be two entries with MNT-CORRECT in the db now.
Expand Down Expand Up @@ -442,6 +443,8 @@ def test_object_writing_and_status_checking(self, monkeypatch, irrd_db_mock_prel
assert not len(list(self.dh.execute_query(DatabaseStatusQuery().sources(["TEST"]))))
assert len(list(self.dh.execute_query(RPSLDatabaseQuery().sources(["TEST2"])))) == 1

assert self.dh.timestamp_last_committed_transaction() > initial_tx_timestamp

self.dh.close()

assert flatten_mock_calls(self.dh.changed_objects_tracker.preloader.signal_reload) == [
Expand Down

0 comments on commit 4cb5edc

Please sign in to comment.