From c645fc46b192a36a221f164767ffe907348ea6c3 Mon Sep 17 00:00:00 2001 From: Ben Duncan <5178243+benduncan@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:14:00 +1000 Subject: [PATCH] fix: dispatch chunk WAL opening for EFI and cloud-init volumes With UseShardedWAL now defaulting to true, the EFI and cloud-init volume preparation must open sharded WAL files instead of always opening the legacy WAL. Without this, Flush() dispatches to the sharded path but shard DB files are nil, causing zero-byte writes. --- hive/handlers/ec2/instance/service_impl.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hive/handlers/ec2/instance/service_impl.go b/hive/handlers/ec2/instance/service_impl.go index daaf34fad..4e64f8c42 100644 --- a/hive/handlers/ec2/instance/service_impl.go +++ b/hive/handlers/ec2/instance/service_impl.go @@ -391,8 +391,12 @@ func (s *InstanceServiceImpl) prepareEFIVolume(imageId string, volumeConfig vipe if err != nil { slog.Info("Volume does not yet exist, creating EFI disk ...") - // Open the chunk WAL - err = efiVb.OpenWAL(&efiVb.WAL, fmt.Sprintf("%s/%s", efiVb.WAL.BaseDir, types.GetFilePath(types.FileTypeWALChunk, efiVb.WAL.WallNum.Load(), efiVb.GetVolume()))) + // Open the chunk WAL (sharded or legacy) + if efiVb.UseShardedWAL { + err = efiVb.OpenShardedWAL() + } else { + err = efiVb.OpenWAL(&efiVb.WAL, fmt.Sprintf("%s/%s", efiVb.WAL.BaseDir, types.GetFilePath(types.FileTypeWALChunk, efiVb.WAL.WallNum.Load(), efiVb.GetVolume()))) + } if err != nil { slog.Error("Failed to load WAL", "err", err) return errors.New(awserrors.ErrorServerInternal) @@ -471,8 +475,12 @@ func (s *InstanceServiceImpl) prepareCloudInitVolume(input *ec2.RunInstancesInpu if err != nil { slog.Info("Volume does not yet exist, creating cloud-init disk ...") - // Open WALs - err = cloudInitVb.OpenWAL(&cloudInitVb.WAL, fmt.Sprintf("%s/%s", cloudInitVb.WAL.BaseDir, types.GetFilePath(types.FileTypeWALChunk, cloudInitVb.WAL.WallNum.Load(), cloudInitVb.GetVolume()))) + // Open the chunk WAL (sharded or legacy) + if cloudInitVb.UseShardedWAL { + err = cloudInitVb.OpenShardedWAL() + } else { + err = cloudInitVb.OpenWAL(&cloudInitVb.WAL, fmt.Sprintf("%s/%s", cloudInitVb.WAL.BaseDir, types.GetFilePath(types.FileTypeWALChunk, cloudInitVb.WAL.WallNum.Load(), cloudInitVb.GetVolume()))) + } if err != nil { slog.Error("Failed to load WAL", "err", err) return errors.New(awserrors.ErrorServerInternal)