process/session/connection的一些問題
記得在一個群裡曾經討論過一個問題:是先有session還是先有connection呢?當時也沒有定論。回答問題的要點在於:什麼是session,什麼是connection,兩者的存在是以什麼為標識的,兩者直接有怎樣的依存關係。
首先看下三者的概念。以下所有概念來源於11gconcept。
Process
[php]
All connected Oracle Database users must run two modules of code to access an Oracle Database instance.
Application or Oracle tool: A database user runs a database application (such as a precompiler program) or an Oracle tool (such as SQL*Plus), which issues SQL statements to an Oracle database.
Oracle database server code: Each user has some Oracle database code executing on his or her behalf, which interprets and processes the application's SQL statements.
These code modules are run by processes. A process is a "thread of control" or a mechanism in an operating system that can run a series of steps. (Some operating systems use the terms job or task.) A process normally has its own private memory area in which it runs.
The processes in an Oracle Database system can be categorized into two major groups:
User processes run the application or Oracle tool code.
Oracle Database processes run the Oracle database server code. They include server processes and background processes.[/php]
process其實就是程式程式碼的執行時版。可以按照作者意圖去自動執行特定的任務。Oracle安裝process所執行任務的來源分為user process和server process.
[php]
Connections and Sessions
Connection and session are closely related to user process but are very different in meaning.
A connection is a communication pathway between a user process and an Oracle Database instance. A communication pathway is established using available interprocess communication mechanisms (on a computer that runs both the user process and Oracle Database) or network software (when different computers run the database application and Oracle Database, and communicate through a network).
A session is a specific connection of a user to an Oracle Database instance through a user process. For example, when a user starts SQL*Plus, the user must provide a valid user name and password, and then a session is established for that user. A session lasts from the time the user connects until the time the user disconnects or exits the database application.
Multiple sessions can be created and exist concurrently for a single Oracle Database user using the same user name. For example, a user with the user name/password of SCOTT/TIGER can connect to the same Oracle Database instance several times.
In configurations without the shared server, Oracle Database creates a server process on behalf of each user session. However, with the shared server, many user sessions can share a single server process.
[/php]
connection其實就是通訊鏈路,對oracle講就是user process和instance間的通訊鏈路,可以使用IPC或者TCP之類的網路機制。
session則是一個資料庫使用者在user process和instance之間所建立的一個具體連結.session存在的前提是建立了連線。建立了連結的同時,session已經存在了。當user資訊錯誤時,user process向instance傳送連結請求,instance驗證user資訊,發現user資訊錯誤,返回錯誤資訊。這個過程只是兩者的通訊,試圖建鏈,還根本沒建立成功,這時候既不存在connection也不存在session。從網路模型上理解二者之間的關係,應該會比較容易點。似乎建立了連結的同時,session也跟著出現了。
舉個例子,打電話。但我們想和對方通話的時候,我們首先要撥號,當對方按下接聽鍵時,雙方直接就建立一條通訊鏈路,這時雙方就可以談話了,session其實就是指從會話準備就緒開始到會話結束,會話結束了就要斷開鏈路。
session可以有active和inactive的狀態,當按下接聽鍵時,鏈路建立了,當我們說hello時,會話開始了,當我們交談時是active的,當我們沉默時是inactive的,當我們說bye的時候,會話結束了,當我們掛機的時候,鏈路斷了。
所以到底是現有session還是先有connection的問題也就清楚了,其實他們是同時的,只是對同一事件同一現象同一事務在不同層次上的描述,從底層通訊看,是叫connection,從上層user process和instance看,是兩者的session已經開始了。當我們敲exit時,會話中斷,底層拆鏈。
如果非要分個先後的話,那session是要放在connection之間的。
至於server process和要討論的問題沒什麼關係。
以上只是一些原理上的猜測,還是有兩個不確定點的,一是connection和session建立的標準是什麼,這個是至關重要的,二是oracle處理的二者的方法是什麼。事實上oracle建立connection後是要去建立session資訊,也就是say hello to user process,所以session建立似乎是要在connection後的。
以上只是我的一些猜想,歡迎大家拍磚。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7591490/viewspace-1008809/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- connection session process的聯絡與區別Session
- A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processesMITSession
- process和session的總結Session
- session,connect,processSession
- ORACLE SESSION 和 PROCESSOracleSession
- 關於v$process與v$session中process的理解Session
- session的存取問題Session
- oracle session和process的關係OracleSession
- connection和session的關係Session
- oracle中session跟process的研究OracleSession
- Connection/Session/Server ProcessesSessionServer
- 修改Oracle process 和 session 的方法--摘OracleSession
- hibernate的session.connection被session.dowork()替代Session
- 關於session的問題Session
- Hibernate的session問題Session
- Session的過期問題Session
- session共享問題???Session
- v$session.PROCESS/V$process.SPID含義Session
- 11G DRCP(Database Resident Connection Pooling)的一些問題DatabaseIDE
- 關於突破 SESSION 0 隔離場景發現的一些問題Session
- hibernate中的no session問題Session
- Session互不干擾的問題。Session
- Struts Tiles 和 session的問題Session
- 關於session的奇怪問題Session
- php關於session的問題PHPSession
- PHP的session,session檔案,及其過期的問題PHPSession
- 【process】一些常見file和process的作用總結
- Oracle中的Connect、session、process的區別OracleSession
- 在Oracle中session和process的區別(轉)OracleSession
- oracle session和process的關係 .轉自CSDNOracleSession
- 關於session leak的問題分析Session
- [Shell] Linux monitor OS process and DB sessionLinuxSession
- 關於session的銷燬的問題Session
- Web--Session共享問題WebSession
- Tomcat 共享session問題TomcatSession
- 1 Million TCP Connection 問題解決TCP
- Xlib: connection to ":0.0" refused by server 問題Server
- Hibernate中的Session快取問題Session快取