Skip to content

Commit

Permalink
Support for sesssion parameter with a new shared memory design
Browse files Browse the repository at this point in the history
  • Loading branch information
jayant07-yb committed Dec 7, 2022
1 parent c88368a commit ad9a388
Show file tree
Hide file tree
Showing 5 changed files with 435 additions and 23 deletions.
41 changes: 40 additions & 1 deletion src/postgres/src/backend/access/transam/xact.c
Original file line number Diff line number Diff line change
Expand Up @@ -3053,6 +3053,45 @@ void
CommitTransactionCommand(void)
{
TransactionState s = CurrentTransactionState;
/* Update the session parameter to the shared memory */
switch (s->blockState)
{
case TBLOCK_END: /* COMMIT received */
case TBLOCK_STARTED: /* running single-query transaction */
{
/* every query will be treated as a single transaction */
/* Copy the session parameter from the local memory to the shared memory */
ereport(WARNING,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("Updating the shared memory")));

YbUpdateSharedMemory();
YbCleanChangedSessionParameter();
}
break;
case TBLOCK_BEGIN:
{
ereport(WARNING,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("Reset the changed session parameters")));
YbCleanChangedSessionParameter();
break;
}
case TBLOCK_SUBBEGIN: /* starting a subtransaction */
case TBLOCK_SUBINPROGRESS: /* live subtransaction */
case TBLOCK_SUBRELEASE: /* RELEASE received */
case TBLOCK_SUBCOMMIT: /* COMMIT received while TBLOCK_SUBINPROGRESS */
case TBLOCK_SUBABORT: /* failed subxact, awaiting ROLLBACK */
case TBLOCK_SUBABORT_END: /* failed subxact, ROLLBACK received */
case TBLOCK_SUBABORT_PENDING: /* live subxact, ROLLBACK received */
case TBLOCK_SUBRESTART: /* live subxact, ROLLBACK TO received */
case TBLOCK_SUBABORT_RESTART: /* failed subxact, ROLLBACK TO received */
/* do nothing for sub transaction since */
break;
default:
/* do nothing */
break;
}

switch (s->blockState)
{
Expand Down Expand Up @@ -6214,4 +6253,4 @@ void YbClearCurrentTransactionId()
{
CurrentTransactionState->transactionId = InvalidTransactionId;
MyPgXact->xid = InvalidTransactionId;
}
}
15 changes: 3 additions & 12 deletions src/postgres/src/backend/postmaster/postmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <fcntl.h>
#include<sys/shm.h>
#include <sys/param.h>
#include <netdb.h>
#include <limits.h>
Expand Down Expand Up @@ -127,6 +128,8 @@
#include "utils/dynamic_loader.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/guc.h"
#include "utils/guc_tables.h"
#include "utils/ps_status.h"
#include "utils/timeout.h"
#include "utils/varlena.h"
Expand Down Expand Up @@ -2613,7 +2616,6 @@ ClosePostmasterPorts(bool am_syslogger)
#endif
}


/*
* reset_shared -- reset shared memory and semaphores
*/
Expand All @@ -2629,17 +2631,6 @@ reset_shared(int port)
* objects if the postmaster crashes and is restarted.
*/
CreateSharedMemoryAndSemaphores(port);

/*
* Create shared Memory for the `SESSION PARAMETERS`
* Each parameter will be having an array of struct `shared_parameter`
*
*/

/* todo-yb --> add the Isyugabytedb() function */
int shmid;
shmid=shmget((key_t)2345, 1024, 0666|IPC_CREAT); /* todo-yb --> Check whether it works without session paramerter */

}


Expand Down
Loading

0 comments on commit ad9a388

Please sign in to comment.