5 Replies Latest reply: Mar 9, 2013 10:45 PM by FabioDouek RSS

    How to create a stuck thread?

    karthiksingh_dba
      Dear Legends,

      Kindly please help me in creating a stuck thread manually using Database side or Application side.

      This is to check my script whether it is detecting stuck thread if i would run in a cron, so that it would fire an alert via email whenever there is a stuck thread detected.

      Any kind of help would be appreciated much. Thanks in advance.

      Regards,
      Karthik
        • 1. Re: How to create a stuck thread?
          FabioDouek
          Just add Thread.sleep(2000000) to your java code. It wouldn't need all this time (this is in ms). You should see a stuck thread after 10 mins.

          Regards,
          Fabio Douek
          • 2. Re: How to create a stuck thread?
            karthiksingh_dba
            Hi,
            Thanks for helping me.
            Just add Thread.sleep(2000000) to your java code. It wouldn't need all this time (this is in ms). You should see a stuck thread after 10 mins.
            I'm a beginner DBA, also am only little aware of writing java code. In which type of file i have to write this code.

            Is there a way to write or change the DB by doing any insert or update, so that we can create a stuck thread. I'm googling it but i can't able to reach it.

            Regards,
            Karthik
            • 3. Re: How to create a stuck thread?
              FabioDouek
              Hi Karthik,

              There are lots of ways to achieve this by instrumentation in the different layers.

              The one I sent to you previously is the simplest. You can create a servlet, add the Thread.sleep, deploy and the job is done.

              As you are a DBA, you should be familiar with stored procedures and this might be easier for you.
              In order to keep it simple, so you can achieve your goal, you can introduce the delay in a stored procedure and invoke it from Weblogic.

              In the stored procedure, you can add the following to introduce the sleep (this is a 20 minutes sleep): DBMS_LOCK.sleep(1200);

              Regards,
              Fabio Douek.

              Edited by: Fabio Douek on Mar 10, 2013 4:27 AM
              • 4. Re: How to create a stuck thread?
                karthiksingh_dba
                Hi Fabio,
                Thanks for your valuable suggestion.
                The one I sent to you previously is the simplest. You can create a servlet, add the Thread.sleep, deploy and the job is done.
                creating a servlet means is it so I have to write a code in web.xml or .jsp. Is my understanding correct?
                As you are a DBA, you should be familiar with stored procedures and this might be easier for you.
                In order to keep it simple, so you can achieve your goal, you can introduce the delay in a stored procedure and invoke it from Weblogic.

                In the stored procedure, you can add the following to introduce the sleep (this is a 20 minutes sleep): DBMS_LOCK.sleep(1200);
                Let me try this store procedure and inform you. How do i invoke this from Weblogic?

                Regards,
                Karthik
                • 5. Re: How to create a stuck thread?
                  FabioDouek
                  Hi Karthik,

                  Yes, you can write a .jsp instead of a servlet. The servlet will be generated transparently. You wii have to generate a WAR file and deploy it in weblogic.

                  If you want to invoke the stored procedure, it will depend on which API you are using. I thought you have Java developers to look after this for you.

                  Regards,
                  Fabio Douek