error out when fetching NULL data from hgsql

Summary:
The original bug that resulted in empty revisions being pulled is long-fixed:
T28553115. I'm planning to make data1 nullable so I can reclaim space by removing older
revs.

Reviewed By: DurhamG

Differential Revision: D28096278

fbshipit-source-id: a57da458df115dcbdf544e2151aa327651190c1a
This commit is contained in:
Mateusz Kwapich 2021-04-29 14:43:53 -07:00 committed by Facebook GitHub Bot
parent d1064681ee
commit 43c2f9f88e

View File

@ -1310,22 +1310,14 @@ def wraprepo(repo):
chunk = revdata[1]
linkrev = revdata[3]
# Some versions of the MySQL Python connector have a
# bug where it converts aa column containing a single
# null byte into None. hgsql needs this workaround to
# handle file revisions that are exactly a single null
# byte.
#
# The only column that can contain a single null byte
# here is data1 (column 6):
# * path is a path, so Unix rules prohibit it from
# containing null bytes.
# * chunk, chunkcount and linkrev are integers.
# * entry is a binary blob that matches a revlog index
# entry, which cannot be "\0".
# * data0 is either empty or "u".
if revdata[6] is None:
revdata = revdata[:6] + (b"\0",)
# To save diskspace we're removing the older revisions from hgsql. Normally
# we shouldn't need them as long as nobody tries to use sqlverify or sqlreplay
# to verify or bring back older data.
raise Exception(
"This part of history was removed from hgsql to save diskpace! (linkrev: %s)"
% linkrev
)
groupedrevdata.setdefault((name, linkrev), {})[chunk] = revdata