DSN is Saving CF Query Ops to Wrong Database?

View: New views
8 Messages — Rating Filter:   Alert me  

DSN is Saving CF Query Ops to Wrong Database?

by Matthew Reinbold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm dealing with some real oddness today and I was wondering if anybody else has seen something similar.

We have a development environment and a test environment. Each environment has its own database on the same instance of SQL Server (9.04.3042....). So the database that dev hits is named "DEV" and test runs their code against a database named "TEST".

There are also separate ColdFusion server instances, again one for dev and another for test. The DSN used for queries used throughout the application are the same, "MYDB" but on the dev instance the application DSN is pointed to the DEV table. Likewise, the test instance has a DSN of "MYDB" but its pointed at the Test table.

Today a number of tests on the test instance were failing. Examining the test table showed that no actions had taken place. Upon examination, it appears that the Test instance had been writing and reading data to the Dev database, despite the settings in the ColdFusion administrator. Subsequent server restarts did not result in different behavior.

Has anyone seen anything like this? Is it possible for SQL Server to cache some user information? How can I find more information about what might be going on?

Matthew Reinbold
Creative Principal, Vox Pop Design, http://voxpopdesign.com
Manager, Salt Lake ColdFusion User's Group, http://slcfug.org 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324264
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by David McGuigan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Maybe. Make sure each of your applications has its own namespace by using this.name in Application.cfc, otherwise they'll share ( and overwrite eachother ) anything you put into the application scope across the entire JVM if I remember correctly. In this case the pointer to a datasource or the reference if the datasource name is identical.


-- Sent from my Palm Pre
Matthew Reinbold wrote:


I'm dealing with some real oddness today and I was wondering if anybody else has seen something similar.

We have a development environment and a test environment. Each environment has its own database on the same instance of SQL Server (9.04.3042....). So the database that dev hits is named "DEV" and test runs their code against a database named "TEST".

There are also separate ColdFusion server instances, again one for dev and another for test. The DSN used for queries used throughout the application are the same, "MYDB" but on the dev instance the application DSN is pointed to the DEV table. Likewise, the test instance has a DSN of "MYDB" but its pointed at the Test table.

Today a number of tests on the test instance were failing. Examining the test table showed that no actions had taken place. Upon examination, it appears that the Test instance had been writing and reading data to the Dev database, despite the settings in the ColdFusion administrator. Subsequent server restarts did not result in different behavior.

Has anyone seen anything like this? Is it possible for SQL Server to cache some user information? How can I find more information about what might be going on?

Matthew Reinbold
Creative Principal, Vox Pop Design, http://voxpopdesign.com
Manager, Salt Lake ColdFusion User's Group, http://slcfug.org 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324268
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by Matthew Reinbold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Maybe. Make sure each of your applications has its own namespace by
> using this.name in Application.cfc, otherwise they'll share ( and
> overwrite eachother ) anything you put into the application scope

Interesting. Looking through the inherited code I'm seeing that in the application.cfc OnApplicationStart method the DSN is set like:

<cfset application.ds = "mydb" />

Would that be any different than using:

<cfset this.ds = "mydb" />

?

Also, to clarify, the "separate" Coldfusion servers for Dev and Test are separate instances upon the same JRun, so some kind of variable scope "leakage" might make sense.

-Matthew

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324270
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> <cfset application.ds = "mydb" />
>
> Would that be any different than using:
>
> <cfset this.ds = "mydb" />

Yes, those are two different things. The first creates a variable in
the Application scope. The second creates a property of the
application.cfc instance.

> Also, to clarify, the "separate" Coldfusion servers for Dev and Test are separate
> instances upon the same JRun, so some kind of variable scope "leakage" might make
> sense.

What exactly do you mean by "separate instances upon the same JRun"?
If you mean that you have separate JRun instances, they should not
share memory at all - each should be represented by a separate Windows
service (assuming you're running Windows). If, on the other hand,
you've deployed multiple CF WARs to the same JRun server - and I'm not
sure that's even possible - they would share memory.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324272
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by David McGuigan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


So do your Application.cfc files have a <cfset this.name = "etc" /> in their
pseudo constructors?


On Mon, Jul 6, 2009 at 3:43 PM, Matthew Reinbold <
matthew.reinbold@...> wrote:

>
> > Maybe. Make sure each of your applications has its own namespace by
> > using this.name in Application.cfc, otherwise they'll share ( and
> > overwrite eachother ) anything you put into the application scope
>
> Interesting. Looking through the inherited code I'm seeing that in the
> application.cfc OnApplicationStart method the DSN is set like:
>
> <cfset application.ds = "mydb" />
>
> Would that be any different than using:
>
> <cfset this.ds = "mydb" />
>
> ?
>
> Also, to clarify, the "separate" Coldfusion servers for Dev and Test are
> separate instances upon the same JRun, so some kind of variable scope
> "leakage" might make sense.
>
> -Matthew
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324273
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by Matthew Reinbold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>So do your Application.cfc files have a <cfset this.name = "etc" /> in their
>pseudo constructors?

The application name is setup exactly as you've described: "this.name = 'myapp'". But the dsn used by queries is set in the onapplicationstart method by saying "application.ds = 'mydb'".

As implied before, these are separate JRun instances. They should have completely separate memory. Why queries to the datasource 'mydb' configured to use the DEV table on one instance while the datasource 'mydb' is configured to use the TEST table is getting screwed up is beyond me.

-Matthew

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324299
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by Matthew Reinbold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> the DEV table on one instance while the datasource 'mydb' is configured to use the TEST table

Ugh. Long night of tracking down shadows, hints, and allegations. That's the DEV *database* and the TEST *database*, not tables.

Turns out the problem was that the previous developer had buried sql queries explicitly stating the database to use in the query:

INSERT INTO [DEV].[dbo].[myTable]....

-Matthew

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324302
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: DSN is Saving CF Query Ops to Wrong Database?

by Adam Haskell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Point of clarification Jrun (app server) can have multiple ColdFusion
deployments (WARs or EARs) and while they share the same JVM they are
separate. In other words, you could have CF Instance 1 with an application
named MyApp and a cf instance 2 with an application named MyApp and they
would not share anything in Application Scope (or Server scope for that
matter). The only case where this is not entirely true, as far as I am
aware, is in WebSphere and that is a slighly different beast with how WAS is
setup.

Adam Haskell


On Mon, Jul 6, 2009 at 6:07 PM, Dave Watts <dwatts@...> wrote:

>
> > <cfset application.ds = "mydb" />
> >
> > Would that be any different than using:
> >
> > <cfset this.ds = "mydb" />
>
> Yes, those are two different things. The first creates a variable in
> the Application scope. The second creates a property of the
> application.cfc instance.
>
> > Also, to clarify, the "separate" Coldfusion servers for Dev and Test are
> separate
> > instances upon the same JRun, so some kind of variable scope "leakage"
> might make
> > sense.
>
> What exactly do you mean by "separate instances upon the same JRun"?
> If you mean that you have separate JRun instances, they should not
> share memory at all - each should be represented by a separate Windows
> service (assuming you're running Windows). If, on the other hand,
> you've deployed multiple CF WARs to the same JRun server - and I'm not
> sure that's even possible - they would share memory.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more information!
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324306
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4