node icon indicating copy to clipboard operation
node copied to clipboard

UV_USE_IO_URING does not update file handle position

Open ronag opened this issue 1 year ago • 9 comments

I suspect possible regression. Not sure what version but must have been recent:

await stream.promises.pipeline(src, fs.createWriteStream(dstPath))

Will not create a full sized file. I suspect that since createWriteStream doesn't explicitly set position during writes it expects the file handle position to be properly updated, which does not seem to be the case with URING.

ronag avatar Sep 25 '24 07:09 ronag

Yes, ordering in the handling of requests sent to the ring is not guaranteed. So you're right, the offset should be properly set when calling uv_fs_write().

santigimeno avatar Sep 25 '24 08:09 santigimeno

I think we should throw in fs.write if position is not provided while UV_USE_IO_URING is enabled. Do we have any other such instances? net?

ronag avatar Sep 25 '24 08:09 ronag

@nodejs/tsc I think this is so bad that we should just remove UV_USE_IO_URING until we figure out a way to fix it.

ronag avatar Sep 25 '24 08:09 ronag

This should not be an issue once v1.49.0, which was just released, is used as it disables the SQPOLL ring by default.

santigimeno avatar Sep 25 '24 09:09 santigimeno

Didn't we disable UV_USE_IO_URING by default everywhere?

mcollina avatar Sep 25 '24 09:09 mcollina

Didn't we disable UV_USE_IO_URING by default everywhere?

Yes, referring to a security issue. But some users like us enable it without knowing that here be dragons.

ronag avatar Sep 25 '24 09:09 ronag

@ronag wait, I'm not familiar with the internals of the streams. Can those uv_fs_write() ops happen in parallel or sequentially? If the latter, I think it should work.

santigimeno avatar Sep 25 '24 09:09 santigimeno

They are sequential.

ronag avatar Sep 25 '24 10:09 ronag

Ok, can you share a reproducer?

santigimeno avatar Sep 25 '24 10:09 santigimeno

ping @ronag, I would like to help on this one.

juanarbol avatar Nov 10 '24 01:11 juanarbol