Fix DB query on startup for negative streams. (#8447)

For negative streams we have to negate the internal stream ID before
querying the DB.

The effect of this bug was to query far too many rows, slowing start up
time, but we would correctly filter the results afterwards so there was
no ill effect.
This commit is contained in:
Erik Johnston 2020-10-02 12:22:19 +01:00 committed by GitHub
parent 34ff8da83b
commit 695240d34a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

1
changelog.d/8447.bugfix Normal file
View file

@ -0,0 +1 @@
Fix DB query on startup for negative streams which caused long start up times. Introduced in #8374.

View file

@ -341,7 +341,7 @@ class MultiWriterIdGenerator:
"cmp": "<=" if self._positive else ">=",
}
sql = self._db.engine.convert_param_style(sql)
cur.execute(sql, (min_stream_id,))
cur.execute(sql, (min_stream_id * self._return_factor,))
self._persisted_upto_position = min_stream_id