Welcome! Log In Create A New Profile

Advanced

Re: Nginx NJS fs.writeFileSync is atomic writing and race condition prevention ?

HENG
October 19, 2018 01:00PM
Thanks your reply.

When I deep into NJS source you ponit to, I found something about GCC write
file flag with O_APPEND

I google Linux GCC write file O_APPEND to learn something.

In fact NJS fs.writeFileSync() with O_APPEND, it is atomic write file if
it's buffer just write all in one time. Even mutil process to write one
file use O_APPEND.

But, if write buffer can NOT write all in one time, in mutil process, it is
NOT atomic.

I found Nginx Log write is use O_APPEND to write atomic, even Nginx has a
lot of workers.

And

I read the source code by your link `write-file-atomic`, it is hard to port
to NJS. The reason is that NJS fs without fs.rename, and Nodejs write file
atomic use temp file rename and write queue to make it.

Thanks.

HENG <ourwaiting@gmail.com> 于2018年10月20日周六 上午12:55写道:

> Thanks your reply.
>
> When I deep into NJS source you ponit to, I found something about GCC
> write file flag with O_APPEND
>
> I google Linux GCC write file O_APPEND to learn something.
>
> In fact NJS fs.writeFileSync() with O_APPEND, it is atomic write file if
> it's buffer just write all in one time. Even mutil process to write one
> file use O_APPEND.
>
> But, if write buffer can NOT write all in one time, in mutil process, it
> is NOT atomic.
>
> I found Nginx Log write is use O_APPEND to write atomic, even Nginx has a
> lot of workers.
>
> And
>
> I read the source code by your link `write-file-atomic`, it is hard to
> port to NJS. The reason is that NJS fs without fs.rename, and Nodejs write
> file atomic use temp file rename and write queue to make it.
>
> Thanks.
>
>
> --
> --------------------------------------------------------------------
> Heng
> ---------------------------------------------------------------------
> --
>


--
--------------------------------------------------------------------
Heng
---------------------------------------------------------------------
--
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Nginx NJS fs.writeFileSync is atomic writing and race condition prevention ?

HENG 400 October 18, 2018 11:36PM

Re: Nginx NJS fs.writeFileSync is atomic writing and race condition prevention ?

Dmitry Volyntsev 128 October 19, 2018 07:28AM

Re: Nginx NJS fs.writeFileSync is atomic writing and race condition prevention ?

HENG 173 October 19, 2018 01:00PM

Re: Nginx NJS fs.writeFileSync is atomic writing and race condition prevention ?

Valentin V. Bartenev 154 October 19, 2018 01:04PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready