Copy link to clipboard
Copied
I have the following issue. My application has a single application.cfc (no application.cfm). Application variables are consistently "disappearing," i.e., becoming undefined. This is generating runtime errors after minimal user activity. If the server is rebooted, the variables persist for a very short time (a few minutes) and then are undefined again.At what time the variables "disappear" appears to be random.
The server is a ColdFusion Enterprise server (CF 8).
Does anyone know why application variables would suddenly go from being defined to undefined within the same user visit? Is there any "side effect" of built-in CF functions or tags which could cause this behavior unexpectedly?
Thanks.
Copy link to clipboard
Copied
Do you have an application name that is also used by another website on the
same server perhaps? Try making it very unique.
Copy link to clipboard
Copied
Good idea, but this is the ONLY application on the server. And the name is very unique. Any other ideas? Also, even when usage is restricted to is restricted to a single user, the issue arises.
Copy link to clipboard
Copied
Could you be setting application variables outside of the Application.cfc and the application times out? If so the variable will become undefined until the other template runs and sets it. What is your app timeout? How heavily trafficed is the app?
Copy link to clipboard
Copied
Right now, essentially only a few internal users, really only one. So it's not heavy traffic at all. The issue happens even with only a single user.
We are creating/defining some application variables outside of the Application.cfc. But we are not undefining any Application variables outside of the CFC. We add application variables dynamically by defining a struct in the application and adding variables to that struct. This is standard practice and has never caused a problem before.
Our app timeout is 24 hrs. The application scope will last that long.
Thanks!
Copy link to clipboard
Copied
So you're saying the app never times out? Just making sure I understand you.
I'm thinking of a situation like this:
pageOne.cfm
--sets application.foo = 'something'
pageTwo.cfm
--outputs #application.foo#
application times out, first user after timeout hits pageTwo.cfm first thing in the day, application.foo is undefined.
Typically if I am setting application variables outside of the Application.cfc I at least make sure the onApplicationStart() method sets the value first to an empty value (string, struct, array, whatever) so that I know it will at least exist elsewhere.
Copy link to clipboard
Copied
I am saying the application scope will last 24 hours, at which time it will reset. That is the server setting. So for all practical purposes, you are correct: it will not (and is not) resetting.
The scenario you describe below is not happening. What's happening is a variable is defined in application one moment and not the next. Not just one variable---but all of them. We're losing the application scope variables. This is happening for all app vars, including ones we intialize in the application.cfc.
Copy link to clipboard
Copied
ashtonwilkins wrote:
That is the server setting.
You are aware that the server setting CAN be overridden in CODE. with either a <cfapplication applicationTimeout...> tag or a this.appliationTimeout= in an Application.cfc file psedudo constructor.
Have you confirmed one of these where not dropped somewhere in the code?
Copy link to clipboard
Copied
Yes, aware, and no, we're not changing it in code.
Copy link to clipboard
Copied
Create an app variable called NOW with date of current date time. Then view
the app var after issue happens. See if / when app is resetting.
Copy link to clipboard
Copied
I'm working on a sophisticated-enough way to do this very thing. I did some manual dumps and can find when they disappear in this sense: it is always on a POST, and I can use an if statement to identify when they're gone. But it's random in the sense that they sometimes persist throughout a few more posts than at other times. Also, they do not always disappear on the same page. It truly appears to be random.
I'm pretty sure (99.9%) that the server is not getting rebooted. But putting logging in the applicationend is a good idea.
Copy link to clipboard
Copied
Is it •any• application-scoped vars that could vanish, or always specific ones?
Are the application-scoped vars all set in onApplicationStart(), or could they be set elsewhere in the code?
Perhaps put a entry in OnApplicationStart() to check it's only getting run when you •think• it's getting run...
--
Adam
Copy link to clipboard
Copied
In short: nope.
Do you any stray Application.cf(c|m) files around?
Are you doing some sort of "variable clearance" that might not consider "pass by reference" issues, or something?
Hard to tell.
--
Adam
Copy link to clipboard
Copied
There is only one application.cfc. No other application.* file. We did a search of all directories.
I don't understand the second question about variable clearance, but if you mean this: (1) we have a struct; (2) we pass it to a function; (3) the function clears it, then no, that's not happening. I understand struct's are passed as references in CF, so we aren't doing that. We never clear out the application struct.
Copy link to clipboard
Copied
And you're absolutely certain that the server isn't crashing/restarting without your knowledge? I'd try Josh's suggestion. I'd also put some logging in onApplicationEnd. I'd also check my application/exception/server logs.
Copy link to clipboard
Copied
Good idea, I will do this.
Copy link to clipboard
Copied
It sounds like you •do• understand what I meant by the reference thing. In that light: I just have to shrug. Sorry.
--
Ada
Copy link to clipboard
Copied
I'm assuming this is not a clustered environment?