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

DurableHttpUsingFileSizeRolledBuffers silently fails when write no permissions on buffer file. #95

Closed
WrathZA opened this issue Jan 16, 2020 · 25 comments · Fixed by #111
Labels
bug Something isn't working

Comments

@WrathZA
Copy link

WrathZA commented Jan 16, 2020

Describe the bug
DurableHttpUsingFileSizeRolledBuffers silently fails when the application doesn't have permission to create or write to the buffer file.

To Reproduce
Create a DurableHttpUsingFileSizeRolledBuffers with just the requestUri

Expected behavior
Thrown an exception.

Additional context
Discovered this issue when deploying applications using "enterprise" Docker containers where the default container user has limited permissions to local file system.

Just a heads up. Thank you for the work in producing this.

@WrathZA WrathZA added the bug Something isn't working label Jan 16, 2020
@github-actions
Copy link
Contributor

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

@FantasticFiasco
Copy link
Owner

Hi WrathZA!

Sorry for taking this long before getting back to you, but you will soon understand why.

Some of the reported issues on this repo indicate that there is a discrepancy between what one is expecting from Serilog, and what actually happens. Sometimes this isn't because the sink is behaving badly, it's because there are some aspects of Serilog, very few I would add, that aren't intuitive.

I cannot fix these unexpected behaviors, but I can try to bridge the gap by describing these problems, why they exist, and their remedy. I've created a wiki page in this repo called Common problems that aim to document unexpected behaviors, like yours. Would you be willing to read that page and tell me if it gives you an explanation to your problem? I think other developers with the exact same problem as you will have a better chance of finding the information on the wiki than in this issue. What do you think?

Thank you very much for being the trigger of creating that wiki page, I praise you for creating this issue although you didn't have to, you solved your issue yourself!

@WrathZA
Copy link
Author

WrathZA commented Jan 20, 2020

Thanks, the wiki is very helpful.

I'm guessing the issue is

// Where no HRESULT is available, assume IOExceptions indicate a locked file

Where is assumes the file is always locked.

I can do a PR on the Bookmark File or on the ctor of the Sink to confirm we have RW access to the files system and self log that fact for others?

@FantasticFiasco
Copy link
Owner

FantasticFiasco commented Jan 20, 2020

Lets back up, making sure that we are on the same page. I think the following statements are true, and you have to tell me which aren't from your point of view.

  1. No exception is thrown by the sink when it fails to write to a buffer file, and even though, perhaps, this is something that one would expect, it is aligned with the guidelines of Serilog and shouldn't change
  2. The above exception is written to SelfLog
  3. No exception is thrown by the sink when it fails to write to the bookmark file, and even though, perhaps, this is something that one would expect, it is aligned with the guidelines of Serilog and shouldn't change
  4. The above error is written to SelfLog

@WrathZA
Copy link
Author

WrathZA commented Jan 21, 2020

I think I understand, though you have much much more experience and context than me. When digging through the code, I noticed there is validation in the form of application exceptions in other ctors.

Close if it's inline with your design, though I'm happy to help with anything should you require it.

@FantasticFiasco
Copy link
Owner

I noticed there is validation in the form of application exceptions in other ctors.

You're correct on this one. There are most certainly exceptions thrown from code that perhaps shouldn't have been thrown, that should have been written to SelfLog instead. Error handling can be improved, and more intuitive.

When it comes to validation, the problem with I/O, whether it's disk or network, is that it doesn't matter if we validate anything at the start, because its state isn't constant. Even if we validate that we can write to disk when the sink is created, there are many things that can cause us not being able to write to disk after any duration of time.

@WrathZA WrathZA closed this as completed Jan 22, 2020
@esakkiraja-k
Copy link

I am facing the same problem in my production servers. no clue what is the reason for file being locked.

@FantasticFiasco
Copy link
Owner

Is the file locked at the very beginning when your application is starting, or later when the application has been working for a time?

@esakkiraja-k
Copy link

It is getting locked after sometime. After I have done couple of IIS reset it starts working. please help me with it. no clue what to do now.

@esakkiraja-k
Copy link

I think we may need to provide shared: true to be configurable when I create a logger.
please share your thoughts
https://nblumhardt.com/2014/05/logging-and-locked-files/

@FantasticFiasco
Copy link
Owner

Can we verify that IIS application pool recycling is the issue? Can you disable overlapped recycling to verify that it is the cause, and not misbehaving anti-virus software or something similar.

@esakkiraja-k
Copy link

Sure. let me try and will let you know. thanks.

@FantasticFiasco
Copy link
Owner

Hi @esakkiraja-k. Where you able to verify the issue?

@esakkiraja-k
Copy link

we changed iis changed app pool recycle to 0. but still we are seeing drop

@esakkiraja-k
Copy link

could you please help me with it. could you please expose an attribute with shared:true.

@FantasticFiasco
Copy link
Owner

I can build you a special version that has set it to true, and you can verify that it works. After that I can build an official version. Which version of the sink are you currently using?

@esakkiraja-k
Copy link

5.2.0 i am using it now. please build it and share. thanks a lot. I hope it may solve the problem

@FantasticFiasco
Copy link
Owner

I'll see if I can get it built tonight

@FantasticFiasco
Copy link
Owner

I've built a new preview, soon to be public on nuget.org. You can find it here. Can you try it out to see if it solves your issue?

@esakkiraja-k
Copy link

thanks a lot. give a couple of days I will verify and get back to you.. how to check your changes..

@FantasticFiasco
Copy link
Owner

You can diff the changes between master and issues/95

@esakkiraja-k
Copy link

it works. please release it. I will upgrade to latest version. please move this fix to latest version. thanks a lot.

@FantasticFiasco
Copy link
Owner

I'll release a new version this week. I'll make a new comment here when it's done.

@FantasticFiasco
Copy link
Owner

v6.0.0 is now available on nuget.org. Thanks for providing information regarding the issue.

@esakkiraja-k
Copy link

esakkiraja-k commented May 15, 2020

thanks for the quick fix. I appreciate your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants