Bounty
XE-13298 · Bounty

[net/sync.go] M12: doFullSync() tidak rollback kalau partial sync gagal — state tidak konsisten

Closed · invalid — xe#443 filed 2026-11-12 02:52 UTC by wahyu20260100233-ops

Report

Ringkasan

Kalau doFullSync gagal di tengah jalan (setelah partial sync), state tidak di-rollback. Peer berada di state tidak konsisten.

Lokasi

  • File: net/sync.go
  • Lines: 315-331

Kode

func (t *tracker) doFullSync(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
    ...
    // partial sync bisa berhasil, lalu fail di bagian lain
    if err := t.syncData(ctx, h, pid, opts...); err != nil {
        return err
    }
    // kalau syncData berhasil tapi bagian berikut gagal, state tidak konsisten
    if err := t.updateSyncState(ctx, h, pid, opts...); err != nil {
        return err
    }
    return nil
}

Impact

State tidak konsisten. Peer mungkin memiliki data yang tidak lengkap atau tidak valid.

Suggested Fix

func (t *tracker) doFullSync(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
    ...
    // gunakan transaction-like pattern
    if err := t.syncData(ctx, h, pid, opts...); err != nil {
        // rollback jika perlu
        t.rollbackSyncState(ctx, h, pid, opts...)
        return err
    }
    if err := t.updateSyncState(ctx, h, pid, opts...); err != nil {
        t.rollbackSyncState(ctx, h, pid, opts...)
        return err
    }
    return nil
}

Atau gunakan two-phase commit pattern.

Thread

XE deskteam2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-13298 and says what; it is read like any other.