Skip to content

Commit f766a84

Browse files
vinzenzpirat89
authored andcommitted
checkpoints: Load checkpoints ordered by id (#499)
* checkpoints: Load checkpoints ordered by `id` Previously checkpoints were loaded from the audit table in the database and ordered by timestamp. However we ran into some problems were timestamps were off due to some misconfiguration that caused the time of the system being in the past after the reboot. That resulted in leapp, trying to resume at a place that has been already executed before. This patch will change the ordering to use the row id, which is sequential in SQLite. Signed-off-by: Vinzenz Feenstra <[email protected]>
1 parent cfe9bb1 commit f766a84

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

leapp/cli/upgrade/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def fetch_last_upgrade_context():
7777
"""
7878
with get_connection(None) as db:
7979
cursor = db.execute(
80-
"SELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY stamp DESC LIMIT 1")
80+
"SELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY id DESC LIMIT 1")
8181
row = cursor.fetchone()
8282
if row:
8383
return row[0], json.loads(row[2])
@@ -90,7 +90,7 @@ def fetch_all_upgrade_contexts():
9090
"""
9191
with get_connection(None) as db:
9292
cursor = db.execute(
93-
"SELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY stamp DESC")
93+
"SELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY id DESC")
9494
row = cursor.fetchall()
9595
if row:
9696
return row

leapp/snactor/context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def last_snactor_context(connection=None):
1414
"""
1515
with get_connection(db=connection) as db:
1616
cursor = db.execute('''
17-
SELECT context, stamp FROM execution WHERE kind = 'snactor-run' ORDER BY stamp DESC LIMIT 1
17+
SELECT context, stamp FROM execution WHERE kind = 'snactor-run' ORDER BY id DESC LIMIT 1
1818
''')
1919
row = cursor.fetchone()
2020
if row:

leapp/utils/audit/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def get_checkpoints(context):
450450
data_source ON data_source.id = audit.data_source_id
451451
WHERE
452452
audit.context = ? AND audit.event = ?
453-
ORDER BY stamp ASC;
453+
ORDER BY audit.id ASC;
454454
''', (context, _AUDIT_CHECKPOINT_EVENT))
455455
cursor.row_factory = _dict_factory
456456
return cursor.fetchall()

0 commit comments

Comments
 (0)