Phase 2b: 11개 모듈 전량 실동작 (333 서비스, 전서버 부팅)

- 10개 모듈 추가/확장(au py rc st lg cl mm vl mg cm), 각 30 서비스 = 330 + tmsrv
- build.sh 자동발견으로 11 모듈서버 + dbio 라이브러리 23 + 배치 22 빌드
- schema.d 11파일 → 75 테이블, 모듈별 disjoint
- 부팅 리소스 규명: fs.mqueue.queues_max=8192(330큐>256), NDRX_MSGSIZEMAX 16000·
  MSGMAX 50(큐당 5.6MB→0.8MB), msgqueue ulimit 2GB → 전 12서버 runok
- 검증: xadmin psc 333 AVAIL, 매입체인 XA 커밋, prepared_xacts=0

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
forge-bot 2026-07-19 09:58:39 +00:00
parent 8219b85f14
commit bec83c721e
73 changed files with 10705 additions and 35 deletions

View file

@ -0,0 +1,121 @@
/*
* au_auth_dbio.pgc - 승인(authorization)/부정거래 DB 접근 (libaudbio.a).
* ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
*/
#include <string.h>
#include <userlog.h>
#include "au_dbio.h"
long audb_next_auth_id(void)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT nextval('au_auth_seq') INTO :h_id;
if (sqlca.sqlcode < 0) {
userlog("audb_next_auth_id FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return h_id;
}
int audb_insert_auth(long auth_id, const char *card, const char *merch, long amount,
const char *appr_code, const char *auth_type, const char *status,
const char *bizdate)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id = auth_id, h_amount = amount;
char h_card[24], h_merch[64], h_appr[12], h_type[12], h_status[8], h_bizdate[16];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch)-1] = 0;
strncpy(h_appr, appr_code, sizeof(h_appr) - 1); h_appr[sizeof(h_appr)-1] = 0;
strncpy(h_type, auth_type, sizeof(h_type) - 1); h_type[sizeof(h_type)-1] = 0;
strncpy(h_status, status, sizeof(h_status) - 1); h_status[sizeof(h_status)-1] = 0;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); h_bizdate[sizeof(h_bizdate)-1] = 0;
EXEC SQL INSERT INTO au_authorization
(auth_id, card_no, merchant_id, amount, approval_code, auth_type, status, biz_date)
VALUES (:h_id, :h_card, :h_merch, :h_amount, :h_appr, :h_type, :h_status, :h_bizdate);
if (sqlca.sqlcode < 0) {
userlog("audb_insert_auth FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
int audb_update_auth_status(long auth_id, const char *status)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id = auth_id;
char h_status[8];
EXEC SQL END DECLARE SECTION;
strncpy(h_status, status, sizeof(h_status) - 1); h_status[sizeof(h_status)-1] = 0;
EXEC SQL UPDATE au_authorization SET status = :h_status, updated_at = now()
WHERE auth_id = :h_id;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_update_auth_status FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
int audb_get_auth_status(long auth_id, char *out)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id = auth_id;
char h_status[8];
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT status INTO :h_status FROM au_authorization WHERE auth_id = :h_id;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_get_auth_status FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
out[0] = h_status[0];
out[1] = 0;
return 0;
}
int audb_update_auth_amount(long auth_id, long amount)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id = auth_id, h_amount = amount;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE au_authorization SET amount = :h_amount, updated_at = now()
WHERE auth_id = :h_id;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_update_auth_amount FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
long audb_insert_fraud(long auth_id, const char *card, long score, const char *reason,
const char *bizdate)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_id, h_auth = auth_id, h_score = score;
char h_card[24], h_reason[128], h_bizdate[16];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
strncpy(h_reason, reason, sizeof(h_reason) - 1); h_reason[sizeof(h_reason)-1] = 0;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); h_bizdate[sizeof(h_bizdate)-1] = 0;
EXEC SQL SELECT nextval('au_fraud_seq') INTO :h_id;
if (sqlca.sqlcode < 0) return -1;
EXEC SQL INSERT INTO au_fraud_log (fraud_id, auth_id, card_no, score, reason, biz_date)
VALUES (:h_id, :h_auth, :h_card, :h_score, :h_reason, :h_bizdate);
if (sqlca.sqlcode < 0) {
userlog("audb_insert_fraud FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return h_id;
}

32
app/src/au/dbio/au_dbio.h Normal file
View file

@ -0,0 +1,32 @@
/*
* au_dbio.h - au (/) DB (libaudbio.a).
* ECPG (EXEC SQL) functions compiled into a static library and linked into
* au_svr and the au batches. They run on the caller's XA branch/connection
* (no EXEC SQL CONNECT); sqlca is the shared per-thread ECPG SQLCA.
* Return convention: 0 = ok, -1 = SQL error (caller may also inspect sqlca).
*/
#ifndef AU_DBIO_H
#define AU_DBIO_H
/* authorization */
long audb_next_auth_id(void);
int audb_insert_auth(long auth_id, const char *card, const char *merch, long amount,
const char *appr_code, const char *auth_type, const char *status,
const char *bizdate);
int audb_update_auth_status(long auth_id, const char *status);
int audb_get_auth_status(long auth_id, char *out /* >= 2 bytes */);
int audb_update_auth_amount(long auth_id, long amount);
/* fraud */
long audb_insert_fraud(long auth_id, const char *card, long score, const char *reason,
const char *bizdate);
/* card limit */
int audb_limit_get(const char *card, long *limit_out, long *used_out);
int audb_limit_dec(const char *card, long amount);
int audb_limit_reset(const char *card);
int audb_limit_set(const char *card, long limit);
int audb_upsert_auth_summary(const char *merch, const char *bizdate, long cnt,
long approved, long declined, long amount);
#endif /* AU_DBIO_H */

View file

@ -0,0 +1,108 @@
/*
* au_limit_dbio.pgc - 카드 한도(card_limit) + 승인 일집계 DB 접근 (libaudbio.a).
*/
#include <string.h>
#include <userlog.h>
#include "au_dbio.h"
int audb_limit_get(const char *card, long *limit_out, long *used_out)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_limit, h_used;
char h_card[24];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
EXEC SQL SELECT daily_limit, used_amount INTO :h_limit, :h_used
FROM card_limit WHERE card_no = :h_card;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_limit_get FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
*limit_out = h_limit;
*used_out = h_used;
return 0;
}
int audb_limit_dec(const char *card, long amount)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_amount = amount;
char h_card[24];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
EXEC SQL UPDATE card_limit SET used_amount = used_amount + :h_amount, updated_at = now()
WHERE card_no = :h_card;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_limit_dec FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
int audb_limit_reset(const char *card)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_card[24];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
EXEC SQL UPDATE card_limit SET used_amount = 0, updated_at = now()
WHERE card_no = :h_card;
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
userlog("audb_limit_reset FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
int audb_limit_set(const char *card, long limit)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_limit = limit;
char h_card[24];
EXEC SQL END DECLARE SECTION;
strncpy(h_card, card, sizeof(h_card) - 1); h_card[sizeof(h_card)-1] = 0;
EXEC SQL INSERT INTO card_limit (card_no, daily_limit, used_amount)
VALUES (:h_card, :h_limit, 0)
ON CONFLICT (card_no) DO UPDATE
SET daily_limit = EXCLUDED.daily_limit, updated_at = now();
if (sqlca.sqlcode < 0) {
userlog("audb_limit_set FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}
int audb_upsert_auth_summary(const char *merch, const char *bizdate, long cnt,
long approved, long declined, long amount)
{
EXEC SQL BEGIN DECLARE SECTION;
long h_cnt = cnt, h_appr = approved, h_dec = declined, h_amt = amount;
char h_merch[64], h_bizdate[16];
EXEC SQL END DECLARE SECTION;
strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch)-1] = 0;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); h_bizdate[sizeof(h_bizdate)-1] = 0;
EXEC SQL INSERT INTO au_summary
(merchant_id, biz_date, auth_count, approve_count, decline_count, auth_amount)
VALUES (:h_merch, :h_bizdate, :h_cnt, :h_appr, :h_dec, :h_amt)
ON CONFLICT (merchant_id, biz_date) DO UPDATE
SET auth_count = au_summary.auth_count + EXCLUDED.auth_count,
approve_count = au_summary.approve_count + EXCLUDED.approve_count,
decline_count = au_summary.decline_count + EXCLUDED.decline_count,
auth_amount = au_summary.auth_amount + EXCLUDED.auth_amount,
updated_at = now();
if (sqlca.sqlcode < 0) {
userlog("audb_upsert_auth_summary FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}
return 0;
}