-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actor event entries do not retain order when passing through event index #11823
Comments
Some reasons this hasn't been picked up earlier:
Workaround goes something like this:
|
Some additional tidbits:
Regarding a fix, I think what we need to do is:
|
@rvagg Raised #11829 for this. See discussion on Slack. We don't need to do a migration as we're okay with calibnet having jumbled events before the epoch where we'll patch it with this. There's only like 10 or so deals on calibnet currently. Please can you test this out with the flow which led you to discover this bug in the first place and maybe modify the actors events itest in my PR to test for this ? |
Related discussion: #11830 |
I'm actually kind of surprised by this issue. Given the lack of a primary key, shouldn't SQL be giving us an automatic auto-incrementing primary key? See https://www.sqlite.org/withoutrowid.html I wonder if we can just rename this row ID to an actual primary key and then order by it. That should give us event fields in insertion order. Kind of implicit, but it should work. |
@Stebalien I think we still need specify that "automatic auto-incrementing primary key" in the DDL for the "event_entry" table (just like we do it for the event table). I don't think we just get it without asking for it. But then it's really the same as what we've done in #11829 (we explicitly insert an "index" column). |
|
The event index doesn't care about order of "entries" that come with events, as per schema:
lotus/chain/events/filter/index.go
Lines 51 to 58 in a1264c8
Unfortunately, order now matters. As per FIP-0083 both
sector-activated
andsector-updated
rely onpiece-cid
andpiece-size
pairings to come out in order such that you can join them up to get the "PieceInfo". When we rely on sqlite table ordering, we get a shuffling of the array of events which loses pairings.The result is that, when using
GetActorEventsRaw
(andSubscribeActorEventsRaw
for historical events) we get something like this (from calibnet msgbafy2bzacec2e6fiovhcjrprjgi76rhoqhr6bt7ag7dsejng5sefuksyvmvpwu
):When loading the same from the from the AMT with
ChainGetEvents
, we see the original order:We're using a
INSERT OR IGNORE INTO
when puttingevent_entry
values in but we only have an index (onkey
), not aUNIQUE
so I believe that means we're still going to get the duplicate keys, but I'd like someone else to sanity check that assumption. (Aside: we also don't have an index onevent_id
which is the only thing we're actually selecting (joining) on, which seems odd, maybe we should).The text was updated successfully, but these errors were encountered: