FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » file being saved causes fatal error.
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
file being saved causes fatal error. [message #179721] Wed, 28 November 2012 02:28 Go to next message
rodeored is currently offline  rodeored
Messages: 2
Registered: November 2012
Karma: 0
Junior Member
If a website user if trying to access a class file at the same time it is being saved, this causes a fatal error. Is there anyway to save the file without causing it to be unavailable for any amount of time?
Re: file being saved causes fatal error. [message #179722 is a reply to message #179721] Wed, 28 November 2012 03:42 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/27/2012 9:28 PM, rodeored wrote:
> If a website user if trying to access a class file at the same time it is being saved, this causes a fatal error. Is there anyway to save the file without causing it to be unavailable for any amount of time?
>

No. It's not PHP causing the problem - it's the OS. While the file is
being saved, a good OS will prevent any other process from reading the
file. Otherwise the other process may get part new, part old.

Before changing ANY files on a live system you should first take the
system offline, then make you changes, and bring the system back online.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: file being saved causes fatal error. [message #179724 is a reply to message #179722] Wed, 28 November 2012 15:57 Go to previous messageGo to next message
rodeored is currently offline  rodeored
Messages: 2
Registered: November 2012
Karma: 0
Junior Member
On Tuesday, November 27, 2012 10:42:27 PM UTC-5, Jerry Stuckle wrote:
>
> No. It's not PHP causing the problem - it's the OS. While the file is
>
> being saved, a good OS will prevent any other process from reading the
>
> file. Otherwise the other process may get part new, part old.
>
>
>
> Before changing ANY files on a live system you should first take the
>
> system offline, then make you changes, and bring the system back online.
>
>
Thank you for your response. What is the system or mechanism for preventing other process from reading a file being saved called? This is on a Linux operating system on an Amazon server.
If a good OS will prevent any other process from reading the file, then why does the system have to be taken off line?
Re: file being saved causes fatal error. [message #179725 is a reply to message #179724] Wed, 28 November 2012 17:30 Go to previous messageGo to next message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma: 0
Member
At Wed, 28 Nov 2012 07:57:23 -0800 (PST) rodeored <info1(at)reenie(dot)org> wrote:

>
> On Tuesday, November 27, 2012 10:42:27 PM UTC-5, Jerry Stuckle wrote:
>>
>> No. It's not PHP causing the problem - it's the OS. While the file is
>>
>> being saved, a good OS will prevent any other process from reading the
>>
>> file. Otherwise the other process may get part new, part old.
>>
>>
>>
>> Before changing ANY files on a live system you should first take the
>>
>> system offline, then make you changes, and bring the system back online.
>>
>>
> Thank you for your response. What is the system or mechanism for preventing other process from reading a file being saved called? This is on a Linux operating system on an Amazon server.
> If a good OS will prevent any other process from reading the file, then why does the system have to be taken off line?

Not the whole O/S, but generally when a CMS system (eg WordPress) is
updating itself, it puts the site in 'maintainence mode', presenting a
'This site is currently offline for maintainence' type of page.
Typically, this only lasts for a short time (maybe a couple of minutes
or so) while the php files for the update are downloaded, unpacked, and
the things like the database updated as needed. You generally don't
want people visiting your web site while the code (php files) that
implement it are 'in flux' (being updated).

>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
Re: file being saved causes fatal error. [message #179726 is a reply to message #179724] Wed, 28 November 2012 17:52 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/28/2012 10:57 AM, rodeored wrote:
> On Tuesday, November 27, 2012 10:42:27 PM UTC-5, Jerry Stuckle wrote:
>>
>> No. It's not PHP causing the problem - it's the OS. While the file is
>>
>> being saved, a good OS will prevent any other process from reading the
>>
>> file. Otherwise the other process may get part new, part old.
>>
>>
>>
>> Before changing ANY files on a live system you should first take the
>>
>> system offline, then make you changes, and bring the system back online.
>>
>>
> Thank you for your response. What is the system or mechanism for preventing other process from reading a file being saved called? This is on a Linux operating system on an Amazon server.
> If a good OS will prevent any other process from reading the file, then why does the system have to be taken off line?
>

When a file is being updated, the file will generally be locked by the
OS. Attempts to access it by other processes will return a lock error.

So you need to take other processes which may access the file (the
website, in this case) down while the update is being performed, or get
an error if someone tries to access it.

This has nothing to do with PHP. It's the OS doing it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: file being saved causes fatal error. [message #179727 is a reply to message #179724] Wed, 28 November 2012 19:02 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 28/11/12 15:57, rodeored wrote:
> On Tuesday, November 27, 2012 10:42:27 PM UTC-5, Jerry Stuckle
> wrote:
>>
>> No. It's not PHP causing the problem - it's the OS. While the
>> file is
>>
>> being saved, a good OS will prevent any other process from reading
>> the
>>
>> file. Otherwise the other process may get part new, part old.
>>
>>
>>
>> Before changing ANY files on a live system you should first take
>> the
>>
>> system offline, then make you changes, and bring the system back
>> online.
>>
>>
> Thank you for your response. What is the system or mechanism for
> preventing other process from reading a file being saved called? This
> is on a Linux operating system on an Amazon server. If a good OS will
> prevent any other process from reading the file, then why does the
> system have to be taken off line?
>
Its jerry talking, therefore its bollocks.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: file being saved causes fatal error. [message #179728 is a reply to message #179724] Wed, 28 November 2012 19:15 Go to previous messageGo to next message
Anders Wegge Keller is currently offline  Anders Wegge Keller
Messages: 30
Registered: May 2012
Karma: 0
Member
rodeored <info1(at)reenie(dot)org> writes:

> If a good OS will prevent any other process from reading the file,
> then why does the system have to be taken off line?

You don't *have* to do, but it's complicated to upgrade a live
system. Most filesystems nowadays are able to make an atomic upgrade
of a file, or even a complete directory hierachy, but the details
about that is outside the scope of this group.

--
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*
Re: file being saved causes fatal error. [message #179746 is a reply to message #179721] Mon, 03 December 2012 09:20 Go to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 28.11.2012 03:28, schrieb rodeored:
> If a website user if trying to access a class file at the same time it is being saved, this causes a fatal error. Is there anyway to save the file without causing it to be unavailable for any amount of time?
>

Just think about your case:

the file is being updated. That means it is not complete.

Depending on how the update software works, you can either read a file of zero
length, or an incomplete file.

What will happen if PHP reads/executes a class file of zero lenght? The class
definition is missing, fatal.

What will happen, if PHP reads/executes an incomplete file? A syntax error, fatal.

What you must do:
- make sure the class file is not read/executed during update.

What you can do:
- speed up the upgrade process (upload to some other file and copy locally, ...)

/Str.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Experience Web and Smartphone designer required
Next Topic: [Windows] php-cgi.exe can't find extension
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 23:40:43 GMT 2024

Total time taken to generate the page: 0.02913 seconds