Przeglądaj źródła

Merge pull request #12901 from keynslug/fix/ds-snap-flaky-tc

fix(dssnap): ensure idempotent write of empty chunks
Andrew Mayorov 1 rok temu
rodzic
commit
ebc02cd39d

+ 3 - 1
apps/emqx_durable_storage/src/emqx_ds_storage_snapshot.erl

@@ -267,7 +267,9 @@ new_writer_file(#writer{dirpath = DirPath}, RelPath) ->
 
 write_chunk_file(WFile0 = #wfile{fd = IoDev, pos = Pos, abspath = AbsPath}, Pos, More, Chunk) ->
     ChunkSize = byte_size(Chunk),
-    case file:write(IoDev, Chunk) of
+    case (ChunkSize > 0) andalso file:write(IoDev, Chunk) of
+        false ->
+            WFile0;
         ok ->
             WFile1 = WFile0#wfile{pos = Pos + ChunkSize},
             case More of