Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsqd: Make sure data directory is writeable on startup #185

Merged
merged 1 commit into from
Apr 29, 2013

Conversation

mreiferson
Copy link
Member

We ran into a problem this morning where our nsqd processes filled up their in-memory queues and couldn't persist the messages to disk. The error log is here:

2013/04/25 17:42:50 CHANNEL(**) ERROR: failed to write message to backend - open *__:**.diskqueue.000000.dat: permission denied

It was our fault for not specifying the --data-path on the command line, but this is something that could easily be checked on startup, leaving it until the in-memory queue is full means that if nsqd needs to be reconfigured and restarted, all messages will be dropped. This is a significant problem.

Also, it's impossible to tell from the error message where the directory is that the data is being saved. Does this default to the root directory, or is it a blank string like the command-line documentation shows?

@mreiferson
Copy link
Member

@rafikk yep, agreed, thanks for the report.

It does actually default to an empty string, the current working directory.

@rafikk
Copy link
Author

rafikk commented Apr 25, 2013

Okay, @mreiferson, thanks for the response. Maybe this should be a required parameter? We were using supervisord to manage the process and it was starting it from the root directory.

Perhaps nsqd should create the .dat files on startup and append to them when the memory queue overflows instead of deferring their creation to when it's needed.

@mreiferson
Copy link
Member

yea, I've gone back and forth in my head about being able to provide sane defaults for command line arguments so when you're just experimenting with the tools you don't have to configure so much.

I think your suggestion is the right one... it should just confirm that its data directory is writable on startup and exit spectacularly if it isn't 😄

You can't create the topic/channel .dat files at initial startup because they don't exist yet (they're created lazily by a producer or consumer) but it can still create the daemon's .dat file to confirm writability.

@mreiferson
Copy link
Member

RFR @jehiah (cc @rafikk)

@jehiah
Copy link
Member

jehiah commented Apr 29, 2013

LGTM

jehiah added a commit that referenced this pull request Apr 29, 2013
nsqd: Make sure data directory is writeable on startup
@jehiah jehiah merged commit 03dcbbf into nsqio:master Apr 29, 2013
absolute8511 pushed a commit to absolute8511/nsq that referenced this pull request Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants