There are few shell scripts that use the isql to execute some sql statements on a Sybase database server. I see several Log Suspend messages in the logs and the problem is that the shell script exits with success.
The transaction log in database MAIN_DB is almost full. Your transaction is being suspended until space is made available in the log.
I need to intercept these Log suspend messages and report the correct error. How do I do this? I am not sure about how to proceed here. When it occurs there is no way it gets cleared and the database administrator has to kill the spid after a some time, but the script already exits with success. So, the data-transfer didn't actually happen and was aborted. This is the scenario I need to handle.
Please let me know how we would be able to intercept the Log Suspend and atleast wait for a particular time ?
You have two issues. One is the script does not detect errors correctly. Secondly the transaction log is filling up frequently.
First the script needs to have the standard output AND the error output go to your log file. When you use the > it is using file descriptor 1. When you want to capture error output you need to use 2> for file descriptor 2. So the command would look like the following.
isql > error.log 2> error.log
Better yet use this
isql 2>&1 > error.log
The previous says to have file descriptor 2 go to file descriptor 1.
Now to detect errors look for "Msg" which all errors have in front.
Secondly to resolve the transaction log space, you need to grow the log size which should be on its own device. Then you need to set the threshold to dump the completed transactions to a disk file automatically. You need to investigate the following commands.
sp_helpthreshold
sp_addthreshold
sp_thresholdaction
Good SQL, good night.
You can check the processes inside the databases, and look for a process status of 'LOG SUSPEND'. Specifiying the username is optional.
sp_who {USERNAME}
Related
I have setup PuTTY/Plink to connect to a remote server for loading data from the remote SQL server.
I can easily call the saved session by using the following:
c:\plink -l myusername savedsite
I can then run a SQL Server job that loads the data.
The issue I have is, that this SQL Server job is a scheduled job that runs every x minutes.
What I notice is that running the Plink command keeps the command window open. So on the subsequent run of the job, another command window opens.
What I want to do is to issue an exit/logout command to the Plink window when the task of loading the data is complete. How do I achiever this please?
OK, it does not looks like you will provide us enough information, so that we can give you a good answer.
So only briefly: Plink won't close for you. It cannot know when you are done.
You have to close it on your own. E.g. by:
Starting it with a redirected input and writing exit/logout to it; or
Remembering its process ID and killing it.
We cannot show you how, as we do not know anything about the way you run it and options your environment allow.
Could not execute statement.
Can't open a connection to site 'SYB_BACKUP'. See the error log file in
the ASE boot directory.
Sybase error code=7205
Severity Level=17, State=2, Transaction State=1
Line 1
enter image description here
The (SAP/Sybase) backupserver is a separate OS process running on the same host as the ASE/dataserver process, so there are a few things you can check:
Have you been able to successfully run dump and/or load commands previously against this dataserver, or is this the first time you've attempted a load command? [If the former then this is likely an issue of the backupserver process not running; if the latter then this may be an issue with an incomplete/incorrect installation of the product.]
Is the backupserver process running on the host where the ASE process is running? [For Windows environments this is usually configured as a service.]
Has the dataserver's SYB_BACKUP (logical) server been configured to reference the correct backusperver name? [Run sp_helpserver SYB_BACKUP and make note of the name under network_name; is this the name of the backupserver?]
Make sure the backupserver is defined in the dataserver's interfaces/sql.ini file. [Is the backupserver - displayed under sp_helpserver/network_name - listed in the sql.ini file?]
Huh. Being new I can't add a comment, so I'm putting it here. What command are you executing?
I have a psftp script to get files from a server every hour. The script works good when I manually run the bat file from its location and also runs well from the SQL Server Agent when I am logged in/monitoring it.
However, when am not logged in, the script hangs and continues to run forever, creating an empty log file.
Since this is an hourly run, this blocks out all subsequent runs as well creating delays in data load.
Could anyone advice what could possibly be causing this rather bizarre issue.
The log files created for each run are independent, with time stamp - so its not a lock out of log files causing the hanging.
Even though there is a prompt , a prompt file is supplied with value Y in it , that allows it to run without any requirement for explicitly entering a prompt value.
The script has been scanned for any pauses and other timeouts (Is not applicable really , since it works seamlessly when am logged in)
I tried setting set --trust-model=always, script still hangs when I am not logged in.
This said, I am not really sure if it has anything to do with me being logged in or if its just a coincidence. But basically, I am never able to catch the issue happening while am monitoring it!
This is probably a permission issue. Firstly check what user will be running the slq agent job when you are not logged in. Then ensure this user has full permissions/admin rights.
I think you might need admin to shell out - which I presume you are doing to run psftp.
I have a shared accde file on a network drive. Occasionally we will have an inconsistent state problem. The error message appears below. It seems to be associated with network connection interruptions for even one user. We have an example when a user unplugged the Ethernet and switched automatically to wireless and other examples where users have left the database open overnight, perhaps when a machine hibernates.
Once this happens the one user cannot work and no one can open the accde file. Other users who have the database open can continue to work.
After the problem occurs it remains until everyone closes the database. At that time it completes whatever recovery it requires and all users can get back in.
This was disruptive when we had six users in one room. Now we have 17 in two cities and a few work-from-home users. It's becoming intolerable.
The obvious answer is to move away from Access. We're working on it but it's a long way off. In the mean time I would appreciate any advice.
Is there a way to prevent the problem entirely?
Is there a VBA way to detect the problem in the instances that are not showing the error message?
Is there something I'm not thinking of?
What would you do?
Error message:
Microsoft Access has detected that this database is in an inconsistent state, and will attempt to recover the database. During this process, a backup copy of the database will be made and all recovered objects will be placed in a new database. Access with then open the new database. The names of objects that were not successfully recovered will be logged in the "Recovery Error" table.
The solution that Microsoft gives is Splitting the database, which just means to put the data elements on a shared server, and everyone has their own copy of the front end.
This might cause problems if that front end needs to be updated (e.g. additional forms). Details here:
http://answers.microsoft.com/en-us/office/forum/office_2007-access/microsoft-office-has-detected-that-this-database/3fb41c70-f7ba-41dd-a847-e62203071466?auth=1
Check the row count in the tables, the tables most likely have large amounts of data creating latency on the read and write queries, causing the locking.
Archive older data and keep the database small and neat, perhaps create referenced databases for archived information
I gather that your MS Access database is getting corrupt when up put it on a shared drive. A Microsoft Access database may get corrupt when in a multi- user environment. Here are the workaround that you can use in order to fix it.
Step 1: Run Command Prompt as Administrator
Click on the Windows icon and type Command Prompt. Then right-click on the Command Prompt and choose Run as administrator option.
Step 2: Execute Compact and Repair Database Command
In the command prompt window, type the following command and then press ‘Enter’.
msaccess <database file name> /compact
In the command, replace <database filename> with database path. For instance,
msaccess "C:\Program Files\Reports.mdb" /compact
This will start the process to compact and repair the faulty Access database file.
Otherwise, You can check out this thread for an alternative solution : https://dba.stackexchange.com/questions/71906/ms-access-mdb-ldb-database-corrupted/171275#171275
Is there a way to have a batch file determine the IP/Name of the server from which it is being triggered (i.e. when it's executed on a separate server to the one triggering the execution)?
My initial thought is to add the line netstat -a >> WhoDunnit.txt so that I can see all connections moments after the script's called, then trawl through that hoping the connection was still open; but asking here in case there's a more sophisticated solution?
Background
We recently found a deployment script was being run at 2am each week, with no one having any knowledge of why.
The script's commands mean it will only affect the server on which it's running, so it must be executing locally.
The script's host server has nothing defined in its scheduled tasks / we can't see anything on this machine that would trigger this script.
So the script must be being called from some other server on which the schedule's defined, but in such a way that it executes on the host server rather than on the triggering server.
If I can find which server's calling the script I can find the schedule and disable it.
Batch file with below in it.
echo %~dpnx0
When started by
C:\Users\User>"\\127.0.0.1\C$\users\user\cmdline.bat"
returns
C:\Users\User>echo \\127.0.0.1\C$\Users\User\cmdline.bat
\\127.0.0.1\C$\Users\User\cmdline.bat
Now I would turn process auditing on and wait for it to start.