Why are these T-SQL jobs from different SQL Server instances executed on the same instance (Always On...
Do authors have to be politically correct in article-writing?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Which one of these password policies are more secure?
Quickly creating a sparse array
Am I a Rude Number?
Making him into a bully (how to show mild violence)
Why avoid shared user accounts?
Why is Agricola named as such?
How to prevent users from executing commands through browser URL
Why is working on the same position for more than 15 years not a red flag?
What incentives do banks have to gather up loans into pools (backed by Ginnie Mae)and selling them?
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
How to make ice magic work from a scientific point of view?
Is a new Boolean field better than a null reference when a value can be meaningfully absent?
Hybrid flat to drop conversion advice
How should I handle players who ignore the session zero agreement?
Can a hotel cancel a confirmed reservation?
Intern applicant asking for compensation equivalent to that of permanent employee
How should I approach using two 8s and two 3s to make the number 24?
What are "industrial chops"?
How can animals be objects of ethics without being subjects as well?
How can I display a custom maintenance message on Magento 2.2.4
Can a Pact of the Blade warlock use the correct existing pact magic weapon so it functions as a "Returning" weapon?
How would an AI self awareness kill switch work?
Why are these T-SQL jobs from different SQL Server instances executed on the same instance (Always On Availability Groups)
AlwaysOn SQL Agent JobsFiles copying to different machine not happening from batch file executed from SQL JobsOn which node first transaction will be executed in Always-on setup?SQL Server 2012 AlwaysOn Availability Group active/passiveScheduled jobs run twice after upgrade to SQL Server 2012Is it possible to have one Sql-Server cluster node in multiple Sql-Server clusters?How long does a failover for SQL Server Availability Groups take?SQL Server 2016 Always ON high availability group listener configurationSQL Server 2017 CU3 will not add read-scale replica. Thinks there is a clusterSQL Server 2017 Availability Groups - Can a Long-running transactions on a primary replica block a secondary replica from seeing updates?
Recently, our blocked processes dashboard has been reporting blocked processes around the time when we do our statistic update.
The reason was quickly found: an update statistics jobstep (T-SQL) that is starting on both the Passive and the Active SQL Server instance.
The job updates several statistics on the same database, that is part of an Always On Availability group. I would expect this to fail on the secondary instance.
A quick rundown of the failover history:
Server A that should stay active due to licensing (will be named Active server), failed over unexpectedly to Server B (Passive Server). on 20/02 9PM.
After the unplanned failover, we did another (but this time planned) manual failover back to the Active server on 21/02 at 12PM.
Job history
Before the first failover all was good, and the active server is the only one running the job.
One job running.
We see the stat updates running on the Active side. (which is primary replica at the time)
During the short time that the passive server was the primary replica, we don't have any monitoring and the job history was cleared.
After the failover, back to the 'normal' state, after being on primary on the passive node for less than 24 hours, the jobstep on the passive instance has also been starting and running on the active instance.
(I killed the sessions).
Now the interesting part to me, is that both jobs are running on the active server, seeming like the job is using the listener to get to the database. But it could be an entirely different reason.
There is a copy job powershell task running nightly at 01 AM (dbatools):
powershell.exe Copy-DbaAgentJob -ExcludeJob "CopyJobs,CopyLogins" -Source INDCSPSQLA01 -Destination INDCSPSQLP01 -Force
My guess is now aimed at the one time, the job copy happened from the active, secondary node --> primary passive node with -Force. This happened at 21/02 01 AM.
The Question
Why is the jobstep on the passive instance executing on the active instance's Database?
Checklist
On both instances, the job target is local:
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
The servername is correct
select name from sys.servers
select @@SERVERNAME
both return the passive server.
The job id's of active and passive are different:
--08C63F07-0853-41DA-BC88-8FDF44AE491F -- passive
--E8C88965-C581-4E06-B651-CC10637FCEEF -- active
Both jobs use the database in question in their step:
@database_name=N'DB1',
--> Should not be accessible on the passive instance, resulting in failure.
No readable secondaries
The database is not accessible on the passive instance:
Version of both servers: 14.0.3030.27
T-SQL Job step command example
@subsystem=N'TSQL',
@command=N'update statistics dbo.table with fullscan ...'
Nothing is running on the passive instance when the job starts.
EDIT:
Restarting the agent on the passive node 'fixes' this, resulting in a new error on executing:
Unable to connect to SQL Server 'INDCSPSQLP01'. The step failed.
As a result, it no longer updates statistics on the primary instance
Hostnames = Passive & Active node, jobs where visibly running.
Application info
SQLAgent - TSQL JobStep (Job 0x9D358B2EF6C53C4BAD6A61CA87D51BF5 : Step 1)
SQLAgent - TSQL JobStep (Job 0x6589C8E881C5064EB651CC10637FCEEF : Step 1)
sql-server availability-groups sql-server-2017 jobs
add a comment |
Recently, our blocked processes dashboard has been reporting blocked processes around the time when we do our statistic update.
The reason was quickly found: an update statistics jobstep (T-SQL) that is starting on both the Passive and the Active SQL Server instance.
The job updates several statistics on the same database, that is part of an Always On Availability group. I would expect this to fail on the secondary instance.
A quick rundown of the failover history:
Server A that should stay active due to licensing (will be named Active server), failed over unexpectedly to Server B (Passive Server). on 20/02 9PM.
After the unplanned failover, we did another (but this time planned) manual failover back to the Active server on 21/02 at 12PM.
Job history
Before the first failover all was good, and the active server is the only one running the job.
One job running.
We see the stat updates running on the Active side. (which is primary replica at the time)
During the short time that the passive server was the primary replica, we don't have any monitoring and the job history was cleared.
After the failover, back to the 'normal' state, after being on primary on the passive node for less than 24 hours, the jobstep on the passive instance has also been starting and running on the active instance.
(I killed the sessions).
Now the interesting part to me, is that both jobs are running on the active server, seeming like the job is using the listener to get to the database. But it could be an entirely different reason.
There is a copy job powershell task running nightly at 01 AM (dbatools):
powershell.exe Copy-DbaAgentJob -ExcludeJob "CopyJobs,CopyLogins" -Source INDCSPSQLA01 -Destination INDCSPSQLP01 -Force
My guess is now aimed at the one time, the job copy happened from the active, secondary node --> primary passive node with -Force. This happened at 21/02 01 AM.
The Question
Why is the jobstep on the passive instance executing on the active instance's Database?
Checklist
On both instances, the job target is local:
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
The servername is correct
select name from sys.servers
select @@SERVERNAME
both return the passive server.
The job id's of active and passive are different:
--08C63F07-0853-41DA-BC88-8FDF44AE491F -- passive
--E8C88965-C581-4E06-B651-CC10637FCEEF -- active
Both jobs use the database in question in their step:
@database_name=N'DB1',
--> Should not be accessible on the passive instance, resulting in failure.
No readable secondaries
The database is not accessible on the passive instance:
Version of both servers: 14.0.3030.27
T-SQL Job step command example
@subsystem=N'TSQL',
@command=N'update statistics dbo.table with fullscan ...'
Nothing is running on the passive instance when the job starts.
EDIT:
Restarting the agent on the passive node 'fixes' this, resulting in a new error on executing:
Unable to connect to SQL Server 'INDCSPSQLP01'. The step failed.
As a result, it no longer updates statistics on the primary instance
Hostnames = Passive & Active node, jobs where visibly running.
Application info
SQLAgent - TSQL JobStep (Job 0x9D358B2EF6C53C4BAD6A61CA87D51BF5 : Step 1)
SQLAgent - TSQL JobStep (Job 0x6589C8E881C5064EB651CC10637FCEEF : Step 1)
sql-server availability-groups sql-server-2017 jobs
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago
add a comment |
Recently, our blocked processes dashboard has been reporting blocked processes around the time when we do our statistic update.
The reason was quickly found: an update statistics jobstep (T-SQL) that is starting on both the Passive and the Active SQL Server instance.
The job updates several statistics on the same database, that is part of an Always On Availability group. I would expect this to fail on the secondary instance.
A quick rundown of the failover history:
Server A that should stay active due to licensing (will be named Active server), failed over unexpectedly to Server B (Passive Server). on 20/02 9PM.
After the unplanned failover, we did another (but this time planned) manual failover back to the Active server on 21/02 at 12PM.
Job history
Before the first failover all was good, and the active server is the only one running the job.
One job running.
We see the stat updates running on the Active side. (which is primary replica at the time)
During the short time that the passive server was the primary replica, we don't have any monitoring and the job history was cleared.
After the failover, back to the 'normal' state, after being on primary on the passive node for less than 24 hours, the jobstep on the passive instance has also been starting and running on the active instance.
(I killed the sessions).
Now the interesting part to me, is that both jobs are running on the active server, seeming like the job is using the listener to get to the database. But it could be an entirely different reason.
There is a copy job powershell task running nightly at 01 AM (dbatools):
powershell.exe Copy-DbaAgentJob -ExcludeJob "CopyJobs,CopyLogins" -Source INDCSPSQLA01 -Destination INDCSPSQLP01 -Force
My guess is now aimed at the one time, the job copy happened from the active, secondary node --> primary passive node with -Force. This happened at 21/02 01 AM.
The Question
Why is the jobstep on the passive instance executing on the active instance's Database?
Checklist
On both instances, the job target is local:
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
The servername is correct
select name from sys.servers
select @@SERVERNAME
both return the passive server.
The job id's of active and passive are different:
--08C63F07-0853-41DA-BC88-8FDF44AE491F -- passive
--E8C88965-C581-4E06-B651-CC10637FCEEF -- active
Both jobs use the database in question in their step:
@database_name=N'DB1',
--> Should not be accessible on the passive instance, resulting in failure.
No readable secondaries
The database is not accessible on the passive instance:
Version of both servers: 14.0.3030.27
T-SQL Job step command example
@subsystem=N'TSQL',
@command=N'update statistics dbo.table with fullscan ...'
Nothing is running on the passive instance when the job starts.
EDIT:
Restarting the agent on the passive node 'fixes' this, resulting in a new error on executing:
Unable to connect to SQL Server 'INDCSPSQLP01'. The step failed.
As a result, it no longer updates statistics on the primary instance
Hostnames = Passive & Active node, jobs where visibly running.
Application info
SQLAgent - TSQL JobStep (Job 0x9D358B2EF6C53C4BAD6A61CA87D51BF5 : Step 1)
SQLAgent - TSQL JobStep (Job 0x6589C8E881C5064EB651CC10637FCEEF : Step 1)
sql-server availability-groups sql-server-2017 jobs
Recently, our blocked processes dashboard has been reporting blocked processes around the time when we do our statistic update.
The reason was quickly found: an update statistics jobstep (T-SQL) that is starting on both the Passive and the Active SQL Server instance.
The job updates several statistics on the same database, that is part of an Always On Availability group. I would expect this to fail on the secondary instance.
A quick rundown of the failover history:
Server A that should stay active due to licensing (will be named Active server), failed over unexpectedly to Server B (Passive Server). on 20/02 9PM.
After the unplanned failover, we did another (but this time planned) manual failover back to the Active server on 21/02 at 12PM.
Job history
Before the first failover all was good, and the active server is the only one running the job.
One job running.
We see the stat updates running on the Active side. (which is primary replica at the time)
During the short time that the passive server was the primary replica, we don't have any monitoring and the job history was cleared.
After the failover, back to the 'normal' state, after being on primary on the passive node for less than 24 hours, the jobstep on the passive instance has also been starting and running on the active instance.
(I killed the sessions).
Now the interesting part to me, is that both jobs are running on the active server, seeming like the job is using the listener to get to the database. But it could be an entirely different reason.
There is a copy job powershell task running nightly at 01 AM (dbatools):
powershell.exe Copy-DbaAgentJob -ExcludeJob "CopyJobs,CopyLogins" -Source INDCSPSQLA01 -Destination INDCSPSQLP01 -Force
My guess is now aimed at the one time, the job copy happened from the active, secondary node --> primary passive node with -Force. This happened at 21/02 01 AM.
The Question
Why is the jobstep on the passive instance executing on the active instance's Database?
Checklist
On both instances, the job target is local:
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
The servername is correct
select name from sys.servers
select @@SERVERNAME
both return the passive server.
The job id's of active and passive are different:
--08C63F07-0853-41DA-BC88-8FDF44AE491F -- passive
--E8C88965-C581-4E06-B651-CC10637FCEEF -- active
Both jobs use the database in question in their step:
@database_name=N'DB1',
--> Should not be accessible on the passive instance, resulting in failure.
No readable secondaries
The database is not accessible on the passive instance:
Version of both servers: 14.0.3030.27
T-SQL Job step command example
@subsystem=N'TSQL',
@command=N'update statistics dbo.table with fullscan ...'
Nothing is running on the passive instance when the job starts.
EDIT:
Restarting the agent on the passive node 'fixes' this, resulting in a new error on executing:
Unable to connect to SQL Server 'INDCSPSQLP01'. The step failed.
As a result, it no longer updates statistics on the primary instance
Hostnames = Passive & Active node, jobs where visibly running.
Application info
SQLAgent - TSQL JobStep (Job 0x9D358B2EF6C53C4BAD6A61CA87D51BF5 : Step 1)
SQLAgent - TSQL JobStep (Job 0x6589C8E881C5064EB651CC10637FCEEF : Step 1)
sql-server availability-groups sql-server-2017 jobs
sql-server availability-groups sql-server-2017 jobs
edited 40 secs ago
Randi Vertongen
asked 1 hour ago
Randi VertongenRandi Vertongen
2,956721
2,956721
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago
add a comment |
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
I don't have a diagnosis for why this problem occurred, but if you have jobs running on databases that are in availability groups, it's best to include a check in step 1 that uses the fn_hadr_is_primary_replica
function to check whether it is running on the primary or secondary.
IF (sys.fn_hadr_is_primary_replica('DB1') <> 1)
BEGIN
RAISERROR('%s is secondary', 11, 1, @@servername );
END
Configure this step to quit the job on failure. This is better than trying to run something that fails because it's hitting a secondary.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f230953%2fwhy-are-these-t-sql-jobs-from-different-sql-server-instances-executed-on-the-sam%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't have a diagnosis for why this problem occurred, but if you have jobs running on databases that are in availability groups, it's best to include a check in step 1 that uses the fn_hadr_is_primary_replica
function to check whether it is running on the primary or secondary.
IF (sys.fn_hadr_is_primary_replica('DB1') <> 1)
BEGIN
RAISERROR('%s is secondary', 11, 1, @@servername );
END
Configure this step to quit the job on failure. This is better than trying to run something that fails because it's hitting a secondary.
add a comment |
I don't have a diagnosis for why this problem occurred, but if you have jobs running on databases that are in availability groups, it's best to include a check in step 1 that uses the fn_hadr_is_primary_replica
function to check whether it is running on the primary or secondary.
IF (sys.fn_hadr_is_primary_replica('DB1') <> 1)
BEGIN
RAISERROR('%s is secondary', 11, 1, @@servername );
END
Configure this step to quit the job on failure. This is better than trying to run something that fails because it's hitting a secondary.
add a comment |
I don't have a diagnosis for why this problem occurred, but if you have jobs running on databases that are in availability groups, it's best to include a check in step 1 that uses the fn_hadr_is_primary_replica
function to check whether it is running on the primary or secondary.
IF (sys.fn_hadr_is_primary_replica('DB1') <> 1)
BEGIN
RAISERROR('%s is secondary', 11, 1, @@servername );
END
Configure this step to quit the job on failure. This is better than trying to run something that fails because it's hitting a secondary.
I don't have a diagnosis for why this problem occurred, but if you have jobs running on databases that are in availability groups, it's best to include a check in step 1 that uses the fn_hadr_is_primary_replica
function to check whether it is running on the primary or secondary.
IF (sys.fn_hadr_is_primary_replica('DB1') <> 1)
BEGIN
RAISERROR('%s is secondary', 11, 1, @@servername );
END
Configure this step to quit the job on failure. This is better than trying to run something that fails because it's hitting a secondary.
answered 37 mins ago
Tony HinkleTony Hinkle
2,7801523
2,7801523
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f230953%2fwhy-are-these-t-sql-jobs-from-different-sql-server-instances-executed-on-the-sam%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Correct me if I'm wrong, but are you saying the job that resides in the msdb database on the secondary is connecting to the availability group-enabled database on the primary?
– Max Vernon
1 hour ago