Skip to content

[CBRD-26463] [POC] support replication for OOS#6813

Merged
H2SU merged 37 commits intoCUBRID:feat/oosfrom
H2SU:feat/oos_repl
Feb 13, 2026
Merged

[CBRD-26463] [POC] support replication for OOS#6813
H2SU merged 37 commits intoCUBRID:feat/oosfrom
H2SU:feat/oos_repl

Conversation

@H2SU
Copy link
Contributor

@H2SU H2SU commented Jan 29, 2026

http://jira.cubrid.org/browse/CBRD-26463

Purpose

  • OOS 형식으로 저장되는 레코드에 대해 replication을 지원하기 위해 POC 수준으로 코드를 작성하여 구현

Implementation

  • Master에서 OOS record insert 후 oos log를 생성 할 때 추후 heap record에 대한 replication log를 생성하기 전 oos record에 대한 replication log를 생성하기 위해 oos log에 대한 LSA를 tdes에 저장
  • Master에서 OOS record insert 시 생성된 oos_oid를 thread_p의 vector oos_oids에 담아두었다가 추후 replication log 생성 시 해당 oid들을 활용하여 repl log를 생성
  • Slave에서 OOS record를 insert 후 생성되는 OID를 thread_p의 vector에 담아두었다가 heap record가 insert 될 때 recdes에서 oid 값 치환하는 작업 추가
  • OOS Replication 지원

Remarks

  • 현재 POC 수준으로 OID 치환 방식이 동작함만을 검증한 코드입니다.
  • 관련 함수
    • locator_fixup_oos_oids_in_recdes
      • recdes의 oos oid를 vector에 넣어놨던 oid로 치환하는 함수
    • heap_recdes_contains_oos
      • heap recdes header를 보고 oos 컬럼을 포함하고 있는지 확인하는 함수

OOS INSERT 시 로직

  1. init oos tracking info
    • tdes->oos_insert_lsa_queue.clear ();
    • thread_p->oos_oids.clear ();
  2. oos insert
  3. oos insert logging
    • oos_log_insert_physical (thread_p, page_ptr, const_cast<VFID *> (&oos_vfid), &oid, &oos_rec);
  4. tdes->oos_insert_lsa_queue에 oos_lsa 추가
    • tdes->oos_insert_lsa_queue.push (tdes->tail_lsa);
  5. thread_p->oos_oids에 insert된 oos_oid들 추가
    • thread_p->oos_oids.push_back (oos_oid);
  6. oos insert replication log 추가 (heap record가 replication 대상일 경우에만 수행)
    if (heap_recdes_contains_oos (recdes))
      {
        // insert oos replication log
        for (int i = 0; i < (int) thread_p->oos_oids.size (); i++)
          {
            error_code = repl_log_insert (thread_p,
                                          class_oid,
                                          &thread_p->oos_oids[i],
                                          LOG_REPLICATION_DATA,
                                          RVREPL_OOS_INSERT, key_dbvalue, REPL_INFO_TYPE_RBR_NORMAL);
          }
      }
  7. heap insert replication log 추가

@H2SU H2SU self-assigned this Jan 29, 2026
@H2SU H2SU requested a review from hornetmj as a code owner January 29, 2026 07:21
const PGBUF_WATCHER heap_header_watcher, HEAP_HDR_STATS * heap_hdr,
const VPID new_next_vpid, const VPID new_last_vpid, const int new_num_pages);

static bool heap_recdes_contains_oos (const RECDES * record);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heap_file.hpp에 extern으로 선언

// TODO: Find a way to obtain the Replication Key at this point, or change where repl_log_insert is called.
// For now, since this is a POC, an arbitrary value is temporarily passed as a dbvalue.
repl_log_insert (thread_p, &attr_info->class_oid, &oos_oid, LOG_REPLICATION_DATA, RVREPL_OOS_INSERT,
&attr_info->values[i].dbvalue, REPL_INFO_TYPE_RBR_NORMAL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replication key를 NULL로 전달하게 될 경우 NULL 체크 시 에러 발생하기 때문에 임시로 현재 dbvalue를 전달

#include "oid.h"
#include "oos_oid_queue.hpp"

thread_local std::deque<OID> g_oos_oid_queue;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OID를 queue에 넣어놨다가 사용하는 방식은 POC 수준에서 빨리 구현하기 위해 사용되었습니다.
추후 성능 측면에서 더 좋은 방식이 있다면 변경될 예정입니다.

Comment on lines +140 to +141
|| (rcvindex) == RVREPL_OOS_INSERT \
|| (rcvindex) == RVREPL_OOS_DELETE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOS Replication log는 OID를 queue에 넣어 치환하는 작업을 추가로 진행해줘야하기 때문에 rcvindex 타입을 추가하였습니다.

Comment on lines 5292 to 5293
recdes->data = recdes->data + 16;
recdes->length = recdes->length - 16;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 OOS에 저장된 recdes는 OOS_REC_HEADER + RECDES 구조로 되어있어 log에 해당 구조로 저장됩니다.

log에 저장된 data를 recovery시에는 해당 레코드가 존재했던 oid에 data를 그대로 쓰는 작업을 수행하고
replication시에는 log에 저장된 data(recdes)를 가지고 logical insert를 수행하고 있습니다.

logical insert시에 oos_insert를 호출하게 되면 전달받은 recdes 앞에 OOS_REC_HEADER를 또 추가하게 되는데, 이 때 OOS_REC_HEADER가 있음에도 불구하고 또 추가되는 문제가 발생합니다.

이 문제를 해결하기 위해 OOS_REC_HEADER의 크기인 16바이트를 제외한 영역을 recdes로 설정하는 작업입니다.

locator단에서 (int)sizeof (OOS_RECORD_HEADER)를 사용할 수 없어 임시로 16바이트 하드코딩을 해놓은 상태입니다.

추후 OOS_REC_HEADER 크기를 반환하는 함수 또는 매크로로 변경할 예정입니다.

@vimkim
Copy link
Contributor

vimkim commented Feb 2, 2026

/run build

// XXX: SHOULD BE THE LAST INCLUDE HEADER
#include "memory_wrapper.hpp"

struct oos_record_header
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.hpp로 이동

LOG_READ_ADD_ALIGN (thread_p, sizeof (*undoredo), &process_lsa, log_page_p);

//TODO : Additional handling for OOS columns in CDC will be needed later.
//TODO : Additional handling for OOS columns in CDC will be needed later.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codestyle.sh로 인한 변경사항

@H2SU H2SU requested a review from hyahong February 13, 2026 03:22
@H2SU H2SU merged commit 6031249 into CUBRID:feat/oos Feb 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants