{"id":263,"date":"2016-01-07T22:46:14","date_gmt":"2016-01-07T22:46:14","guid":{"rendered":"http:\/\/nenadnoveljic.com\/blog\/?p=263"},"modified":"2016-02-02T20:56:36","modified_gmt":"2016-02-02T20:56:36","slug":"avaloq-database-crash","status":"publish","type":"post","link":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/","title":{"rendered":"Avaloq Database Crash"},"content":{"rendered":"<p>Our site suffered the crash of an Avaloq test database. The following information was found in the alert log:<\/p>\n<pre><code>PMON (ospid: 1112): terminating the instance due to error 471\r\nTIMESTAMP\r\nSystem state dump requested by (instance=1, osid=1112 (PMON)), summary=[abnormal instance termination].\r\nSystem State dumped to trace file \/u00\/oracle\/orabase\/diag\/rdbms\/XXX\/trace\/XXX_diag_1221_20151231063902.trc\r\nDumping diagnostic data in directory=[cdmp_20151231063902], requested by (instance=1, osid=1112 (PMON)), summary=[abnormal instance termination].\r\nInstance terminated by PMON, pid = 1112<\/code><\/pre>\n<p>I looked into the pmon trace XXX_pmon_1112.trc and found out that the PMON terminated the instance because the database writer process DBW2 was not running any more:<\/p>\n<pre><code>Background process DBW2 found dead\r\nOracle pid = 12\r\nOS pid (from detached process) = 1234\r\nOS pid (from process state) = 1234\r\n<\/code><\/pre>\n<p>Note here the OS pid of the DBW process &#8211; 1234. This is an important clue for later.<\/p>\n<p>There weren&#8217;t any trace files left by the process 1234, so I assumed that the sudden death was due to some external impact. To find out the cause I used the <a href=\"http:\/\/www.brendangregg.com\/DTrace\/kill.d\">kill.d<\/a> dtrace script by <a href=\"http:\/\/www.brendangregg.com\/\">Gregg Brendan<\/a>. The culprit was indeed revealed next day when I harvested the kill.d results :<\/p>\n<pre><code>...\r\n26804   aaafile.sh     9 1234   -1\r\n27913   aaafile.sh     9 1234   -1\r\n28988   aaafile.sh     9 1234   -1\r\n28509   aaafile.sh     9 1234   -1\r\n27393   aaafile.sh     9 1234   -1\r\n29964   aaafile.sh     9 1234   -1\r\n...\r\n<\/code><\/pre>\n<p>The avaloq program aaafile.sh was killing the 1234 process. In this case, the victim happened to be a database writer.<\/p>\n<p>But why would Avaloq do this?<\/p>\n<p>To answer this question I correlated the information in alert log with the Avaloq aaafile log files.<\/p>\n<pre><code>Thu Jan 07 15:19:58 2016\r\nALTER SYSTEM enable restricted session;\r\nImmediate Kill Session#: 811, Serial#: 3\r\nImmediate Kill Session: sess: 316711c00  OS pid: 12280\r\nImmediate Kill Session#: 1084, Serial#: 77\r\nImmediate Kill Session: sess: 314742c68  OS pid: 11927\r\nImmediate Kill Session#: 1142, Serial#: 1179\r\nImmediate Kill Session: sess: 3167a1f68  OS pid: 12020\r\nThu Jan 07 15:20:01 2016\r\nopiodr aborting process unknown ospid (12068) as a result of ORA-28\r\nThu Jan 07 15:20:22 2016\r\nopidrv aborting process J099 ospid (28486) as a result of ORA-28\r\nThu Jan 07 15:23:30 2016\r\nCompleted checkpoint up to RBA [0xd.2.10], SCN: 85281115086\r\n<\/code><\/pre>\n<pre><code>aaafile log:\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: PARAMS: CMD = kill, FILE = 1234\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: Processing Command: kill process (1234)\r\nkill: 1234: no such process\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: PARAMS: CMD = kill, FILE = 12112\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: Processing Command: kill process (12112)\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: PARAMS: CMD = kill, FILE = 1234\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: Processing Command: kill process (1234)\r\nkill: 1234: no such process\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: PARAMS: CMD = kill, FILE = 28486\r\n...\r\nsvavr02a:2016-01-07_15-20:\"\":INFO: Processing Command: kill process (28486)\r\n<\/code><\/pre>\n<p>From the information above the following can be deduced:<br \/>\n&#8211; the session and os kills were caused by setting the session level 0 (session level 0 is the application shutdown in Avaloq)<br \/>\n&#8211; every database session kill was followed by the kill -9 of the corresponding shadow process<br \/>\n&#8211; there were a lot of kill -9 1234 for no obvious reason<\/p>\n<p>To find out where the kill -9 1234 was coming from, I traced the session which sets the session level to zero and found the following query on the v$process view:<\/p>\n<pre><code>      SELECT P.SPID\r\n            ,S.PROCESS\r\n            ,S.MACHINE\r\n            ,S.PROGRAM\r\n      FROM   V$SESSION  S\r\n            ,V$PROCESS  P\r\n      WHERE  S.SID      = :b0\r\n        AND  S.SERIAL#  = :b1\r\n        AND  P.ADDR (+) = S.PADDR;\r\n<\/code><\/pre>\n<p>This query was executed after almost every alter system disconnect session immediate.<\/p>\n<p>Therefore, I concluded that Avaloq is quering the v$process.spid to find out the OS PID. However, as kill oracle session and kill -9 ar not atomic operations it can happen that the shadow process already disappears when by the time the query gets executed returning NULL for SPID.<\/p>\n<p>Since Avaloq selects v$session.process in the same query I assumed that this value is used as a fallback if SPID is NULL. In the <a href=\"http:\/\/docs.oracle.com\/cd\/E11882_01\/server.112\/e40402\/dynviews_3016.htm#REFRN30223\">Oracle Documentation<\/a> the column process is described as: &#8220;Operating system client process ID&#8221;. However, when I selected process from v$session I was suprised to see that for all the JDBC processes the value was set to 1234. The Metalink note &#8220;How to Set V$SESSION Properties Using the JDBC Thin Driver (Doc ID 147413.1)&#8221; explains that this is the expected behaviour. Hence, Avaloq will kill any process with this PID, if there are JDBC sessions coming from the database server itself. Avaloq doesn&#8217;t try to kill all the sessions, but just the ones from the users which are registered in the table SEC_USER. In our case it was the messaging agent which was logged in as user I. In particular, below is the query found in the trace files which selects the sessions for killing:<\/p>\n<pre><code>SELECT SID     SID\r\n,SERIAL# SERIAL\r\nFROM   GV$SESSION\r\nWHERE  AUDSID   &gt; 0\r\nAND  AUDSID  != USERENV('sessionid')\r\nAND  TYPE     = 'USER'\r\nAND ',' || :b0 || ',' NOT LIKE '%,' || USERNAME || ',%'\r\nAND  USERNAME IN (\r\nSELECT ORACLE_USER\r\nFROM   SEC_USER\r\nWHERE  ORACLE_USER NOT IN ('SYS', 'K', 'K_READ')\r\n)\r\nAND  NVL(CLIENT_INFO,' ') NOT LIKE 'BGP_OS.%'\r\nAND  PROGRAM  NOT LIKE 'amqzlaa%';\r\n<\/code><\/pre>\n<p>As a workaround, make sure that you close the JDBC connections of the users in K.SEC_USER &#8211; except for K, K_READ and SYS &#8211; coming from the database server prior to setting session level to zero.<\/p>\n<p><strong>Update 02\/02\/2016<\/strong>: Avaloq released the patch #1695233 in the release 3.9.1.5.0. The patch recreates the procedure k.kill_session. The patch is successfully tested in my envoironment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting session level to zero can crash the database if there are local JDBC connections from the application users (i.e. users that are registered in K.SEC_USER and at the same time a core database background process is running under the PID 1234. <a href=\"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[13,5],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-avaloq","category-oracle"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Avaloq Database Crash<\/title>\n<meta name=\"description\" content=\"Setting session level to zero can crash the database if there are local JDBC connections from the application users.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Avaloq Database Crash\" \/>\n<meta property=\"og:description\" content=\"Setting session level to zero can crash the database if there are local JDBC connections from the application users.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/\" \/>\n<meta property=\"og:site_name\" content=\"All-round Database Topics\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-07T22:46:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-02-02T20:56:36+00:00\" \/>\n<meta name=\"author\" content=\"Nenad Noveljic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NenadNoveljic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nenad Noveljic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/\"},\"author\":{\"name\":\"Nenad Noveljic\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"headline\":\"Avaloq Database Crash\",\"datePublished\":\"2016-01-07T22:46:14+00:00\",\"dateModified\":\"2016-02-02T20:56:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/\"},\"wordCount\":539,\"commentCount\":1,\"articleSection\":[\"Avaloq\",\"Oracle\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/\",\"name\":\"Avaloq Database Crash\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\"},\"datePublished\":\"2016-01-07T22:46:14+00:00\",\"dateModified\":\"2016-02-02T20:56:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"description\":\"Setting session level to zero can crash the database if there are local JDBC connections from the application users.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/avaloq-database-crash\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Avaloq Database Crash\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\",\"name\":\"All-round Database Topics\",\"description\":\"Nenad Noveljic\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\",\"name\":\"Nenad Noveljic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"caption\":\"Nenad Noveljic\"},\"sameAs\":[\"nenad-noveljic-9b746a6\",\"https:\\\/\\\/x.com\\\/NenadNoveljic\"],\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/author\\\/nenad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Avaloq Database Crash","description":"Setting session level to zero can crash the database if there are local JDBC connections from the application users.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/","og_locale":"en_US","og_type":"article","og_title":"Avaloq Database Crash","og_description":"Setting session level to zero can crash the database if there are local JDBC connections from the application users.","og_url":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/","og_site_name":"All-round Database Topics","article_published_time":"2016-01-07T22:46:14+00:00","article_modified_time":"2016-02-02T20:56:36+00:00","author":"Nenad Noveljic","twitter_card":"summary_large_image","twitter_creator":"@NenadNoveljic","twitter_misc":{"Written by":"Nenad Noveljic","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/#article","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/"},"author":{"name":"Nenad Noveljic","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"headline":"Avaloq Database Crash","datePublished":"2016-01-07T22:46:14+00:00","dateModified":"2016-02-02T20:56:36+00:00","mainEntityOfPage":{"@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/"},"wordCount":539,"commentCount":1,"articleSection":["Avaloq","Oracle"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/","url":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/","name":"Avaloq Database Crash","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#website"},"datePublished":"2016-01-07T22:46:14+00:00","dateModified":"2016-02-02T20:56:36+00:00","author":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"description":"Setting session level to zero can crash the database if there are local JDBC connections from the application users.","breadcrumb":{"@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nenadnoveljic.com\/blog\/avaloq-database-crash\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nenadnoveljic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Avaloq Database Crash"}]},{"@type":"WebSite","@id":"https:\/\/nenadnoveljic.com\/blog\/#website","url":"https:\/\/nenadnoveljic.com\/blog\/","name":"All-round Database Topics","description":"Nenad Noveljic","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nenadnoveljic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa","name":"Nenad Noveljic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","caption":"Nenad Noveljic"},"sameAs":["nenad-noveljic-9b746a6","https:\/\/x.com\/NenadNoveljic"],"url":"https:\/\/nenadnoveljic.com\/blog\/author\/nenad\/"}]}},"_links":{"self":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":2,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":532,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions\/532"}],"wp:attachment":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}