openresty / openresty/lua-nginx-module

openresty lua buffer is writing only 4kb file from buffer

Open
#1,498 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

Hi ,

This is our openresty lua code

ngx.say("success")
ngx.eof()
local function write_to_file()
local args = ngx.req.get_uri_args()
local file, err = io.open("/home/ubuntu/lua_files/lua_dir/example.csv", "a")
if file==nil then
ngx.say("Couldn't open file: "..err)
else
file:setvbuf("full", 1000000)
for key, val in pairs(args) do
file:write(val," ")
end
file:close()
end
end
ngx.thread.spawn(write_to_file)


When we use above code to lua to maintain buuffer of 1mb in, but it is writing 4kb to file on periodically based on inoming requests

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides only an inline OpenResty Lua snippet centered on write_to_file and file:setvbuf; no repository file or test is named. Start by reproducing the request-driven writes and inspect the module's documented buffering behavior; done means identifying whether 4 KB writes are expected and specifying a verified fix or explanation.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.